summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--ChangeLog9
-rw-r--r--Makefile.am2
-rw-r--r--README50
-rwxr-xr-xbootstrap10
-rw-r--r--configure.ac17
-rw-r--r--contrib/Makefile.am68
-rwxr-xr-xcontrib/anastasis-dbconfig150
-rw-r--r--contrib/anastasis-pp-v0.rst (renamed from contrib/pp/pp.rst)0
-rw-r--r--contrib/anastasis-tos-v0.rst (renamed from contrib/tos/tos.rst)0
-rwxr-xr-xcontrib/extract.sh23
m---------contrib/gana0
-rw-r--r--contrib/locale/de/LC_MESSAGES/anastasis-tos-v0.po229
-rwxr-xr-xcontrib/pogen.sh3
-rw-r--r--contrib/pp/.gitignore3
-rw-r--r--contrib/pp/Makefile109
-rw-r--r--contrib/pp/README58
-rw-r--r--contrib/pp/en/0.epubbin14822 -> 0 bytes
-rw-r--r--contrib/pp/en/0.html188
-rw-r--r--contrib/pp/en/0.pdfbin75235 -> 0 bytes
-rw-r--r--contrib/pp/en/0.txt219
-rw-r--r--contrib/pp/en/0.xml177
-rw-r--r--contrib/pp/locale/de/LC_MESSAGES/pp.po511
-rw-r--r--contrib/provider-list.json40
-rw-r--r--contrib/redux.al.json7
-rw-r--r--contrib/redux.be.json3
-rw-r--r--contrib/redux.ch.json10
-rw-r--r--contrib/redux.countries.json205
-rw-r--r--contrib/redux.cz.json5
-rw-r--r--contrib/redux.de.json27
-rw-r--r--contrib/redux.dk.json5
-rw-r--r--contrib/redux.es.json8
-rw-r--r--contrib/redux.fr.json (renamed from contrib/redux.xy.json)20
-rw-r--r--contrib/redux.in.json3
-rw-r--r--contrib/redux.it.json7
-rw-r--r--contrib/redux.jp.json5
-rw-r--r--contrib/redux.nl.json37
-rw-r--r--contrib/redux.sk.json5
-rw-r--r--contrib/redux.us.json7
-rw-r--r--contrib/redux.xx.json13
-rw-r--r--contrib/tos/.gitignore3
-rw-r--r--contrib/tos/Makefile109
-rw-r--r--contrib/tos/README58
-rw-r--r--contrib/tos/conf.py282
-rw-r--r--contrib/tos/en/0.epubbin16289 -> 0 bytes
-rw-r--r--contrib/tos/en/0.html272
-rw-r--r--contrib/tos/en/0.pdfbin79435 -> 0 bytes
-rw-r--r--contrib/tos/en/0.txt287
-rw-r--r--contrib/tos/en/0.xml271
-rw-r--r--contrib/tos/locale/de/LC_MESSAGES/tos.po517
-rw-r--r--contrib/uncrustify.cfg2
-rwxr-xr-xcontrib/update-pp.sh11
-rwxr-xr-xcontrib/update-tos.sh11
-rw-r--r--debian/anastasis-httpd.config14
-rw-r--r--debian/anastasis-httpd.install9
-rw-r--r--debian/anastasis-httpd.postinst38
-rw-r--r--debian/anastasis-httpd.postrm11
-rw-r--r--debian/anastasis-httpd.preinst29
-rw-r--r--debian/anastasis-httpd.prerm11
-rw-r--r--debian/anastasis-httpd.service2
-rw-r--r--debian/changelog54
-rw-r--r--debian/control57
-rwxr-xr-xdebian/db/install/pgsql38
-rw-r--r--debian/etc/anastasis/anastasis.conf4
-rw-r--r--debian/etc/anastasis/secrets/anastasis-db.secret.conf2
-rwxr-xr-xdebian/rules8
-rw-r--r--doc/Makefile.am2
-rw-r--r--doc/anastasis-dbconfig.187
-rw-r--r--doc/anastasis-dbinit.189
-rw-r--r--doc/anastasis.texi1893
-rw-r--r--doc/sphinx/anastasis_reducer_recovery.drawio2
-rw-r--r--doc/sphinx/anastasis_reducer_recovery.pngbin52610 -> 51922 bytes
-rw-r--r--doc/sphinx/anastasis_reducer_recovery.svg3
-rw-r--r--doc/sphinx/conf.py6
-rw-r--r--doc/sphinx/configuration.rst3
-rw-r--r--doc/sphinx/core/api-common.rst15
-rw-r--r--doc/sphinx/frags/configuration-format.rst7
-rw-r--r--doc/sphinx/frags/legal.rst183
-rw-r--r--doc/sphinx/manpages/anastasis-dbconfig.1.rst61
-rw-r--r--doc/sphinx/manpages/anastasis-dbinit.1.rst67
-rw-r--r--doc/sphinx/manpages/anastasis-gtk.1.rst15
-rw-r--r--doc/sphinx/manpages/anastasis-reducer.1.rst14
-rw-r--r--doc/sphinx/manpages/anastasis.conf.5.rst6
-rw-r--r--doc/sphinx/reducer.rst135
-rw-r--r--doc/sphinx/rest.rst251
-rw-r--r--m4/ax_compare_version.m4177
-rw-r--r--m4/ax_lib_postgresql.m4272
-rw-r--r--po/POTFILES.in77
-rw-r--r--src/authorization/Makefile.am7
-rwxr-xr-xsrc/authorization/anastasis-authorization-email.sh1
-rwxr-xr-xsrc/authorization/anastasis-authorization-post.sh196
-rwxr-xr-xsrc/authorization/anastasis-authorization-sms.sh33
-rw-r--r--src/authorization/anastasis_authorization_plugin.c2
-rw-r--r--src/authorization/anastasis_authorization_plugin_email.c76
-rw-r--r--src/authorization/anastasis_authorization_plugin_file.c28
-rw-r--r--src/authorization/anastasis_authorization_plugin_iban.c281
-rw-r--r--src/authorization/anastasis_authorization_plugin_post.c83
-rw-r--r--src/authorization/anastasis_authorization_plugin_sms.c73
-rw-r--r--src/authorization/anastasis_authorization_plugin_totp.c62
-rw-r--r--src/authorization/authorization-email-messages.json4
-rw-r--r--src/authorization/authorization-post-messages.json2
-rw-r--r--src/authorization/iban.h2
-rw-r--r--src/authorization/libanastasiseufin/lae_common.h2
-rw-r--r--src/authorization/libanastasiseufin/lae_credit.c6
-rwxr-xr-xsrc/authorization/test-post.sh12
-rw-r--r--src/backend/Makefile.am10
-rw-r--r--src/backend/anastasis-httpd.c146
-rw-r--r--src/backend/anastasis-httpd.h9
-rw-r--r--src/backend/anastasis-httpd_config.c12
-rw-r--r--src/backend/anastasis-httpd_policy-meta.c192
-rw-r--r--src/backend/anastasis-httpd_policy-meta.h41
-rw-r--r--src/backend/anastasis-httpd_policy-upload.c (renamed from src/backend/anastasis-httpd_policy_upload.c)215
-rw-r--r--src/backend/anastasis-httpd_policy.c36
-rw-r--r--src/backend/anastasis-httpd_policy.h2
-rw-r--r--src/backend/anastasis-httpd_terms.c2
-rw-r--r--src/backend/anastasis-httpd_truth-challenge.c1331
-rw-r--r--src/backend/anastasis-httpd_truth-solve.c (renamed from src/backend/anastasis-httpd_truth.c)884
-rw-r--r--src/backend/anastasis-httpd_truth-upload.c (renamed from src/backend/anastasis-httpd_truth_upload.c)241
-rw-r--r--src/backend/anastasis-httpd_truth.h59
-rw-r--r--src/backend/anastasis.conf2
-rw-r--r--src/cli/.gitignore7
-rw-r--r--src/cli/Makefile.am28
-rw-r--r--src/cli/anastasis-cli-discover.c261
-rw-r--r--src/cli/anastasis-cli-redux.c43
-rw-r--r--src/cli/resources/00-backup.json7
-rw-r--r--src/cli/resources/00-recovery.json3
-rw-r--r--src/cli/resources/01-backup.json27
-rw-r--r--src/cli/resources/01-recovery.json3
-rw-r--r--src/cli/resources/02-backup.json35
-rw-r--r--src/cli/resources/02-recovery.json9
-rw-r--r--src/cli/resources/03-backup.json45
-rw-r--r--src/cli/resources/04-backup.json44
-rw-r--r--src/cli/resources/05-backup.json13
-rw-r--r--src/cli/resources/06-backup.json13
-rwxr-xr-xsrc/cli/setup.sh72
-rw-r--r--src/cli/test_anastasis_reducer_1.conf2
-rw-r--r--src/cli/test_anastasis_reducer_2.conf2
-rw-r--r--src/cli/test_anastasis_reducer_3.conf2
-rw-r--r--src/cli/test_anastasis_reducer_4.conf2
-rwxr-xr-xsrc/cli/test_anastasis_reducer_backup_enter_user_attributes.sh10
-rwxr-xr-xsrc/cli/test_anastasis_reducer_done_authentication.sh4
-rwxr-xr-xsrc/cli/test_anastasis_reducer_enter_secret.sh438
-rw-r--r--src/cli/test_anastasis_reducer_free_1.conf10
-rw-r--r--src/cli/test_anastasis_reducer_free_2.conf10
-rw-r--r--src/cli/test_anastasis_reducer_free_3.conf10
-rw-r--r--src/cli/test_anastasis_reducer_free_4.conf10
-rwxr-xr-xsrc/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh500
-rwxr-xr-xsrc/cli/test_anastasis_reducer_recovery_hanging.sh376
-rwxr-xr-xsrc/cli/test_anastasis_reducer_recovery_no_pay.sh351
-rwxr-xr-xsrc/cli/test_anastasis_reducer_select_continent.sh14
-rwxr-xr-xsrc/cli/test_anastasis_reducer_select_country.sh18
-rw-r--r--src/cli/test_free_reducer.conf2
-rwxr-xr-xsrc/cli/test_iban.sh363
-rw-r--r--src/cli/test_reducer.conf76
-rw-r--r--src/cli/test_reducer_free.conf210
-rw-r--r--src/cli/test_reducer_home/.local/share/taler/exchange-offline/master.priv1
-rw-r--r--src/include/anastasis.h363
-rw-r--r--src/include/anastasis_authorization_lib.h2
-rw-r--r--src/include/anastasis_authorization_plugin.h74
-rw-r--r--src/include/anastasis_crypto_lib.h69
-rw-r--r--src/include/anastasis_database_lib.h2
-rw-r--r--src/include/anastasis_database_plugin.h67
-rw-r--r--src/include/anastasis_eufin_lib.h2
-rw-r--r--src/include/anastasis_redux.h113
-rw-r--r--src/include/anastasis_service.h716
-rw-r--r--src/include/anastasis_testing_lib.h484
-rw-r--r--src/include/anastasis_util_lib.h39
-rw-r--r--src/include/gettext.h4
-rw-r--r--src/include/platform.h214
-rw-r--r--src/lib/Makefile.am1
-rw-r--r--src/lib/anastasis_backup.c84
-rw-r--r--src/lib/anastasis_meta.c178
-rw-r--r--src/lib/anastasis_recovery.c580
-rw-r--r--src/reducer/Makefile.am4
-rw-r--r--src/reducer/anastasis_api_backup_redux.c419
-rw-r--r--src/reducer/anastasis_api_discovery.c549
-rw-r--r--src/reducer/anastasis_api_providers.c300
-rw-r--r--src/reducer/anastasis_api_recovery_redux.c1745
-rw-r--r--src/reducer/anastasis_api_redux.c396
-rw-r--r--src/reducer/anastasis_api_redux.h56
-rw-r--r--src/reducer/validation_CH_AHV.c6
-rw-r--r--src/reducer/validation_CZ_BN.c6
-rw-r--r--src/reducer/validation_DE_SVN.c6
-rw-r--r--src/reducer/validation_DE_TIN.c6
-rw-r--r--src/reducer/validation_ES_DNI.c6
-rw-r--r--src/reducer/validation_FR_INSEE.c66
-rw-r--r--src/reducer/validation_IN_AADHAR.c6
-rw-r--r--src/reducer/validation_IT_CF.c6
-rw-r--r--src/reducer/validation_NL_BSN.c57
-rw-r--r--src/reducer/validation_XX_SQUARE.c6
-rw-r--r--src/reducer/validation_XY_PRIME.c6
-rw-r--r--src/restclient/Makefile.am10
-rw-r--r--src/restclient/anastasis_api_config.c131
-rw-r--r--src/restclient/anastasis_api_curl_defaults.c19
-rw-r--r--src/restclient/anastasis_api_curl_defaults.h6
-rw-r--r--src/restclient/anastasis_api_keyshare_lookup.c65
-rw-r--r--src/restclient/anastasis_api_policy_lookup.c29
-rw-r--r--src/restclient/anastasis_api_policy_meta_lookup.c272
-rw-r--r--src/restclient/anastasis_api_policy_store.c48
-rw-r--r--src/restclient/anastasis_api_truth_challenge.c456
-rw-r--r--src/restclient/anastasis_api_truth_solve.c437
-rw-r--r--src/restclient/anastasis_api_truth_store.c16
-rw-r--r--src/stasis/Makefile.am15
-rw-r--r--src/stasis/anastasis_db_plugin.c2
-rw-r--r--src/stasis/drop.sql (renamed from src/stasis/drop0001.sql)25
-rw-r--r--src/stasis/plugin_anastasis_postgres.c596
-rw-r--r--src/stasis/stasis-0001.sql58
-rw-r--r--src/stasis/test_anastasis_db.c14
-rw-r--r--src/stasis/versioning.sql (renamed from src/stasis/stasis-0000.sql)3
-rw-r--r--src/testing/.gitignore5
-rw-r--r--src/testing/Makefile.am25
-rw-r--r--src/testing/test_anastasis.c186
-rw-r--r--src/testing/test_anastasis_api.c200
-rw-r--r--src/testing/test_anastasis_api.conf170
-rw-r--r--src/testing/test_anastasis_api_home/.config/taler/exchange/account-2.json3
-rw-r--r--src/testing/test_anastasis_api_home/taler/exchange-offline/master.priv (renamed from src/testing/test_anastasis_api_home/.local/share/taler/exchange/offline-keys/master.priv)0
-rw-r--r--src/testing/test_anastasis_api_home/taler/exchange/offline-keys/master.priv1
-rw-r--r--src/testing/testing_api_cmd_config.c46
-rw-r--r--src/testing/testing_api_cmd_policy_lookup.c37
-rw-r--r--src/testing/testing_api_cmd_policy_store.c40
-rw-r--r--src/testing/testing_api_cmd_truth_challenge.c368
-rw-r--r--src/testing/testing_api_cmd_truth_solve.c (renamed from src/testing/testing_api_cmd_keyshare_lookup.c)240
-rw-r--r--src/testing/testing_api_cmd_truth_store.c43
-rw-r--r--src/testing/testing_api_helpers.c6
-rw-r--r--src/testing/testing_api_trait_account_priv.c58
-rw-r--r--src/testing/testing_api_trait_account_pub.c58
-rw-r--r--src/testing/testing_api_trait_code.c59
-rw-r--r--src/testing/testing_api_trait_eks.c58
-rw-r--r--src/testing/testing_api_trait_hash.c57
-rw-r--r--src/testing/testing_api_trait_payment_secret.c59
-rw-r--r--src/testing/testing_api_trait_salt.c60
-rw-r--r--src/testing/testing_api_trait_truth_key.c58
-rw-r--r--src/testing/testing_api_trait_truth_uuid.c61
-rw-r--r--src/testing/testing_api_traits.c36
-rw-r--r--src/testing/testing_cmd_challenge_answer.c280
-rw-r--r--src/testing/testing_cmd_policy_create.c17
-rw-r--r--src/testing/testing_cmd_recover_secret.c64
-rw-r--r--src/testing/testing_cmd_secret_share.c69
-rw-r--r--src/testing/testing_cmd_truth_upload.c57
-rw-r--r--src/testing/testing_trait_challenge.c57
-rw-r--r--src/testing/testing_trait_core_secret.c59
-rw-r--r--src/testing/testing_trait_policy.c58
-rw-r--r--src/testing/testing_trait_truth.c58
-rw-r--r--src/util/Makefile.am6
-rw-r--r--src/util/anastasis-config.c6
-rw-r--r--src/util/anastasis-config.in5
-rw-r--r--src/util/anastasis-crypto-tvg.c32
-rw-r--r--src/util/anastasis_crypto.c151
-rw-r--r--src/util/os_installation.c4
-rw-r--r--src/util/pin.c84
-rw-r--r--src/util/test_anastasis_crypto.c28
251 files changed, 15680 insertions, 10901 deletions
diff --git a/.gitignore b/.gitignore
index 0d5dbc1..998e44b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -130,3 +130,4 @@ src/cli/test_reducer.err
vgcore*
__pycache__
tags
+contrib/extracted.h
diff --git a/ChangeLog b/ChangeLog
index 66b6c39..e9407a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon 26 Sep 2022 02:48:38 PM CEST
+ Multiple providers operational.
+ WebUI operational at https://webui.anastasis.lu/.
+ Various UI/UX improvements.
+ Releasing Anastasis v0.3.0. -CG
+
+Thu 30 Sep 2021 03:48:38 PM CEST
+ Releasing Anastasis v0.2.0. -CG
+
Tue 24 Aug 2021 10:30:23 PM CEST
IBAN authentication support working.
Releasing Anastasis v0.1.0. -CG
diff --git a/Makefile.am b/Makefile.am
index 8a6319e..c7549a7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@ else
if ENABLE_DOC
SUBDIRS = . contrib src doc po
else
- SUBDIRS = . contrib src doc po
+ SUBDIRS = . contrib src po
endif
endif
diff --git a/README b/README
index db5dcf0..a753c3b 100644
--- a/README
+++ b/README
@@ -48,3 +48,53 @@ src/cli/ includes a reducer-based command-line interface
contrib/ contains resource files, like what identity attributes to ask for
doc/ contains documentation files, like TeXinfo
po/ internationalization via GNU gettext
+
+
+Development note
+================
+
+To test against a local development service, add
+
+ {
+ "code" : "xx",
+ "name" : "Testland",
+ "continent" : "Demoworld",
+ "call_code" : "+00"
+ }
+
+to contrib/redux.countries.json, and also append something like
+
+ {
+ "url" : "http://localhost:8086/",
+ "restricted" : "xx"
+ },
+ {
+ "url" : "http://localhost:8087/",
+ "restricted" : "xx"
+ },
+ {
+ "url" : "http://localhost:8088/",
+ "restricted" : "xx"
+ },
+ {
+ "url" : "http://localhost:8089/",
+ "restricted" : "xx"
+ }
+
+to contrib/provider-list.json. Then the reducer will use these
+providers on loopback for the "testland" country.
+
+
+Experimental providers
+======================
+
+We hope to have another provider running soon. Once it is operational,
+we should add
+
+ {
+ "url" : "https://v1.anastasis.openw3b.org/",
+ "name" : "Openw3b Foundation, India"
+ },
+
+to the contrib/provider-list.json.
+
diff --git a/bootstrap b/bootstrap
index a7414cd..eaaf3fc 100755
--- a/bootstrap
+++ b/bootstrap
@@ -5,10 +5,16 @@ if ! git --version >/dev/null; then
exit 1
fi
+if ! htmlark --version >/dev/null; then
+ echo "htmlark not installed"
+ echo "Run 'pip install htmlark'"
+ exit 1
+fi
+
echo "$0: Updating submodules"
-echo | git submodule update --init
+echo | git submodule update --init --force --remote
-git submodule update --init
+git submodule update --init --force --remote
./contrib/gana-update.sh
diff --git a/configure.ac b/configure.ac
index 70778fb..8b7b83c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
# This configure file is in the public domain
AC_PREREQ([2.69])
-AC_INIT([anastasis], [0.2.0], [taler-bug@gnu.org])
+AC_INIT([anastasis],[0.4.1],[taler-bug@gnu.org])
AC_CONFIG_SRCDIR([src/backend/anastasis-httpd.c])
AC_CONFIG_HEADERS([anastasis_config.h])
# support for non-recursive builds
@@ -16,7 +16,7 @@ AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_AWK
-AC_PROG_CC_C99
+AC_PROG_CC
AC_PROG_OBJC
AC_PROG_INSTALL
AC_PROG_LN_S
@@ -47,7 +47,6 @@ AS_IF([test "x$doc_only" != xyes],[
# Checks for programs.
AC_PROG_CC
-AC_PROG_CC_C99
# check for gettext
AM_GNU_GETTEXT([external])
@@ -138,25 +137,21 @@ AS_CASE([$with_gnunet],
[no], [AC_MSG_ERROR([--with-gnunet is required])],
[LDFLAGS="-L$with_gnunet/lib $LDFLAGS"
CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"])
-AC_CHECK_HEADERS([gnunet/platform.h gnunet/gnunet_util_lib.h],
+AC_CHECK_HEADERS([gnunet/gnunet_util_lib.h],
[AC_CHECK_LIB([gnunetutil],
[GNUNET_SCHEDULER_run],
- [libgnunetutil=1])],
- [],
- [#ifdef HAVE_GNUNET_PLATFORM_H
- #include <gnunet/platform.h>
- #endif])
+ [libgnunetutil=1])])
AS_IF([test $libgnunetutil != 1],
[AC_MSG_ERROR([[
***
-*** You need libgnunetutil to build this program.
+*** You need libgnunetutil >= 0.20.0 to build this program.
*** This library is part of GNUnet, available at
*** https://gnunet.org
*** ]])])
# test for postgres
-AX_LIB_POSTGRESQL([9.3])
+AX_LIB_POSTGRESQL([15])
AS_IF([test "x$found_postgresql" = "xyes"],[postgres=true])
AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index a2bdf27..47c5e8e 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -3,50 +3,39 @@
SUBDIRS = .
-# English (en)
-tosendir=$(datadir)/anastasis/tos/en
+bin_SCRIPTS = \
+ anastasis-dbconfig
-# English (en)
-ppendir=$(datadir)/anastasis/pp/en
+termsdir=$(datadir)/anastasis/terms/
+terms_DATA = \
+ anastasis-tos-v0.rst \
+ anastasis-pp-v0.rst
-tosen_DATA = \
- tos/en/0.txt \
- tos/en/0.pdf \
- tos/en/0.epub \
- tos/en/0.xml \
- tos/en/0.html
-
-ppen_DATA = \
- pp/en/0.txt \
- pp/en/0.pdf \
- pp/en/0.epub \
- pp/en/0.xml \
- pp/en/0.html
+install-exec-local:
+ find locale/ -name "*.po"
+ mkdir -p $(DESTDIR)$(datadir)
+ cp --parents -r $$(find locale/ -name "*.po") $(DESTDIR)$(datadir)
+extracted.h: *.json
+ ./extract.sh
+noinst_SCRIPTS = extracted.h
pkgdatadir= $(prefix)/share/anastasis/
EXTRA_DIST = \
+ locale/de/LC_MESSAGES/anastasis-tos-v0.po \
+ $(bin_SCRIPTS) \
$(pkgdata_DATA) \
- $(tosen_DATA) \
- $(ppen_DATA) \
- tos/Makefile \
- tos/README \
- tos/tos.rst \
- tos/conf.py \
- tos/locale/de/LC_MESSAGES/tos.po \
- pp/Makefile \
- pp/README \
- pp/pp.rst \
- pp/conf.py \
- pp/locale/de/LC_MESSAGES/pp.po \
+ $(terms_DATA) \
pogen.sh \
uncrustify.cfg \
uncrustify_precommit \
gana.sh \
gana-update.sh \
- microhttpd.tag
+ microhttpd.tag \
+ extract.sh \
+ extracted.h
pkgdata_DATA = \
redux.al.json \
@@ -56,28 +45,13 @@ pkgdata_DATA = \
redux.de.json \
redux.dk.json \
redux.es.json \
+ redux.fr.json \
redux.in.json \
redux.it.json \
redux.jp.json \
+ redux.nl.json \
redux.sk.json \
redux.us.json \
redux.xx.json \
- redux.xy.json \
redux.countries.json \
provider-list.json
-
-# Change the set of supported languages here. You should
-# also update tos'XX'data and EXTRA_DIST accordingly.
-TOS_LANGUAGES="en de"
-PP_LANGUAGES="en de"
-
-# Change the terms-of-service version (Etag) to generate here!
-# This value should be incremented whenever there is a substantive
-# change in the original text (but not for the translations).
-TOS_VERSION=0
-PP_VERSION=0
-
-update-tos:
- VERSION=$(TOS_VERSION) ./update-tos.sh $(TOS_LANGUAGES)
-update-pp:
- VERSION=$(PP_VERSION) ./update-pp.sh $(PP_LANGUAGES)
diff --git a/contrib/anastasis-dbconfig b/contrib/anastasis-dbconfig
new file mode 100755
index 0000000..d4af960
--- /dev/null
+++ b/contrib/anastasis-dbconfig
@@ -0,0 +1,150 @@
+#!/bin/bash
+# This file is part of GNU ANASTASIS.
+# Copyright (C) 2023 Anastasis Systems SA
+#
+# ANASTASIS is free software; you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free Software
+# Foundation; either version 2.1, or (at your option) any later version.
+#
+# ANASTASIS is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License along with
+# ANASTASIS; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+#
+# @author Christian Grothoff
+#
+#
+# Error checking on
+set -eu
+
+RESET_DB=0
+SKIP_DBINIT=0
+DBUSER="anastasis-httpd"
+CFGFILE="/etc/anastasis/secrets/anastasis-db.secret.conf"
+
+# Parse command-line options
+while getopts 'c:hrsu:' OPTION; do
+ case "$OPTION" in
+ c)
+ CFGFILE="$OPTARG"
+ ;;
+ h)
+ echo 'Supported options:'
+ echo " -c FILENAME -- write configuration to FILENAME (default: $CFGFILE)"
+ echo " -r -- reset database (dangerous)"
+ echo " -s -- skip database initialization"
+ echo " -u USER -- anastasis-httpd to be run by USER (default: $DBUSER)"
+ exit 0
+ ;;
+ r)
+ RESET_DB="1"
+ ;;
+ s)
+ SKIP_DBINIT="1"
+ ;;
+ u)
+ DBUSER="$OPTARG"
+ ;;
+ ?)
+ exit_fail "Unrecognized command line option"
+ ;;
+ esac
+done
+
+if ! id postgres > /dev/null
+then
+ echo "Could not find 'postgres' user. Please install Postgresql first"
+ exit 1
+fi
+
+if [ "$(id -u)" -ne 0 ]
+then
+ echo "This script must be run as root"
+ exit 1
+fi
+
+if [ 0 = "$SKIP_DBINIT" ]
+then
+ if ! anastasis-dbinit -v 2> /dev/null
+ then
+ echo "Required 'anastasis-dbinit' not found. Please fix your installation."
+ exit 1
+ fi
+ DBINIT=$(which anastasis-dbinit)
+fi
+
+if ! id "$DBUSER" > /dev/null
+then
+ echo "Could not find '$DBUSER' user. Please set it up first"
+ exit 1
+fi
+
+echo "Setting up database user $DBUSER." 1>&2
+
+if ! sudo -i -u postgres createuser "$DBUSER" 2> /dev/null
+then
+ echo "Database user '$DBUSER' already existed. Continuing anyway." 1>&2
+fi
+
+DBPATH=$(anastasis-config \
+ -c "$CFGFILE" \
+ -s stasis-postgres \
+ -o CONFIG)
+
+if ! echo "$DBPATH" | grep "postgres://" > /dev/null
+then
+ echo "Invalid database configuration value '$DBPATH'." 1>&2
+ exit 1
+fi
+
+DBNAME=$(echo "$DBPATH" \
+ | sed \
+ -e "s/postgres:\/\/.*\///" \
+ -e "s/?.*//")
+
+
+if sudo -i -u postgres psql "$DBNAME" < /dev/null 2> /dev/null
+then
+ if [ 1 = "$RESET_DB" ]
+ then
+ echo "Deleting existing database $DBNAME." 1>&2
+ if ! sudo -i -u postgres dropdb "$DBNAME"
+ then
+ echo "Failed to delete existing database '$DBNAME'"
+ exit 1
+ fi
+ DO_CREATE=1
+ else
+ echo "Database '$DBNAME' already exists, continuing anyway."
+ DO_CREATE=0
+ fi
+else
+ DO_CREATE=1
+fi
+
+if [1 = "$DO_CREATE" ]
+then
+ echo "Creating database $DBNAME." 1>&2
+
+ if ! sudo -i -u postgres createdb -O "$DBUSER" "$DBNAME"
+ then
+ echo "Failed to create database '$DBNAME'"
+ exit 1
+ fi
+fi
+
+if [ 0 = "$SKIP_DBINIT" ]
+then
+ echo "Initializing database $DBNAME." 1>&2
+ if ! sudo -u "$DBUSER" "$DBINIT" -c "$CFGFILE"
+ then
+ echo "Failed to initialize database schema"
+ exit 1
+ fi
+fi
+
+echo "Database configuration finished." 1>&2
+
+exit 0
diff --git a/contrib/pp/pp.rst b/contrib/anastasis-pp-v0.rst
index 8972028..8972028 100644
--- a/contrib/pp/pp.rst
+++ b/contrib/anastasis-pp-v0.rst
diff --git a/contrib/tos/tos.rst b/contrib/anastasis-tos-v0.rst
index 4445601..4445601 100644
--- a/contrib/tos/tos.rst
+++ b/contrib/anastasis-tos-v0.rst
diff --git a/contrib/extract.sh b/contrib/extract.sh
new file mode 100755
index 0000000..e879e74
--- /dev/null
+++ b/contrib/extract.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# This file is in the public domain.
+# It extracts translateable strings from the JSON file(s).
+#
+# The resulting 'extracted.h' file is only used by
+# gettext, and not in the actual code. We still make
+# sure it is legal C code.
+
+for n in redux.??.json
+do
+ jq '.required_attributes[].label' < $n | awk '{print "_(" $0 "),"}' >> prep.h
+done
+
+jq '.countries[].continent' < redux.countries.json | awk '{print "_(" $0 "),"}' >> prep.h
+
+jq '.countries[].name' < redux.countries.json | awk '{print "_(" $0 "),"}' >> prep.h
+
+echo "// This is a generated file, see extract.sh" > extracted.h
+echo "const char * i18n[] = {" >> extracted.h
+sort prep.h | uniq >> extracted.h
+echo "};" >> extracted.h
+
+rm -f prep.h
diff --git a/contrib/gana b/contrib/gana
-Subproject f126ffd32255c68f4fbef5e9ef849ef04855b0a
+Subproject 4728c9e60ce121f439b3db30cc08f06ff0beff7
diff --git a/contrib/locale/de/LC_MESSAGES/anastasis-tos-v0.po b/contrib/locale/de/LC_MESSAGES/anastasis-tos-v0.po
new file mode 100644
index 0000000..6eb06d2
--- /dev/null
+++ b/contrib/locale/de/LC_MESSAGES/anastasis-tos-v0.po
@@ -0,0 +1,229 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) 2014-2023 Taler Systems SA (GPLv3+ or GFDL 1.3+)
+# This file is distributed under the same license as the anastasis-tos-v0 package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: anastasis-tos-v0 anastasis-tos-v0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2023-08-12 09:27+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:2
+msgid "Terms Of Service"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:4
+msgid "Last Updated: 07.09.2021"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:6
+msgid "Welcome! Anastasis SARL (“we,†“our,†or “usâ€) provides a distributed privacy-preserving backup and recovery service for key material through our Internet presence (collectively the “Servicesâ€). Before using our Services, please read the Terms of Service (the “Terms†or the “Agreementâ€) carefully."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:13
+msgid "Overview"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:15
+msgid "This section provides a brief summary of the highlights of this Agreement. Please note that when you accept this Agreement, you are accepting all of the terms and conditions and not just this section. We and possibly other third parties provide Internet services which interact with the Anastasis key backup and recovery application. When using an application to interact with our Services, you are agreeing to our Terms, so please read carefully."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:25
+msgid "Highlights:"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:27
+msgid "You are responsible for selecting authentication methods and policies that are adequate to protect your key material. Any losses arising from you not being able to satisfy the selected authentication challenges or third parties being able successfully pass the challenges are your problem."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:32
+msgid "We will store your encrypted key shares and disclose them upon successful authentication to the best of our ability within the limitations of the law and our implementation. Our liability will be limited to the liability limit exposed in the protocol."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:36
+msgid "For our Services, we may charge various fees. The specific fee structure is provided based on the Anastasis protocol and should be shown to you when you use an application to interact with our services. You agree and understand that the Anastasis protocol allows for the fee structure to change."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:40
+msgid "You agree to not intentionally overwhelm our systems with requests and follow responsible disclosure if you find security issues in our services."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:42
+msgid "We cannot be held accountable for our Services not being available due to circumstances beyond our control. If we modify or terminate our services, we will announce this and ensure that you can recover your key material for at least one year before we completely terminate the Service."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:47
+msgid "These terms outline approved uses of our Services. If you have any questions or comments related to this Agreement, please send us a message to legal@anastasis.lu. If you do not agree to this Agreement, you must not use our Services."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:54
+msgid "How you accept this policy"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:56
+msgid "By using our API (typically via an Anastasis-enabled application), you acknowledge that you have read, understood, and agreed to these Terms. We reserve the right to change these Terms at any time. If you disagree with the change, you must simply stop using our APIs. Your continued use of our Services following any such change will signify your acceptance to be bound by the then current Terms. Please check the effective date above to determine if there have been any changes since you have last reviewed these Terms."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:66
+msgid "Services"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:68
+msgid "We will store your encrypted key shares (and the associated encrypted recovery policy document) to the best of our ability and within the limitations of the implementation. We will disclose the key shares only after the specific authentication challenge has been passed. We will rate-limit the use of the authentication APIs to limit brute-force attacks."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:75
+msgid "We are not guaranteeing that the authentication procedures are effective. Other parties may be able to intercept authentication messages, or you may not be able to receive these messages anymore. You are responsible for choosing safe authentication methods with sufficient security."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:80
+msgid "When using our Services, you agree to not take any action that intentionally imposes an unreasonable load on our infrastructure. If you find security problems in our Services, you agree to first report them to security@anastasis.lu and grant us the right to publish your report. We warrant that we will ourselves publicly disclose any issues reported within 1 month, and that we will not prosecute anyone reporting security issues if they did not exploit the issue beyond a proof-of-concept, and followed the above responsible disclosure practice."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:92
+msgid "Fees"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:94
+msgid "You agree to pay the fees for backup and recovery operations (\"Fees\") as defined by us, which we may change from time to time. Your Anastasis client should obtain and display applicable fees during backup and recovery."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:101
+msgid "Eligibility"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:103
+msgid "To be eligible to use our Services, you must be able to form legally binding contracts or have the permission of your legal guardian. By using our Services, you represent and warrant that you meet all eligibility requirements that we outline in these Terms."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:110
+msgid "Copyrights and trademarks"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:112
+msgid "The Anastasis software is released under the terms of the GNU Affero General Public License (GNU AGPLv3+). You have the right to access, use, and share the Anastasis application, in modified or unmodified form. However, the Affero GPL is a strong copyleft license, which means that any derivative works must be distributed under the same license terms as the original software. If you have any questions, you should review the GNU AGPL’s full terms and conditions at https://www.gnu.org/licenses/agpl-3.0.en.html. “Anastasis†itself is a trademark of Anastasis SARL. You are welcome to use the name in relation to implementations of the Anastasis protocol, assuming your use is compatible with an official release from the GNU Project that is not older than two years."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:127
+msgid "Limitation of liability & disclaimer of warranties"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:129
+msgid "You understand and agree that we have no control over, and no duty to take any action regarding: Failures, disruptions, errors, or delays in processing that you may experience while using our Services; The risk of failure of hardware, software, and Internet connections; The risk of malicious software being introduced or found in the software underlying the Anastasis implementation. You release us from all liability related to any losses, damages, or claims arising from:"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:137
+msgid "user error such as forgotten security answers or loss of control over accounts used for authentication;"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:139
+msgid "(b) server failure or data loss; (d) bugs or other errors in the Anastasis client software; and (e) any unauthorized third party activities, including, but not limited to,"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:142
+msgid "the use of viruses, phishing, brute forcing, or other means of attack against the Anastasis client. We make no representations concerning any Third Party Content contained in or accessed through our Services."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:146
+msgid "Any other terms, conditions, warranties, or representations associated with such content, are solely between you and such organizations and/or individuals."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:150
+msgid "To the fullest extent permitted by applicable law, in no event will we or any of our officers, directors, representatives, agents, servants, counsel, employees, consultants, lawyers, and other personnel authorized to act, acting, or purporting to act on our behalf (collectively the “Anastasis Partiesâ€) be liable to you under contract, tort, strict liability, negligence, or any other legal or equitable theory, for:"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:158
+msgid "any lost profits, data loss, cost of procurement of substitute goods or services, or direct, indirect, incidental, special, punitive, compensatory, or consequential damages of any kind whatsoever resulting from:"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:162
+msgid "your use of, or conduct in connection with, our services;"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:163
+msgid "any unauthorized use of your wallet and/or private key due to your failure to maintain the confidentiality of your wallet;"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:165
+msgid "any interruption or cessation of transmission to or from the services; or"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:166
+msgid "any bugs, viruses, trojan horses, or the like that are found in the Taler Wallet software or that may be transmitted to or through our services by any third party (regardless of the source of origination), or"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:170
+msgid "any direct damages."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:172
+msgid "These limitations apply regardless of legal theory, whether based on tort, strict liability, breach of contract, breach of warranty, or any other legal theory, and whether or not we were advised of the possibility of such damages. Some jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, so the above limitation may not apply to you."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:179
+msgid "Our services are provided \"as is\" and without warranty of any kind. To the maximum extent permitted by law, we disclaim all representations and warranties, express or implied, relating to the services and underlying software or any content on the services, whether provided or owned by us or by any third party, including without limitation, warranties of merchantability, fitness for a particular purpose, title, non-infringement, freedom from computer virus, and any implied warranties arising from course of dealing, course of performance, or usage in trade, all of which are expressly disclaimed. In addition, we do not represent or warrant that the content accessible via the services is accurate, complete, available, current, free of viruses or other harmful components, or that the results of using the services will meet your requirements. Some states do not allow the disclaimer of implied warranties, so the foregoing disclaimers may not apply to you. This paragraph gives you specific legal rights and you may also have other legal rights that vary from state to state."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:196
+msgid "Indemnity and Time limitation on claims and Termination"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:198
+msgid "To the extent permitted by applicable law, you agree to defend, indemnify, and hold harmless the Anastasis Parties from and against any and all claims, damages, obligations, losses, liabilities, costs or debt, and expenses (including, but not limited to, attorney’s fees) arising from: (a) your use of and access to the Services; (b) any feedback or submissions you provide to us concerning the Anastasis software; (c) your violation of any term of this Agreement; or (d) your violation of any law, rule, or regulation, or the rights of any third party."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:208
+msgid "You agree that any claim you may have arising out of or related to your relationship with us must be filed within one year after such claim arises, otherwise, your claim in permanently barred."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:212
+msgid "In the event of termination concerning your use of our Services, your obligations under this Agreement will still continue."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:217
+msgid "Discontinuance of services and Force majeure"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:219
+msgid "We shall not be held liable for any delays, failure in performance, or interruptions of service which result directly or indirectly from any cause or condition beyond our reasonable control, including but not limited to: any delay or failure due to any act of God, act of civil or military authorities, act of terrorism, civil disturbance, war, strike or other labor dispute, fire, interruption in telecommunications or Internet services or network provider services, failure of equipment and/or software, other catastrophe, or any other occurrence which is beyond our reasonable control and shall not affect the validity and enforceability of any remaining provisions."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:231
+msgid "Governing law, Waivers, Severability and Assignment"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:233
+msgid "No matter where you’re located, the laws of Luxembourg will govern these Terms. If any provisions of these Terms are inconsistent with any applicable law, those provisions will be superseded or modified only to the extent such provisions are inconsistent. The parties agree to submit to the ordinary courts in Luxembourg for exclusive jurisdiction of any dispute arising out of or related to your use of the Services or your breach of these Terms."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:241
+msgid "Our failure to exercise or delay in exercising any right, power, or privilege under this Agreement shall not operate as a waiver; nor shall any single or partial exercise of any right, power, or privilege preclude any other or further exercise thereof."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:246
+msgid "You agree that we may assign any of our rights and/or transfer, sub-contract, or delegate any of our obligations under these Terms."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:249
+msgid "If it turns out that any part of this Agreement is invalid, void, or for any reason unenforceable, that term will be deemed severable and limited or eliminated to the minimum extent necessary."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:253
+msgid "This Agreement sets forth the entire understanding and agreement as to the subject matter hereof and supersedes any and all prior discussions, agreements, and understandings of any kind (including, without limitation, any prior versions of this Agreement) and every nature between us. Except as provided for above, any modification to this Agreement must be in writing and must be signed by both parties."
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:262
+msgid "Questions or comments"
+msgstr ""
+
+#: ../../../../../../../../../tmp/taler-terms-CS0F7n/anastasis-tos-v0.rst:264
+msgid "We welcome comments, questions, concerns, or suggestions. Please send us a message on our contact page at legal@anastasis.lu."
+msgstr ""
diff --git a/contrib/pogen.sh b/contrib/pogen.sh
index 89140ea..21eedce 100755
--- a/contrib/pogen.sh
+++ b/contrib/pogen.sh
@@ -1,3 +1,4 @@
#!/bin/sh
find src -name "*.c" | sort > po/POTFILES.in
-find contrib -name "*.json" | sort >> po/POTFILES.in
+echo "contrib/extracted.h" >> po/POTFILES.in
+echo "src/authorization/extracted.h" >> po/POTFILES.in
diff --git a/contrib/pp/.gitignore b/contrib/pp/.gitignore
deleted file mode 100644
index fb83616..0000000
--- a/contrib/pp/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-sphinx.err
-sphinx.log
-_build/
diff --git a/contrib/pp/Makefile b/contrib/pp/Makefile
deleted file mode 100644
index ab29543..0000000
--- a/contrib/pp/Makefile
+++ /dev/null
@@ -1,109 +0,0 @@
-# Makefile for Sphinx documentation
-#
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-BUILDDIR = _build
-
-# User-friendly check for sphinx-build
-ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
-$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
-endif
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html json epub latex latexpdf text man doctest gettext
-
-help:
- @echo "Please use \`make <target>' where <target> is one of"
- @echo " html to make a single large HTML file"
- @echo " json to make JSON files"
- @echo " epub to make an epub"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " pdf to make LaTeX files and run them through pdflatex"
- @echo " txt to make text files"
- @echo " man to make manual pages"
- @echo " texinfo to make Texinfo files"
- @echo " info to make Texinfo files and run them through makeinfo"
- @echo " gettext to make PO message catalogs"
- @echo " xml to make Docutils-native XML files"
- @echo " pseudoxml to make pseudoxml-XML files for display purposes"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
-
-clean:
- rm -rf $(BUILDDIR)/*
-
-
-# The html-linked builder does not support caching, so we
-# remove all cached state first.
-html:
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML page is in $(BUILDDIR)/html."
-
-json:
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-epub:
- $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
- @echo
- @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo
- @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
- @echo "Run \`make' in that directory to run these through (pdf)latex" \
- "(use \`make latexpdf' here to do that automatically)."
-
-pdf:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/pdf
- @echo "Running LaTeX files through pdflatex..."
- $(MAKE) -C $(BUILDDIR)/pdf all-pdf
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/pdf."
-
-txt:
- $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/txt
- @echo
- @echo "Build finished. The text files are in $(BUILDDIR)/txt."
-
-man:
- $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
- @echo
- @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-texinfo:
- $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
- @echo
- @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
- @echo "Run \`make' in that directory to run these through makeinfo" \
- "(use \`make info' here to do that automatically)."
-
-info:
- $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/info
- @echo "Running Texinfo files through makeinfo..."
- make -C $(BUILDDIR)/texinfo info
- @echo "makeinfo finished; the Info files are in $(BUILDDIR)/info."
-
-gettext:
- $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
- @echo
- @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-doctest:
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in $(BUILDDIR)/doctest/output.txt."
-
-xml:
- $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
- @echo
- @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
diff --git a/contrib/pp/README b/contrib/pp/README
deleted file mode 100644
index d221b14..0000000
--- a/contrib/pp/README
+++ /dev/null
@@ -1,58 +0,0 @@
-This directory contains the privacy policy (template) for Anastasis
-operators.
-
-
-Dependencies
-============
-
-Generating a new Privacy Policy requires Sphinx, LaTeX with babel
-packages for all supported languages. On Debian, you should
-at least install:
-
-$ apt install python3-sphinx sphinx-intl texlive-lang-german texlive-lang-english
-
-(NOTE: List may be incomplete.)
-
-
-Updating the Privacy Policy
-===========================
-
-The master file with the Privacy Policy is 'pp.rst'.
-
-If you make substantial changes, you MUST change the "PP_VERSION"
-in contrib/Makefile.am to the new Etag.
-
-To begin the translation into other languages after editing the master
-file, run
-
-$ make gettext
-
-to generate the master PO file. Then, run
-
-$ sphinx-intl update -p _build/locale/ -l de -l fr -l it
-
-to update the PO files for the various languages (extend the list of
-languages as necessary). The PO files for the translators are kept
-at locale/$LANG/LC_MESSAGES/pp.po for the language $LANG.
-
-Once all PO files have been updated with new translations, run
-
-$ make update-pp
-
-in the "contrib/" directory to generate all of the formats. The
-respective make rule calls the '../update-pp.sh' script in the
-contrib/ directory, which calls the 'Makefile' in the pp/
-directory for the various supported languages and file formats
-and then moves the generated files to the target directory
-('contrib/pp/$LANG/$VERSION.$FORMAT')
-
-
-Adding a new language
-=====================
-
-To add a new language $LANG, add $LANG to "PP_LANGUAGES" in
-'contrib/Makefile.am' and run
-
-$ sphinx-intl update -p _build/gettext -l $LANG
-
-to generate the PO template.
diff --git a/contrib/pp/en/0.epub b/contrib/pp/en/0.epub
deleted file mode 100644
index b77975b..0000000
--- a/contrib/pp/en/0.epub
+++ /dev/null
Binary files differ
diff --git a/contrib/pp/en/0.html b/contrib/pp/en/0.html
deleted file mode 100644
index 6f9fa46..0000000
--- a/contrib/pp/en/0.html
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Privacy Policy &#8212; Taler Privacy Policy</title>
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <link rel="stylesheet" href="_static/epub.css" type="text/css" />
- <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script src="_static/jquery.js"></script>
- <script src="_static/underscore.js"></script>
- <script src="_static/doctools.js"></script>
- </head><body>
-
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <div class="section" id="privacy-policy">
-<h1>Privacy Policy<a class="headerlink" href="#privacy-policy" title="Permalink to this headline">¶</a></h1>
-<p>Last Updated: 07.09.2021</p>
-<p>This Privacy Policy describes the policies and procedures of Anastasis
-SARL (“we,†“our,†or “usâ€) pertaining to the collection, use, and
-disclosure of your information on our sites and related mobile
-applications and products we offer (the “Servicesâ€). This Privacy
-Statement applies to your personal data when you use our Services, and
-does not apply to online websites or services that we do not own or
-control.</p>
-<div class="section" id="overview">
-<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2>
-<p>Your privacy is important to us. We follow a few fundamental
-principles: We don’t ask you for personally identifiable information
-(defined below). That being said, your contact information, such as
-your phone number, social media handle, or email address (depending on
-how you contact us), may be collected when you communicate with us,
-for example to report a bug or other error related to Anastasis. We
-don’t share your information with third parties except when strictly
-required to deliver you our Services and products, or to comply with
-the law. If you have any questions or concerns about this policy,
-please reach out to us at <a class="reference external" href="mailto:privacy&#37;&#52;&#48;anastasis&#46;lu">privacy<span>&#64;</span>anastasis<span>&#46;</span>lu</a>.</p>
-</div>
-<div class="section" id="how-you-accept-this-policy">
-<h2>How you accept this policy<a class="headerlink" href="#how-you-accept-this-policy" title="Permalink to this headline">¶</a></h2>
-<p>By using our Services or visiting our sites, you agree to the use, disclosure,
-and procedures outlined in this Privacy Policy.</p>
-</div>
-<div class="section" id="what-personal-information-do-we-collect-from-our-users">
-<h2>What personal information do we collect from our users?<a class="headerlink" href="#what-personal-information-do-we-collect-from-our-users" title="Permalink to this headline">¶</a></h2>
-<p>The information we collect from you falls into two categories: (i) personally
-identifiable information (i.e., data that could potentially identify you as an
-individual) (“Personal Informationâ€), and (ii) non-personally identifiable
-information (i.e., information that cannot be used to identify who you are)
-(“Non-Personal Informationâ€). This Privacy Policy covers both categories and
-will tell you how we might collect and use each type.</p>
-<p>We do our best to not collect any Personal Information from Anastasis
-users. The detailed Personal Information Anastasis asks from you during
-the regular backup and recovery process at the beginning is never shared
-with us and only used to create a cryptographic account identifier which
-does not allow us to recover any of your details.</p>
-<p>That being said, when using our Services to recover key material, we may
-inherently receive the following information (depending on your choice of
-authentication method):</p>
-<blockquote>
-<div><ul class="simple">
-<li><p>Bank account details necessary when receiving funds from you to authenticate via a SEPA transfer. We will store these as part of our business records for accounting, and our bank will also be legally obliged to store the details for many years.</p></li>
-<li><p>Your phone number when using SMS authentication. We rely on third party providers (such as your mobile network operator) to deliver the SMS to you. These third parties will see the SMS message sent to you and could thus learn that you are using Anastasis. SMS is inherently insecure, and you should expect many governments and private parties to be able to observe these messages. However, we do not store your SMS number on our systems, except maybe in short-term logs to diagnose errors.</p></li>
-<li><p>Your e-mail address when using E-mail authentication. We rely on the Internet and your E-mail provider to deliver the E-mail to you. Internet service providers will see the E-mail message sent to you and could thus learn that you are using Anastasis. E-mail is inherently insecure, and you should expect many governments and private parties to be able to observe these messages. However, we do not store your E-mail address on our systems, except maybe in short-term logs to diagnose errors.</p></li>
-<li><p>Your physical address when using postal mail authentication. We rely on external providers for printing and sending the letter to you. These providers will need to learn your address and could learn that you are using Anastasis. Physical mail has strict privacy protections by law, but governments are known to break postal secrecy. We do not store your physical address on our systems, except maybe in short-term logs to diagnose errors.</p></li>
-<li><p>When you contact us. We may collect certain information if you choose to contact us, for example to report a bug or other error with the Taler Wallet. This may include contact information such as your name, email address or phone number depending on the method you choose to contact us.</p></li>
-</ul>
-</div></blockquote>
-</div>
-<div class="section" id="how-we-collect-and-process-information">
-<h2>How we collect and process information<a class="headerlink" href="#how-we-collect-and-process-information" title="Permalink to this headline">¶</a></h2>
-<p>We may process your information for the following reasons:</p>
-<blockquote>
-<div><ul class="simple">
-<li><p>to authenticate you during secret recovery</p></li>
-<li><p>to support you using Anastasis when you contact us</p></li>
-</ul>
-</div></blockquote>
-</div>
-<div class="section" id="how-we-share-and-use-the-information-we-gather">
-<h2>How we share and use the information we gather<a class="headerlink" href="#how-we-share-and-use-the-information-we-gather" title="Permalink to this headline">¶</a></h2>
-<p>We may share your authentication data with other providers that assist
-us in performing the authentication. We will try to use providers that
-to the best of our knowledge respect your privacy and have good
-privacy practices. We reserve the right to change authentication
-providers at any time to ensure availability of our services.</p>
-<p>We primarily use the limited information we receive directly from you to
-enhance Anastasis. Some ways we may use your Personal Information are
-to: Contact you when necessary to respond to your comments, answer your
-questions, or obtain additional information on issues related to bugs or
-errors with the Anastasis application that you reported.</p>
-</div>
-<div class="section" id="agents-or-third-party-partners">
-<h2>Agents or third party partners<a class="headerlink" href="#agents-or-third-party-partners" title="Permalink to this headline">¶</a></h2>
-<p>We may provide your Personal Information to our employees, contractors,
-agents, service providers, and designees (“Agentsâ€) to enable them to perform
-certain services for us exclusively, including: improvement and maintenance of
-our software and Services. By accepting this Privacy Policy, as outlined
-above, you consent to any such transfer.</p>
-</div>
-<div class="section" id="protection-of-us-and-others">
-<h2>Protection of us and others<a class="headerlink" href="#protection-of-us-and-others" title="Permalink to this headline">¶</a></h2>
-<p>We reserve the right to access, read, preserve, and disclose any information
-that we reasonably believe is necessary to comply with the law or a court
-order.</p>
-</div>
-<div class="section" id="what-personal-information-can-i-access-or-change">
-<h2>What personal information can I access or change?<a class="headerlink" href="#what-personal-information-can-i-access-or-change" title="Permalink to this headline">¶</a></h2>
-<p>You can request access to the information we have collected from
-you. You can do this by contacting us at <a class="reference external" href="mailto:privacy&#37;&#52;&#48;anastasis&#46;lu">privacy<span>&#64;</span>anastasis<span>&#46;</span>lu</a>. We will
-make sure to provide you with a copy of the data we process about
-you. To comply with your request, we may ask you to verify your
-identity. We will fulfill your request by sending your copy
-electronically. For any subsequent access request, we may charge you
-with an administrative fee. If you believe that the information we
-have collected is incorrect, you are welcome to contact us so we can
-update it and keep your data accurate. Any data that is no longer
-needed for purposes specified in the “How We Use the Information We
-Gather†section will be deleted after ninety (90) days.</p>
-</div>
-<div class="section" id="data-retention">
-<h2>Data retention<a class="headerlink" href="#data-retention" title="Permalink to this headline">¶</a></h2>
-<p>Information entered into our bug tracker will be retained indefinitely
-and is typically made public. We will only use it to triage the
-problem. Beyond that, we do not retain personally identifiable
-information about our users for longer than one week.</p>
-</div>
-<div class="section" id="data-security">
-<h2>Data security<a class="headerlink" href="#data-security" title="Permalink to this headline">¶</a></h2>
-<p>We are committed to making sure your information is protected. We employ
-several physical and electronic safeguards to keep your information safe,
-including encrypted user passwords, two factor verification and authentication
-on passwords where possible, and securing connections with industry standard
-transport layer security. You are also welcome to contact us using GnuPG
-encrypted e-mail. Even with all these precautions, we cannot fully guarantee
-against the access, disclosure, alteration, or deletion of data through
-events, including but not limited to hardware or software failure or
-unauthorized use. Any information that you provide to us is done so entirely
-at your own risk.</p>
-</div>
-<div class="section" id="changes-and-updates-to-privacy-policy">
-<h2>Changes and updates to privacy policy<a class="headerlink" href="#changes-and-updates-to-privacy-policy" title="Permalink to this headline">¶</a></h2>
-<p>We reserve the right to update and revise this privacy policy at any time. We
-occasionally review this Privacy Policy to make sure it complies with
-applicable laws and conforms to changes in our business. We may need to update
-this Privacy Policy, and we reserve the right to do so at any time. If we do
-revise this Privacy Policy, we will update the “Effective Date†at the top
-of this page so that you can tell if it has changed since your last visit. As
-we generally do not collect contact information and also do not track your
-visits, we will not be able to notify you directly. However, Anastasis clients
-may inform you about a change in the privacy policy once they detect that the
-policy has changed. Please review this Privacy Policy regularly to ensure that
-you are aware of its terms. Any use of our Services after an amendment to our
-Privacy Policy constitutes your acceptance to the revised or amended
-agreement.</p>
-</div>
-<div class="section" id="international-users-and-visitors">
-<h2>International users and visitors<a class="headerlink" href="#international-users-and-visitors" title="Permalink to this headline">¶</a></h2>
-<p>Our Services are (currently) hosted in Germany. If you are a user
-accessing the Services from the Switzerland, Asia, US, or any other
-region with laws or regulations governing personal data collection,
-use, and disclosure that differ from the laws of Germany, please be
-advised that through your continued use of the Services, which is
-governed by the law of the country hosting the service, you are
-transferring your Personal Information to Germany and you consent to
-that transfer.</p>
-</div>
-<div class="section" id="questions">
-<h2>Questions<a class="headerlink" href="#questions" title="Permalink to this headline">¶</a></h2>
-<p>Please contact us at <a class="reference external" href="mailto:privacy&#37;&#52;&#48;anastasis&#46;lu">privacy<span>&#64;</span>anastasis<span>&#46;</span>lu</a> if you have questions about our
-privacy practices that are not addressed in this Privacy Statement.</p>
-</div>
-</div>
-
-
- <div class="clearer"></div>
- </div>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- </body>
-</html> \ No newline at end of file
diff --git a/contrib/pp/en/0.pdf b/contrib/pp/en/0.pdf
deleted file mode 100644
index 805f725..0000000
--- a/contrib/pp/en/0.pdf
+++ /dev/null
Binary files differ
diff --git a/contrib/pp/en/0.txt b/contrib/pp/en/0.txt
deleted file mode 100644
index 72906ca..0000000
--- a/contrib/pp/en/0.txt
+++ /dev/null
@@ -1,219 +0,0 @@
-Privacy Policy
-**************
-
-Last Updated: 07.09.2021
-
-This Privacy Policy describes the policies and procedures of Anastasis
-SARL (“we,†“our,†or “usâ€) pertaining to the collection, use, and
-disclosure of your information on our sites and related mobile
-applications and products we offer (the “Servicesâ€). This Privacy
-Statement applies to your personal data when you use our Services, and
-does not apply to online websites or services that we do not own or
-control.
-
-
-Overview
-========
-
-Your privacy is important to us. We follow a few fundamental
-principles: We don’t ask you for personally identifiable information
-(defined below). That being said, your contact information, such as
-your phone number, social media handle, or email address (depending on
-how you contact us), may be collected when you communicate with us,
-for example to report a bug or other error related to Anastasis. We
-don’t share your information with third parties except when strictly
-required to deliver you our Services and products, or to comply with
-the law. If you have any questions or concerns about this policy,
-please reach out to us at privacy@anastasis.lu.
-
-
-How you accept this policy
-==========================
-
-By using our Services or visiting our sites, you agree to the use,
-disclosure, and procedures outlined in this Privacy Policy.
-
-
-What personal information do we collect from our users?
-=======================================================
-
-The information we collect from you falls into two categories: (i)
-personally identifiable information (i.e., data that could potentially
-identify you as an individual) (“Personal Informationâ€), and (ii) non-
-personally identifiable information (i.e., information that cannot be
-used to identify who you are) (“Non-Personal Informationâ€). This
-Privacy Policy covers both categories and will tell you how we might
-collect and use each type.
-
-We do our best to not collect any Personal Information from Anastasis
-users. The detailed Personal Information Anastasis asks from you
-during the regular backup and recovery process at the beginning is
-never shared with us and only used to create a cryptographic account
-identifier which does not allow us to recover any of your details.
-
-That being said, when using our Services to recover key material, we
-may inherently receive the following information (depending on your
-choice of authentication method):
-
- * Bank account details necessary when receiving funds from you to
- authenticate via a SEPA transfer. We will store these as part of
- our business records for accounting, and our bank will also be
- legally obliged to store the details for many years.
-
- * Your phone number when using SMS authentication. We rely on third
- party providers (such as your mobile network operator) to deliver
- the SMS to you. These third parties will see the SMS message sent
- to you and could thus learn that you are using Anastasis. SMS is
- inherently insecure, and you should expect many governments and
- private parties to be able to observe these messages. However,
- we do not store your SMS number on our systems, except maybe in
- short-term logs to diagnose errors.
-
- * Your e-mail address when using E-mail authentication. We rely on
- the Internet and your E-mail provider to deliver the E-mail to
- you. Internet service providers will see the E-mail message sent
- to you and could thus learn that you are using Anastasis. E-mail
- is inherently insecure, and you should expect many governments
- and private parties to be able to observe these messages.
- However, we do not store your E-mail address on our systems,
- except maybe in short-term logs to diagnose errors.
-
- * Your physical address when using postal mail authentication. We
- rely on external providers for printing and sending the letter to
- you. These providers will need to learn your address and could
- learn that you are using Anastasis. Physical mail has strict
- privacy protections by law, but governments are known to break
- postal secrecy. We do not store your physical address on our
- systems, except maybe in short-term logs to diagnose errors.
-
- * When you contact us. We may collect certain information if you
- choose to contact us, for example to report a bug or other error
- with the Taler Wallet. This may include contact information such
- as your name, email address or phone number depending on the
- method you choose to contact us.
-
-
-How we collect and process information
-======================================
-
-We may process your information for the following reasons:
-
- * to authenticate you during secret recovery
-
- * to support you using Anastasis when you contact us
-
-
-How we share and use the information we gather
-==============================================
-
-We may share your authentication data with other providers that assist
-us in performing the authentication. We will try to use providers that
-to the best of our knowledge respect your privacy and have good
-privacy practices. We reserve the right to change authentication
-providers at any time to ensure availability of our services.
-
-We primarily use the limited information we receive directly from you
-to enhance Anastasis. Some ways we may use your Personal Information
-are to: Contact you when necessary to respond to your comments, answer
-your questions, or obtain additional information on issues related to
-bugs or errors with the Anastasis application that you reported.
-
-
-Agents or third party partners
-==============================
-
-We may provide your Personal Information to our employees,
-contractors, agents, service providers, and designees (“Agentsâ€) to
-enable them to perform certain services for us exclusively, including:
-improvement and maintenance of our software and Services. By accepting
-this Privacy Policy, as outlined above, you consent to any such
-transfer.
-
-
-Protection of us and others
-===========================
-
-We reserve the right to access, read, preserve, and disclose any
-information that we reasonably believe is necessary to comply with the
-law or a court order.
-
-
-What personal information can I access or change?
-=================================================
-
-You can request access to the information we have collected from you.
-You can do this by contacting us at privacy@anastasis.lu. We will make
-sure to provide you with a copy of the data we process about you. To
-comply with your request, we may ask you to verify your identity. We
-will fulfill your request by sending your copy electronically. For any
-subsequent access request, we may charge you with an administrative
-fee. If you believe that the information we have collected is
-incorrect, you are welcome to contact us so we can update it and keep
-your data accurate. Any data that is no longer needed for purposes
-specified in the “How We Use the Information We Gather†section will
-be deleted after ninety (90) days.
-
-
-Data retention
-==============
-
-Information entered into our bug tracker will be retained indefinitely
-and is typically made public. We will only use it to triage the
-problem. Beyond that, we do not retain personally identifiable
-information about our users for longer than one week.
-
-
-Data security
-=============
-
-We are committed to making sure your information is protected. We
-employ several physical and electronic safeguards to keep your
-information safe, including encrypted user passwords, two factor
-verification and authentication on passwords where possible, and
-securing connections with industry standard transport layer security.
-You are also welcome to contact us using GnuPG encrypted e-mail. Even
-with all these precautions, we cannot fully guarantee against the
-access, disclosure, alteration, or deletion of data through events,
-including but not limited to hardware or software failure or
-unauthorized use. Any information that you provide to us is done so
-entirely at your own risk.
-
-
-Changes and updates to privacy policy
-=====================================
-
-We reserve the right to update and revise this privacy policy at any
-time. We occasionally review this Privacy Policy to make sure it
-complies with applicable laws and conforms to changes in our business.
-We may need to update this Privacy Policy, and we reserve the right to
-do so at any time. If we do revise this Privacy Policy, we will update
-the “Effective Date†at the top of this page so that you can tell if
-it has changed since your last visit. As we generally do not collect
-contact information and also do not track your visits, we will not be
-able to notify you directly. However, Anastasis clients may inform you
-about a change in the privacy policy once they detect that the policy
-has changed. Please review this Privacy Policy regularly to ensure
-that you are aware of its terms. Any use of our Services after an
-amendment to our Privacy Policy constitutes your acceptance to the
-revised or amended agreement.
-
-
-International users and visitors
-================================
-
-Our Services are (currently) hosted in Germany. If you are a user
-accessing the Services from the Switzerland, Asia, US, or any other
-region with laws or regulations governing personal data collection,
-use, and disclosure that differ from the laws of Germany, please be
-advised that through your continued use of the Services, which is
-governed by the law of the country hosting the service, you are
-transferring your Personal Information to Germany and you consent to
-that transfer.
-
-
-Questions
-=========
-
-Please contact us at privacy@anastasis.lu if you have questions about
-our privacy practices that are not addressed in this Privacy
-Statement.
diff --git a/contrib/pp/en/0.xml b/contrib/pp/en/0.xml
deleted file mode 100644
index b972e30..0000000
--- a/contrib/pp/en/0.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE document PUBLIC "+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" "http://docutils.sourceforge.net/docs/ref/docutils.dtd">
-<!-- Generated by Docutils 0.16 -->
-<document source="/research/anastasis/anastasis/contrib/pp/pp.rst">
- <section ids="privacy-policy" names="privacy\ policy">
- <title>Privacy Policy</title>
- <paragraph>Last Updated: 07.09.2021</paragraph>
- <paragraph>This Privacy Policy describes the policies and procedures of Anastasis
- SARL (“we,†“our,†or “usâ€) pertaining to the collection, use, and
- disclosure of your information on our sites and related mobile
- applications and products we offer (the “Servicesâ€). This Privacy
- Statement applies to your personal data when you use our Services, and
- does not apply to online websites or services that we do not own or
- control.</paragraph>
- <section ids="overview" names="overview">
- <title>Overview</title>
- <paragraph>Your privacy is important to us. We follow a few fundamental
- principles: We don’t ask you for personally identifiable information
- (defined below). That being said, your contact information, such as
- your phone number, social media handle, or email address (depending on
- how you contact us), may be collected when you communicate with us,
- for example to report a bug or other error related to Anastasis. We
- don’t share your information with third parties except when strictly
- required to deliver you our Services and products, or to comply with
- the law. If you have any questions or concerns about this policy,
- please reach out to us at <reference refuri="mailto:privacy@anastasis.lu">privacy@anastasis.lu</reference>.</paragraph>
- </section>
- <section ids="how-you-accept-this-policy" names="how\ you\ accept\ this\ policy">
- <title>How you accept this policy</title>
- <paragraph>By using our Services or visiting our sites, you agree to the use, disclosure,
- and procedures outlined in this Privacy Policy.</paragraph>
- </section>
- <section ids="what-personal-information-do-we-collect-from-our-users" names="what\ personal\ information\ do\ we\ collect\ from\ our\ users?">
- <title>What personal information do we collect from our users?</title>
- <paragraph>The information we collect from you falls into two categories: (i) personally
- identifiable information (i.e., data that could potentially identify you as an
- individual) (“Personal Informationâ€), and (ii) non-personally identifiable
- information (i.e., information that cannot be used to identify who you are)
- (“Non-Personal Informationâ€). This Privacy Policy covers both categories and
- will tell you how we might collect and use each type.</paragraph>
- <paragraph>We do our best to not collect any Personal Information from Anastasis
- users. The detailed Personal Information Anastasis asks from you during
- the regular backup and recovery process at the beginning is never shared
- with us and only used to create a cryptographic account identifier which
- does not allow us to recover any of your details.</paragraph>
- <paragraph>That being said, when using our Services to recover key material, we may
- inherently receive the following information (depending on your choice of
- authentication method):</paragraph>
- <block_quote>
- <bullet_list bullet="*">
- <list_item>
- <paragraph>Bank account details necessary when receiving funds from you to authenticate via a SEPA transfer. We will store these as part of our business records for accounting, and our bank will also be legally obliged to store the details for many years.</paragraph>
- </list_item>
- <list_item>
- <paragraph>Your phone number when using SMS authentication. We rely on third party providers (such as your mobile network operator) to deliver the SMS to you. These third parties will see the SMS message sent to you and could thus learn that you are using Anastasis. SMS is inherently insecure, and you should expect many governments and private parties to be able to observe these messages. However, we do not store your SMS number on our systems, except maybe in short-term logs to diagnose errors.</paragraph>
- </list_item>
- <list_item>
- <paragraph>Your e-mail address when using E-mail authentication. We rely on the Internet and your E-mail provider to deliver the E-mail to you. Internet service providers will see the E-mail message sent to you and could thus learn that you are using Anastasis. E-mail is inherently insecure, and you should expect many governments and private parties to be able to observe these messages. However, we do not store your E-mail address on our systems, except maybe in short-term logs to diagnose errors.</paragraph>
- </list_item>
- <list_item>
- <paragraph>Your physical address when using postal mail authentication. We rely on external providers for printing and sending the letter to you. These providers will need to learn your address and could learn that you are using Anastasis. Physical mail has strict privacy protections by law, but governments are known to break postal secrecy. We do not store your physical address on our systems, except maybe in short-term logs to diagnose errors.</paragraph>
- </list_item>
- <list_item>
- <paragraph>When you contact us. We may collect certain information if you choose to contact us, for example to report a bug or other error with the Taler Wallet. This may include contact information such as your name, email address or phone number depending on the method you choose to contact us.</paragraph>
- </list_item>
- </bullet_list>
- </block_quote>
- </section>
- <section ids="how-we-collect-and-process-information" names="how\ we\ collect\ and\ process\ information">
- <title>How we collect and process information</title>
- <paragraph>We may process your information for the following reasons:</paragraph>
- <block_quote>
- <bullet_list bullet="*">
- <list_item>
- <paragraph>to authenticate you during secret recovery</paragraph>
- </list_item>
- <list_item>
- <paragraph>to support you using Anastasis when you contact us</paragraph>
- </list_item>
- </bullet_list>
- </block_quote>
- </section>
- <section ids="how-we-share-and-use-the-information-we-gather" names="how\ we\ share\ and\ use\ the\ information\ we\ gather">
- <title>How we share and use the information we gather</title>
- <paragraph>We may share your authentication data with other providers that assist
- us in performing the authentication. We will try to use providers that
- to the best of our knowledge respect your privacy and have good
- privacy practices. We reserve the right to change authentication
- providers at any time to ensure availability of our services.</paragraph>
- <paragraph>We primarily use the limited information we receive directly from you to
- enhance Anastasis. Some ways we may use your Personal Information are
- to: Contact you when necessary to respond to your comments, answer your
- questions, or obtain additional information on issues related to bugs or
- errors with the Anastasis application that you reported.</paragraph>
- </section>
- <section ids="agents-or-third-party-partners" names="agents\ or\ third\ party\ partners">
- <title>Agents or third party partners</title>
- <paragraph>We may provide your Personal Information to our employees, contractors,
- agents, service providers, and designees (“Agentsâ€) to enable them to perform
- certain services for us exclusively, including: improvement and maintenance of
- our software and Services. By accepting this Privacy Policy, as outlined
- above, you consent to any such transfer.</paragraph>
- </section>
- <section ids="protection-of-us-and-others" names="protection\ of\ us\ and\ others">
- <title>Protection of us and others</title>
- <paragraph>We reserve the right to access, read, preserve, and disclose any information
- that we reasonably believe is necessary to comply with the law or a court
- order.</paragraph>
- </section>
- <section ids="what-personal-information-can-i-access-or-change" names="what\ personal\ information\ can\ i\ access\ or\ change?">
- <title>What personal information can I access or change?</title>
- <paragraph>You can request access to the information we have collected from
- you. You can do this by contacting us at <reference refuri="mailto:privacy@anastasis.lu">privacy@anastasis.lu</reference>. We will
- make sure to provide you with a copy of the data we process about
- you. To comply with your request, we may ask you to verify your
- identity. We will fulfill your request by sending your copy
- electronically. For any subsequent access request, we may charge you
- with an administrative fee. If you believe that the information we
- have collected is incorrect, you are welcome to contact us so we can
- update it and keep your data accurate. Any data that is no longer
- needed for purposes specified in the “How We Use the Information We
- Gather†section will be deleted after ninety (90) days.</paragraph>
- </section>
- <section ids="data-retention" names="data\ retention">
- <title>Data retention</title>
- <paragraph>Information entered into our bug tracker will be retained indefinitely
- and is typically made public. We will only use it to triage the
- problem. Beyond that, we do not retain personally identifiable
- information about our users for longer than one week.</paragraph>
- </section>
- <section ids="data-security" names="data\ security">
- <title>Data security</title>
- <paragraph>We are committed to making sure your information is protected. We employ
- several physical and electronic safeguards to keep your information safe,
- including encrypted user passwords, two factor verification and authentication
- on passwords where possible, and securing connections with industry standard
- transport layer security. You are also welcome to contact us using GnuPG
- encrypted e-mail. Even with all these precautions, we cannot fully guarantee
- against the access, disclosure, alteration, or deletion of data through
- events, including but not limited to hardware or software failure or
- unauthorized use. Any information that you provide to us is done so entirely
- at your own risk.</paragraph>
- </section>
- <section ids="changes-and-updates-to-privacy-policy" names="changes\ and\ updates\ to\ privacy\ policy">
- <title>Changes and updates to privacy policy</title>
- <paragraph>We reserve the right to update and revise this privacy policy at any time. We
- occasionally review this Privacy Policy to make sure it complies with
- applicable laws and conforms to changes in our business. We may need to update
- this Privacy Policy, and we reserve the right to do so at any time. If we do
- revise this Privacy Policy, we will update the “Effective Date†at the top
- of this page so that you can tell if it has changed since your last visit. As
- we generally do not collect contact information and also do not track your
- visits, we will not be able to notify you directly. However, Anastasis clients
- may inform you about a change in the privacy policy once they detect that the
- policy has changed. Please review this Privacy Policy regularly to ensure that
- you are aware of its terms. Any use of our Services after an amendment to our
- Privacy Policy constitutes your acceptance to the revised or amended
- agreement.</paragraph>
- </section>
- <section ids="international-users-and-visitors" names="international\ users\ and\ visitors">
- <title>International users and visitors</title>
- <paragraph>Our Services are (currently) hosted in Germany. If you are a user
- accessing the Services from the Switzerland, Asia, US, or any other
- region with laws or regulations governing personal data collection,
- use, and disclosure that differ from the laws of Germany, please be
- advised that through your continued use of the Services, which is
- governed by the law of the country hosting the service, you are
- transferring your Personal Information to Germany and you consent to
- that transfer.</paragraph>
- </section>
- <section ids="questions" names="questions">
- <title>Questions</title>
- <paragraph>Please contact us at <reference refuri="mailto:privacy@anastasis.lu">privacy@anastasis.lu</reference> if you have questions about our
- privacy practices that are not addressed in this Privacy Statement.</paragraph>
- </section>
- </section>
-</document>
diff --git a/contrib/pp/locale/de/LC_MESSAGES/pp.po b/contrib/pp/locale/de/LC_MESSAGES/pp.po
deleted file mode 100644
index f53add7..0000000
--- a/contrib/pp/locale/de/LC_MESSAGES/pp.po
+++ /dev/null
@@ -1,511 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) 2014-2020 Taler Systems SA (GPLv3+ or GFDL 1.3+)
-# This file is distributed under the same license as the pp package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2020.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: pp 0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-09-07 21:42+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.9.1\n"
-
-#: ../../pp.rst:2
-msgid "Privacy Policy"
-msgstr ""
-
-#: ../../pp.rst:4
-msgid "Last Updated: 07.09.2021"
-msgstr ""
-
-#: ../../pp.rst:6
-msgid ""
-"This Privacy Policy describes the policies and procedures of Anastasis "
-"SARL (“we,†“our,†or “usâ€) pertaining to the collection, use, and "
-"disclosure of your information on our sites and related mobile "
-"applications and products we offer (the “Servicesâ€). This Privacy "
-"Statement applies to your personal data when you use our Services, and "
-"does not apply to online websites or services that we do not own or "
-"control."
-msgstr ""
-
-#: ../../pp.rst:16
-msgid "Overview"
-msgstr ""
-
-#: ../../pp.rst:18
-msgid ""
-"Your privacy is important to us. We follow a few fundamental principles: "
-"We don’t ask you for personally identifiable information (defined below)."
-" That being said, your contact information, such as your phone number, "
-"social media handle, or email address (depending on how you contact us), "
-"may be collected when you communicate with us, for example to report a "
-"bug or other error related to Anastasis. We don’t share your information "
-"with third parties except when strictly required to deliver you our "
-"Services and products, or to comply with the law. If you have any "
-"questions or concerns about this policy, please reach out to us at "
-"privacy@anastasis.lu."
-msgstr ""
-
-#: ../../pp.rst:31
-msgid "How you accept this policy"
-msgstr ""
-
-#: ../../pp.rst:33
-msgid ""
-"By using our Services or visiting our sites, you agree to the use, "
-"disclosure, and procedures outlined in this Privacy Policy."
-msgstr ""
-
-#: ../../pp.rst:38
-msgid "What personal information do we collect from our users?"
-msgstr ""
-
-#: ../../pp.rst:40
-msgid ""
-"The information we collect from you falls into two categories: (i) "
-"personally identifiable information (i.e., data that could potentially "
-"identify you as an individual) (“Personal Informationâ€), and (ii) non-"
-"personally identifiable information (i.e., information that cannot be "
-"used to identify who you are) (“Non-Personal Informationâ€). This Privacy "
-"Policy covers both categories and will tell you how we might collect and "
-"use each type."
-msgstr ""
-
-#: ../../pp.rst:47
-msgid ""
-"We do our best to not collect any Personal Information from Anastasis "
-"users. The detailed Personal Information Anastasis asks from you during "
-"the regular backup and recovery process at the beginning is never shared "
-"with us and only used to create a cryptographic account identifier which "
-"does not allow us to recover any of your details."
-msgstr ""
-
-#: ../../pp.rst:53
-msgid ""
-"That being said, when using our Services to recover key material, we may "
-"inherently receive the following information (depending on your choice of"
-" authentication method):"
-msgstr ""
-
-#: ../../pp.rst:57
-msgid ""
-"Bank account details necessary when receiving funds from you to "
-"authenticate via a SEPA transfer. We will store these as part of our "
-"business records for accounting, and our bank will also be legally "
-"obliged to store the details for many years."
-msgstr ""
-
-#: ../../pp.rst:59
-msgid ""
-"Your phone number when using SMS authentication. We rely on third party "
-"providers (such as your mobile network operator) to deliver the SMS to "
-"you. These third parties will see the SMS message sent to you and could "
-"thus learn that you are using Anastasis. SMS is inherently insecure, and "
-"you should expect many governments and private parties to be able to "
-"observe these messages. However, we do not store your SMS number on our "
-"systems, except maybe in short-term logs to diagnose errors."
-msgstr ""
-
-#: ../../pp.rst:61
-msgid ""
-"Your e-mail address when using E-mail authentication. We rely on the "
-"Internet and your E-mail provider to deliver the E-mail to you. Internet "
-"service providers will see the E-mail message sent to you and could thus "
-"learn that you are using Anastasis. E-mail is inherently insecure, and "
-"you should expect many governments and private parties to be able to "
-"observe these messages. However, we do not store your E-mail address on "
-"our systems, except maybe in short-term logs to diagnose errors."
-msgstr ""
-
-#: ../../pp.rst:63
-msgid ""
-"Your physical address when using postal mail authentication. We rely on "
-"external providers for printing and sending the letter to you. These "
-"providers will need to learn your address and could learn that you are "
-"using Anastasis. Physical mail has strict privacy protections by law, but"
-" governments are known to break postal secrecy. We do not store your "
-"physical address on our systems, except maybe in short-term logs to "
-"diagnose errors."
-msgstr ""
-
-#: ../../pp.rst:65
-msgid ""
-"When you contact us. We may collect certain information if you choose to "
-"contact us, for example to report a bug or other error with the Taler "
-"Wallet. This may include contact information such as your name, email "
-"address or phone number depending on the method you choose to contact us."
-msgstr ""
-
-#: ../../pp.rst:69
-msgid "How we collect and process information"
-msgstr ""
-
-#: ../../pp.rst:71
-msgid "We may process your information for the following reasons:"
-msgstr ""
-
-#: ../../pp.rst:73
-msgid "to authenticate you during secret recovery"
-msgstr ""
-
-#: ../../pp.rst:74
-msgid "to support you using Anastasis when you contact us"
-msgstr ""
-
-#: ../../pp.rst:78
-msgid "How we share and use the information we gather"
-msgstr ""
-
-#: ../../pp.rst:80
-msgid ""
-"We may share your authentication data with other providers that assist us"
-" in performing the authentication. We will try to use providers that to "
-"the best of our knowledge respect your privacy and have good privacy "
-"practices. We reserve the right to change authentication providers at "
-"any time to ensure availability of our services."
-msgstr ""
-
-#: ../../pp.rst:86
-msgid ""
-"We primarily use the limited information we receive directly from you to "
-"enhance Anastasis. Some ways we may use your Personal Information are to:"
-" Contact you when necessary to respond to your comments, answer your "
-"questions, or obtain additional information on issues related to bugs or "
-"errors with the Anastasis application that you reported."
-msgstr ""
-
-#: ../../pp.rst:94
-msgid "Agents or third party partners"
-msgstr ""
-
-#: ../../pp.rst:96
-msgid ""
-"We may provide your Personal Information to our employees, contractors, "
-"agents, service providers, and designees (“Agentsâ€) to enable them to "
-"perform certain services for us exclusively, including: improvement and "
-"maintenance of our software and Services. By accepting this Privacy "
-"Policy, as outlined above, you consent to any such transfer."
-msgstr ""
-
-#: ../../pp.rst:104
-msgid "Protection of us and others"
-msgstr ""
-
-#: ../../pp.rst:106
-msgid ""
-"We reserve the right to access, read, preserve, and disclose any "
-"information that we reasonably believe is necessary to comply with the "
-"law or a court order."
-msgstr ""
-
-#: ../../pp.rst:112
-msgid "What personal information can I access or change?"
-msgstr ""
-
-#: ../../pp.rst:114
-msgid ""
-"You can request access to the information we have collected from you. You"
-" can do this by contacting us at privacy@anastasis.lu. We will make sure "
-"to provide you with a copy of the data we process about you. To comply "
-"with your request, we may ask you to verify your identity. We will "
-"fulfill your request by sending your copy electronically. For any "
-"subsequent access request, we may charge you with an administrative fee. "
-"If you believe that the information we have collected is incorrect, you "
-"are welcome to contact us so we can update it and keep your data "
-"accurate. Any data that is no longer needed for purposes specified in the"
-" “How We Use the Information We Gather†section will be deleted after "
-"ninety (90) days."
-msgstr ""
-
-#: ../../pp.rst:128
-msgid "Data retention"
-msgstr ""
-
-#: ../../pp.rst:130
-msgid ""
-"Information entered into our bug tracker will be retained indefinitely "
-"and is typically made public. We will only use it to triage the problem."
-" Beyond that, we do not retain personally identifiable information about"
-" our users for longer than one week."
-msgstr ""
-
-#: ../../pp.rst:137
-msgid "Data security"
-msgstr ""
-
-#: ../../pp.rst:139
-msgid ""
-"We are committed to making sure your information is protected. We employ "
-"several physical and electronic safeguards to keep your information safe,"
-" including encrypted user passwords, two factor verification and "
-"authentication on passwords where possible, and securing connections with"
-" industry standard transport layer security. You are also welcome to "
-"contact us using GnuPG encrypted e-mail. Even with all these precautions,"
-" we cannot fully guarantee against the access, disclosure, alteration, or"
-" deletion of data through events, including but not limited to hardware "
-"or software failure or unauthorized use. Any information that you provide"
-" to us is done so entirely at your own risk."
-msgstr ""
-
-#: ../../pp.rst:152
-msgid "Changes and updates to privacy policy"
-msgstr ""
-
-#: ../../pp.rst:154
-msgid ""
-"We reserve the right to update and revise this privacy policy at any "
-"time. We occasionally review this Privacy Policy to make sure it complies"
-" with applicable laws and conforms to changes in our business. We may "
-"need to update this Privacy Policy, and we reserve the right to do so at "
-"any time. If we do revise this Privacy Policy, we will update the "
-"“Effective Date†at the top of this page so that you can tell if it has "
-"changed since your last visit. As we generally do not collect contact "
-"information and also do not track your visits, we will not be able to "
-"notify you directly. However, Anastasis clients may inform you about a "
-"change in the privacy policy once they detect that the policy has "
-"changed. Please review this Privacy Policy regularly to ensure that you "
-"are aware of its terms. Any use of our Services after an amendment to our"
-" Privacy Policy constitutes your acceptance to the revised or amended "
-"agreement."
-msgstr ""
-
-#: ../../pp.rst:170
-msgid "International users and visitors"
-msgstr ""
-
-#: ../../pp.rst:172
-msgid ""
-"Our Services are (currently) hosted in Germany. If you are a user "
-"accessing the Services from the Switzerland, Asia, US, or any other "
-"region with laws or regulations governing personal data collection, use, "
-"and disclosure that differ from the laws of Germany, please be advised "
-"that through your continued use of the Services, which is governed by the"
-" law of the country hosting the service, you are transferring your "
-"Personal Information to Germany and you consent to that transfer."
-msgstr ""
-
-#: ../../pp.rst:183
-msgid "Questions"
-msgstr ""
-
-#: ../../pp.rst:185
-msgid ""
-"Please contact us at privacy@anastasis.lu if you have questions about our"
-" privacy practices that are not addressed in this Privacy Statement."
-msgstr ""
-
-#~ msgid "Last Updated: 11.12.2019"
-#~ msgstr ""
-
-#~ msgid ""
-#~ "This Privacy Policy describes the "
-#~ "policies and procedures of Taler Systems"
-#~ " SA (“we,†“our,†or “usâ€) pertaining"
-#~ " to the collection, use, and "
-#~ "disclosure of your information on our"
-#~ " sites and related mobile applications "
-#~ "and products we offer (the “Servicesâ€"
-#~ " or “Taler Walletâ€). This Privacy "
-#~ "Statement applies to your personal data"
-#~ " when you use our Services, and "
-#~ "does not apply to online websites "
-#~ "or services that we do not own "
-#~ "or control."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "Your privacy is important to us. "
-#~ "We follow a few fundamental principles:"
-#~ " We don’t ask you for personally "
-#~ "identifiable information (defined below). That"
-#~ " being said, your contact information, "
-#~ "such as your phone number, social "
-#~ "media handle, or email address "
-#~ "(depending on how you contact us), "
-#~ "may be collected when you communicate"
-#~ " with us, for example to report "
-#~ "a bug or other error related to"
-#~ " the Taler Wallet. We don’t share "
-#~ "your information with third parties "
-#~ "except when strictly required to deliver"
-#~ " you our Services and products, or"
-#~ " to comply with the law. If you"
-#~ " have any questions or concerns about"
-#~ " this policy, please reach out to "
-#~ "us at privacy@taler-systems.net."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "We do our best to not collect "
-#~ "any Personal Information from Taler "
-#~ "Wallet users. We believe that the "
-#~ "Taler Wallet never transmits personal "
-#~ "information to our services without at"
-#~ " least clear implied consent, and we"
-#~ " only process and retain information "
-#~ "with a strict business need. That "
-#~ "being said, when using our Services, "
-#~ "we inherently have to collect the "
-#~ "following information:"
-#~ msgstr ""
-
-#~ msgid ""
-#~ "Bank account details necessary when "
-#~ "receiving funds from you to top-up"
-#~ " your wallet or to transfer funds "
-#~ "to you when you are being paid "
-#~ "via Taler. At the current experimental"
-#~ " stage, only the pseudonym and "
-#~ "password you entered in the bank "
-#~ "demonstrator is stored."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "The amounts being withdrawn or "
-#~ "deposited, with associated unique transaction"
-#~ " identifiers and cryptographic signatures "
-#~ "authorizing the transaction. Note that "
-#~ "for purchases, we cannot identify the"
-#~ " buyer from the collected data, so"
-#~ " when you spend money, we only "
-#~ "receive non-personal information."
-#~ msgstr ""
-
-#~ msgid "to transfer money as specified by our users (Taler transactions);"
-#~ msgstr ""
-
-#~ msgid ""
-#~ "to assist government entities in linking"
-#~ " income to the underlying contract"
-#~ msgstr ""
-
-#~ msgid "to support you using the Taler Wallet or to improve our Services"
-#~ msgstr ""
-
-#~ msgid ""
-#~ "We may share your Personal Data or"
-#~ " other information about you only if"
-#~ " you are a merchant receiving income,"
-#~ " with your bank, to the degree "
-#~ "necessary to execute the payment."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "We retain Personal Data to transfer "
-#~ "funds to the accounts designated by "
-#~ "our users. We may retain Personal "
-#~ "Data only for as long as mandated"
-#~ " by law and required for the "
-#~ "wire transfers."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "We primarily use the limited information"
-#~ " we receive directly from you to "
-#~ "enhance the Taler Wallet. Some ways "
-#~ "we may use your Personal Information "
-#~ "are to: Contact you when necessary "
-#~ "to respond to your comments, answer "
-#~ "your questions, or obtain additional "
-#~ "information on issues related to bugs"
-#~ " or errors with the Taler Wallet "
-#~ "that you reported."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "You can request access to the "
-#~ "information we have collected from you."
-#~ " You can do this by contacting "
-#~ "us at privacy@taler-systems.net. We will"
-#~ " make sure to provide you with "
-#~ "a copy of the data we process "
-#~ "about you. To comply with your "
-#~ "request, we may ask you to verify"
-#~ " your identity. We will fulfill your"
-#~ " request by sending your copy "
-#~ "electronically. For any subsequent access "
-#~ "request, we may charge you with an"
-#~ " administrative fee. If you believe "
-#~ "that the information we have collected"
-#~ " is incorrect, you are welcome to "
-#~ "contact us so we can update it "
-#~ "and keep your data accurate. Any "
-#~ "data that is no longer needed for"
-#~ " purposes specified in the “How We"
-#~ " Use the Information We Gather†"
-#~ "section will be deleted after ninety "
-#~ "(90) days."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "If you uninstall the Taler Wallet "
-#~ "mobile applications from your device, or"
-#~ " request that your information be "
-#~ "deleted, we still may retain some "
-#~ "information that you have provided to"
-#~ " us to maintain the Taler Wallet "
-#~ "or to comply with relevant laws."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "We reserve the right to update and"
-#~ " revise this privacy policy at any"
-#~ " time. We occasionally review this "
-#~ "Privacy Policy to make sure it "
-#~ "complies with applicable laws and "
-#~ "conforms to changes in our business. "
-#~ "We may need to update this Privacy"
-#~ " Policy, and we reserve the right "
-#~ "to do so at any time. If we"
-#~ " do revise this Privacy Policy, we"
-#~ " will update the “Effective Date†at"
-#~ " the bottom of this page so "
-#~ "that you can tell if it has "
-#~ "changed since your last visit. As "
-#~ "we generally do not collect contact "
-#~ "information and also do not track "
-#~ "your visits, we will not be able"
-#~ " to notify you directly. However, the"
-#~ " Taler Wallet may inform you about"
-#~ " a change in the privacy policy "
-#~ "once it detects that the policy "
-#~ "has changed. Please review this Privacy"
-#~ " Policy regularly to ensure that you"
-#~ " are aware of its terms. Any "
-#~ "use of our Services after an "
-#~ "amendment to our Privacy Policy "
-#~ "constitutes your acceptance to the "
-#~ "revised or amended agreement."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "Our Services are hosted in Switzerland."
-#~ " If you are a user accessing "
-#~ "the Services from the European Union,"
-#~ " Asia, US, or any other region "
-#~ "with laws or regulations governing "
-#~ "personal data collection, use, and "
-#~ "disclosure that differ from Swiss laws,"
-#~ " please be advised that through your"
-#~ " continued use of the Services, which"
-#~ " is governed by Swiss law, you "
-#~ "are transferring your Personal Information "
-#~ "to Switzerland and you consent to "
-#~ "that transfer."
-#~ msgstr ""
-
-#~ msgid ""
-#~ "Please contact us at privacy@taler-"
-#~ "systems.net if you have questions about"
-#~ " our privacy practices that are not"
-#~ " addressed in this Privacy Statement."
-#~ msgstr ""
-
diff --git a/contrib/provider-list.json b/contrib/provider-list.json
index 78b020d..ddce9be 100644
--- a/contrib/provider-list.json
+++ b/contrib/provider-list.json
@@ -3,28 +3,36 @@
"SPDX-License-Identifier": "GPL3.0-or-later",
"anastasis_provider": [
{
- "url" : "https://anastasis.demo.taler.net/",
- "currency" : "KUDOS"
+ "url" : "https://v1.anastasis.taler.net/",
+ "name" : "Bern University of Applied Sciences, Switzerland"
},
{
- "url" : "https://kudos.demo.anastasis.lu/",
- "currency" : "KUDOS"
+ "url" : "https://v1.anastasis.codeblau.de/",
+ "name" : "Codeblau GmbH, Germany"
},
- {
+ {
+ "url" : "https://v1.anastasis.lu/",
+ "name" : "Anastasis SARL, Luxembourg"
+ },
+ {
"url" : "http://localhost:8086/",
- "currency" : "TESTKUDOS"
- },
- {
+ "name" : "Data Loss Inc. #1",
+ "restricted" : "xx"
+ },
+ {
"url" : "http://localhost:8087/",
- "currency" : "TESTKUDOS"
- },
- {
+ "name" : "Data Loss Inc. #2",
+ "restricted" : "xx"
+ },
+ {
"url" : "http://localhost:8088/",
- "currency" : "TESTKUDOS"
- },
- {
+ "name" : "Data Loss Inc. #3",
+ "restricted" : "xx"
+ },
+ {
"url" : "http://localhost:8089/",
- "currency" : "TESTKUDOS"
- }
+ "name" : "Data Loss Inc. #4",
+ "restricted" : "xx"
+ }
]
}
diff --git a/contrib/redux.al.json b/contrib/redux.al.json
index bb4360e..2696540 100644
--- a/contrib/redux.al.json
+++ b/contrib/redux.al.json
@@ -19,11 +19,8 @@
{
"type": "string",
"name": "nid_number",
- "label": "Numri i Identitetit",
- "label_i18n":{
- "en": "Identity Number",
- "al": "Numri i Identitetit"
- },
+ "label": "Identity Number",
+ "tooltip": "Numri i Identitetit",
"widget": "anastasis_gtk_ia_nid_al",
"uuid": "256e5d30-d65e-481b-9ac4-55f5ac03b24a",
"validation-regex": "^[0-9A-T][0-9](((0|5)[0-9])|10|11|51|52)[0-9]{3}[A-W]$",
diff --git a/contrib/redux.be.json b/contrib/redux.be.json
index 821a3eb..80711cf 100644
--- a/contrib/redux.be.json
+++ b/contrib/redux.be.json
@@ -27,9 +27,6 @@
"type": "string",
"name": "nrn_number",
"label": "National Register Number",
- "label_i18n":{
- "en": "National Register Number"
- },
"widget": "anastasis_gtk_ia_nid_be",
"uuid": "0452f99a-06f7-48bd-8ac0-2e4ed9a24560",
"validation-regex": "^[0-9]{11}$",
diff --git a/contrib/redux.ch.json b/contrib/redux.ch.json
index 48e8e7a..6b99ca1 100644
--- a/contrib/redux.ch.json
+++ b/contrib/redux.ch.json
@@ -27,14 +27,12 @@
"type": "string",
"name": "ahv_number",
"label": "AHV number",
- "label_i18n":{
- "de_DE":"AHV-Nummer",
- "de_CH":"AHV-Nummer"
- },
+ "tooltip":"AHV-Nummer",
"widget": "anastasis_gtk_ia_ahv",
"uuid" : "1da87570-ba16-4f62-8a7e-cbda92f51591",
- "validation-regex": "^(756).[0-9]{4}.[0-9]{4}.[0-9]{2}|(756)[0-9]{10}$",
- "validation-logic": "CH_AHV_check"
+ "validation-regex": "^(756)\\.[0-9]{4}\\.[0-9]{4}\\.[0-9]{2}|(756)[0-9]{10}$",
+ "validation-logic": "CH_AHV_check",
+ "autocomplete": "???.????.????.??"
}
]
}
diff --git a/contrib/redux.countries.json b/contrib/redux.countries.json
index 8fb2e99..113cb01 100644
--- a/contrib/redux.countries.json
+++ b/contrib/redux.countries.json
@@ -3,175 +3,94 @@
"SPDX-License-Identifier": "GPL3.0-or-later",
"countries": [
{
- "code" : "al",
- "name" : "Albania",
- "continent" : "Europe",
- "name_i18n" : {
- "de_DE": "Albanien",
- "en_UK": "Albania"
- },
- "currency": "ALL",
- "call_code" : "+355"
+ "code" : "al",
+ "name" : "Albania",
+ "continent" : "Europe",
+ "call_code" : "+355"
},
{
- "code" : "be",
- "name" : "Belgium",
- "continent" : "Europe",
- "name_i18n" : {
- "de_DE": "Belgien",
- "en_UK": "Belgium"
- },
- "currency": "EUR",
- "call_code" : "+32"
+ "code" : "be",
+ "name" : "Belgium",
+ "continent" : "Europe",
+ "call_code" : "+32"
},
{
- "code" : "ch",
- "name" : "Switzerland",
- "continent" : "Europe",
- "name_i18n" : {
- "de_DE": "Schweiz",
- "de_CH": "Schwiiz",
- "fr_FR": "Suisse",
- "en_UK": "Swiss"
- },
- "currency": "CHF",
- "call_code" : "+41"
+ "code" : "ch",
+ "name" : "Switzerland",
+ "continent" : "Europe",
+ "call_code" : "+41"
},
{
- "code" : "cz",
- "name" : "Czech Republic",
- "continent" : "Europe",
- "name_i18n" : {
- "en_UK": "Czech Republic"
- },
- "currency": "CZK",
- "call_code" : "+420"
+ "code" : "cz",
+ "name" : "Czech Republic",
+ "continent" : "Europe",
+ "call_code" : "+420"
},
{
- "code" : "de",
- "name" : "Germany",
- "continent" : "Europe",
- "continent_i18n" : { "de_DE" : "Europa" },
- "name_i18n" : {
- "de_DE": "Deutschland",
- "de_CH": "Deutschland",
- "fr_FR": "Allemagne",
- "en_UK": "Germany"
- },
- "currency": "EUR",
- "call_code" : "+49"
+ "code" : "de",
+ "name" : "Germany",
+ "continent" : "Europe",
+ "call_code" : "+49"
},
{
- "code" : "dk",
- "name" : "Denmark",
- "continent" : "Europe",
- "continent_i18n" : { "de_DE" : "Europa" },
- "name_i18n" : {
- "en_UK": "Denmark"
- },
- "currency": "DKK",
- "call_code" : "+45"
+ "code" : "dk",
+ "name" : "Denmark",
+ "continent" : "Europe",
+ "call_code" : "+45"
},
{
- "code" : "es",
- "name" : "Spain",
- "continent" : "Europe",
- "continent_i18n" : { "es_ES" : "Europa" },
- "name_i18n" : {
- "es_ES": "España"
- },
- "currency": "EUR",
- "call_code" : "+44"
+ "code" : "es",
+ "name" : "Spain",
+ "continent" : "Europe",
+ "call_code" : "+44"
},
{
- "code" : "in",
- "name" : "India",
- "continent" : "India",
- "continent_i18n" : { "en_EN" : "India" },
- "name_i18n" : {
- "de_DE": "Indien",
- "de_CH": "Indien",
- "fr_FR": "l'Inde",
- "en_UK": "India"
- },
- "currency": "INR",
- "call_code" : "+91"
+ "code" : "fr",
+ "name" : "France",
+ "continent" : "Europe",
+ "call_code" : "+33"
},
{
- "code" : "it",
- "name" : "Italy",
- "continent" : "Europe",
- "name_i18n" : {
- "de_DE": "Italien",
- "en_UK": "Italy"
- },
- "currency": "EUR",
- "call_code" : "+39"
+ "code" : "in",
+ "name" : "India",
+ "continent" : "India",
+ "call_code" : "+91"
},
{
- "code" : "jp",
- "name" : "Japan",
- "continent" : "Asia",
- "continent_i18n" : { "en_EN" : "Japan" },
- "name_i18n" : {
- "de_DE": "Japan",
- "de_CH": "Japan",
- "en_UK": "Japan"
- },
- "currency": "JPY",
- "call_code" : "+81"
+ "code" : "it",
+ "name" : "Italy",
+ "continent" : "Europe",
+ "call_code" : "+39"
},
{
- "code" : "sl",
- "name" : "Slovakia",
- "continent" : "Europe",
- "name_i18n" : {
- "en_UK": "Slovakia"
- },
- "currency": "EUR",
- "call_code" : "+421"
+ "code" : "jp",
+ "name" : "Japan",
+ "continent" : "Asia",
+ "call_code" : "+81"
},
{
- "code" : "us",
- "name" : "United States of America (USA)",
- "continent" : "North America",
- "continent_i18n" : { "de_DE" : "Nordamerika" },
- "name_i18n" : {
- "de_DE": "Vereinigte Staaten von Amerika (USA)",
- "de_CH": "Vereinigte Staaten von Amerika (USA)",
- "fr_FR": "États-Unis d'Amérique (USA)",
- "en_UK": "United States of America (USA)"
- },
- "currency": "USD",
- "call_code" : "+1"
+ "code" : "nl",
+ "name" : "Netherlands",
+ "continent" : "Europe",
+ "call_code" : "+31"
},
{
- "code" : "xx",
- "name" : "Testland",
- "continent" : "Testcontinent",
- "continent_i18n" : { "de_DE" : "Testkontinent" },
- "name_i18n" : {
- "de_DE": "Testlandt",
- "de_CH": "Testlandi",
- "fr_FR": "Testpais",
- "en_UK": "Testland"
- },
- "currency": "TESTKUDOS",
- "call_code" : "+00"
+ "code" : "sk",
+ "name" : "Slovakia",
+ "continent" : "Europe",
+ "call_code" : "+421"
},
{
- "code" : "xy",
- "name" : "Demoland",
- "continent" : "Testcontinent",
- "continent_i18n" : { "de_DE" : "Testkontinent" },
- "name_i18n" : {
- "de_DE":"Demolandt",
- "de_CH":"Demolandi",
- "fr_FR": "Demopais",
- "en_UK": "Demoland"
- },
- "currency": "KUDOS",
- "call_code" : "+01"
+ "code" : "us",
+ "name" : "United States of America (USA)",
+ "continent" : "North America",
+ "call_code" : "+1"
+ },
+ {
+ "code" : "xx",
+ "name" : "Testland",
+ "continent" : "Demoworld",
+ "call_code" : "+0"
}
]
}
diff --git a/contrib/redux.cz.json b/contrib/redux.cz.json
index e7118a8..3f11118 100644
--- a/contrib/redux.cz.json
+++ b/contrib/redux.cz.json
@@ -20,10 +20,7 @@
"type": "string",
"name": "birth_number",
"label": "Birth Number",
- "label_i18n":{
- "en": "Birth Number",
- "cz": "rodné Äíslo"
- },
+ "tooltip": "rodné Äíslo",
"widget": "anastasis_gtk_ia_birthnumber_cz",
"uuid": "03e3a05b-1192-44f1-ac36-7425512eee1a",
"validation-regex": "^[0-9]{2}(((0|2|5|7)[0-9])|10|11|31|32|51|52|81|82)/[0-9]{3}[0-9]?$",
diff --git a/contrib/redux.de.json b/contrib/redux.de.json
index 862a463..e62f24a 100644
--- a/contrib/redux.de.json
+++ b/contrib/redux.de.json
@@ -25,30 +25,27 @@
},
{
"type": "string",
+ "name": "social_security_number",
+ "label": "Social security number",
+ "tooltip": "Deutsche Sozialversicherungsnummer",
+ "widget": "anastasis_gtk_ia_ssn_de",
+ "uuid": "d5e2aa79-1c88-4cf4-a4d2-252508b38e05",
+ "validation-regex": "^[0-9]{8}[[:upper:]][0-9]{3}$",
+ "validation-logic": "DE_SVN_check",
+ "optional" : true
+ },
+ {
+ "type": "string",
"name": "tax_number",
"label": "Taxpayer identification number",
"label_i18n":{
"de_DE": "Steuerliche Identifikationsnummer",
"en": "German taxpayer identification number"
},
- "widget": "anastasis_gtk_ia_tax_de",
+ "widget": "anastasis_gtk_ia_tin_de",
"uuid": "dae48f85-e3ff-47a4-a4a3-ed981ed8c3c6",
"validation-regex": "^[0-9]{11}$",
"validation-logic": "DE_TIN_check"
- },
- {
- "type": "string",
- "name": "social_security_number",
- "label": "Social security number",
- "label_i18n":{
- "de_DE": "Deutsche Sozialversicherungsnummer",
- "en": "German Social security number"
- },
- "widget": "anastasis_gtk_ia_ssn_de",
- "uuid": "d5e2aa79-1c88-4cf4-a4d2-252508b38e05",
- "validation-regex": "^[0-9]{8}[[:upper:]][0-9]{3}$",
- "validation-logic": "DE_SVN_check",
- "optional" : true
}
]
}
diff --git a/contrib/redux.dk.json b/contrib/redux.dk.json
index 29c7c6c..66859b5 100644
--- a/contrib/redux.dk.json
+++ b/contrib/redux.dk.json
@@ -20,10 +20,7 @@
"type": "string",
"name": "cpr_number",
"label": "CPR-nummer",
- "label_i18n":{
- "en": "CPR Number",
- "dk": "CPR-nummer"
- },
+ "tooltip": "CPR-nummer",
"widget": "anastasis_gtk_ia_cpr_dk",
"uuid": "38f13a4d-4302-4ada-ada1-c3ff4a8ff689",
"validation-regex": "^(0[1-9]|[1-2][0-9]|30|31)((0[1-9]|10|11|12))[0-9]{2}-[0-9A-Z]{4}$"
diff --git a/contrib/redux.es.json b/contrib/redux.es.json
index 5926b6d..320d346 100644
--- a/contrib/redux.es.json
+++ b/contrib/redux.es.json
@@ -27,9 +27,7 @@
"type": "string",
"name": "tax_number",
"label": "Tax number",
- "label_i18n":{
- "es_ES":"Número de Identificación Fiscal (DNI, NIE)",
- },
+ "tooltip":"Número de Identificación Fiscal (DNI, NIE)",
"widget": "anastasis_gtk_ia_es_dni",
"uuid" : "ac8bd865-6be8-445c-b650-6a18eef16a49",
"validation-regex": "^[0-9MXYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$",
@@ -39,9 +37,7 @@
"type": "string",
"name": "ssn_number",
"label": "Social security number",
- "label_i18n":{
- "es_ES":"Número de Seguridad Social",
- },
+ "tooltip":"Número de Seguridad Social",
"widget": "anastasis_gtk_ia_es_ssn",
"uuid" : "22396a19-f3bb-497e-b63a-961fd639140e",
"validation-regex": "^[0-9]{11}$"
diff --git a/contrib/redux.xy.json b/contrib/redux.fr.json
index 2091d9a..fe6ce9b 100644
--- a/contrib/redux.xy.json
+++ b/contrib/redux.fr.json
@@ -18,12 +18,20 @@
},
{
"type": "string",
- "name": "prime_number",
- "label": "Prime number",
- "widget": "anastasis_gtk_xx_prime",
- "uuid" : "39190a95-cacb-4412-8bae-1f7da3f980b4",
- "validation-regex": "^[0-9]+$",
- "validation-logic": "XY_PRIME_check"
+ "name": "birthplace",
+ "label": "Birthplace",
+ "widget": "anastasis_gtk_ia_birthplace",
+ "uuid" : "4c822e8e-89c6-11eb-95c4-8b077ad8489f"
+ },
+ {
+ "type": "string",
+ "name": "social_security_number",
+ "label": "Code Insee",
+ "tooltip": "Code Insee",
+ "widget": "anastasis_gtk_ia_insee_fr",
+ "uuid": "2f36a81c-3f6d-41f3-97ee-9c885bc41873",
+ "validation-regex": "^[0-9]{15}$",
+ "validation-logic": "FR_INSEE_check"
}
]
}
diff --git a/contrib/redux.in.json b/contrib/redux.in.json
index a53035c..e7dc8fa 100644
--- a/contrib/redux.in.json
+++ b/contrib/redux.in.json
@@ -27,9 +27,6 @@
"type": "string",
"name": "aadhar_number",
"label": "Aadhar number",
- "label_i18n":{
- "en": "Aadhar number"
- },
"widget": "anastasis_gtk_ia_aadhar_in",
"uuid": "55afe97a-98bc-48d1-bb37-a9658be3fdc9",
"validation-regex": "^[2-9]{1}[0-9]{3}\\s[0-9]{4}\\s[0-9]{4}$",
diff --git a/contrib/redux.it.json b/contrib/redux.it.json
index f744497..f67cd45 100644
--- a/contrib/redux.it.json
+++ b/contrib/redux.it.json
@@ -19,11 +19,8 @@
{
"type": "string",
"name": "fiscal_code",
- "label": "Codice fiscale",
- "label_i18n":{
- "it": "Codice fiscale",
- "en": "Fiscal code"
- },
+ "label": "Fiscal code",
+ "tooltip": "Codice fiscale",
"widget": "anastasis_gtk_ia_cf_it",
"uuid": "88f53c51-52ad-4d63-a163-ec042589f925",
"validation-regex": "^[[:upper:]]{6}[0-9]{2}[A-EHLMPRT](([0-24-6][0-9])|(30|31|70|71))[A-MZ][0-9]{3}[A-Z]$",
diff --git a/contrib/redux.jp.json b/contrib/redux.jp.json
index 2a80cdf..9eda2f6 100644
--- a/contrib/redux.jp.json
+++ b/contrib/redux.jp.json
@@ -27,10 +27,7 @@
"type": "string",
"name": "my_number",
"label": "My number",
- "label_i18n":{
- "en": "My number",
- "jp": "マイナンãƒãƒ¼"
- },
+ "tooltip": "マイナンãƒãƒ¼",
"widget": "anastasis_gtk_ia_my_jp",
"uuid": "90848f42-a83e-4226-8186-329696c14152",
"validation-regex": "^[0-9]{12}$"
diff --git a/contrib/redux.nl.json b/contrib/redux.nl.json
new file mode 100644
index 0000000..ce6b766
--- /dev/null
+++ b/contrib/redux.nl.json
@@ -0,0 +1,37 @@
+{
+ "license": "GPLv3+",
+ "SPDX-License-Identifier": "GPL3.0-or-later",
+ "required_attributes": [
+ {
+ "type": "string",
+ "name": "full_name",
+ "label": "Full name",
+ "widget": "anastasis_gtk_ia_full_name",
+ "uuid" : "9e8f463f-575f-42cb-85f3-759559997331"
+ },
+ {
+ "type": "date",
+ "name": "birthdate",
+ "label": "Birthdate",
+ "widget": "anastasis_gtk_ia_birthdate",
+ "uuid" : "83d655c7-bdb6-484d-904e-80c1058c8854"
+ },
+ {
+ "type": "string",
+ "name": "birthplace",
+ "label": "Birthplace",
+ "widget": "anastasis_gtk_ia_birthplace",
+ "uuid" : "4c822e8e-89c6-11eb-95c4-8b077ad8489f"
+ },
+ {
+ "type": "string",
+ "name": "social_security_number",
+ "label": "Citizen Service Number",
+ "tooltip": "Burgerservicenummer (BSN)",
+ "widget": "anastasis_gtk_ia_ssn_nl",
+ "uuid": "b6bf1f14-1f85-4afb-af21-f54b88490bdc",
+ "validation-regex": "^[1-9][0-9]{8}$",
+ "validation-logic": "NL_BSN_check"
+ }
+ ]
+}
diff --git a/contrib/redux.sk.json b/contrib/redux.sk.json
index e2acef7..7520d15 100644
--- a/contrib/redux.sk.json
+++ b/contrib/redux.sk.json
@@ -20,10 +20,7 @@
"type": "string",
"name": "birth_number",
"label": "Birth Number",
- "label_i18n":{
- "en": "Birth Number",
- "sk": "rodné Äíslo"
- },
+ "tooltip": "rodné Äíslo",
"widget": "anastasis_gtk_ia_birthnumber_sk",
"uuid": "1cd372fe-2cea-4928-9f29-66f2bdd8555c",
"validation-regex": "^[0-9]{2}(((0|2|5|7)[0-9])|10|11|31|32|51|52|81|82)/[0-9]{3}[0-9]?$",
diff --git a/contrib/redux.us.json b/contrib/redux.us.json
index 17e7556..c6d0189 100644
--- a/contrib/redux.us.json
+++ b/contrib/redux.us.json
@@ -27,12 +27,11 @@
"type": "string",
"name": "social_security_number",
"label": "Social security number",
- "label_i18n":{
- "en": "US Social security number"
- },
+ "tooltip": "US Social security number",
"widget": "anastasis_gtk_ia_ssn_us",
"uuid": "310a138c-b0b7-4985-b8b8-d00e765e9f9b",
- "validation-regex": "^d{3}-d{2}-d{4}$"
+ "validation-regex": "^[0-9]{3}-[0-9]{2}-[0-9]{4}$",
+ "autocomplete": "???-??-????"
}
]
}
diff --git a/contrib/redux.xx.json b/contrib/redux.xx.json
index b28af81..71d67e5 100644
--- a/contrib/redux.xx.json
+++ b/contrib/redux.xx.json
@@ -1,6 +1,7 @@
{
"license": "GPLv3+",
"SPDX-License-Identifier": "GPL3.0-or-later",
+ "restricted" : "xx",
"required_attributes": [
{
"type": "string",
@@ -18,8 +19,20 @@
},
{
"type": "string",
+ "name": "prime_number",
+ "label": "Prime number",
+ "tooltip": "Mathematics is fun",
+ "widget": "anastasis_gtk_xx_prime",
+ "uuid" : "39190a95-cacb-4412-8bae-1f7da3f980b4",
+ "validation-regex": "^[0-9]+$",
+ "validation-logic": "XY_PRIME_check",
+ "optional" : true
+ },
+ {
+ "type": "string",
"name": "sq_number",
"label": "Square number",
+ "tooltip": "Mathematics is fun",
"widget": "anastasis_gtk_xx_square",
"uuid" : "ed790bca-89bf-11eb-96f2-233996cf644e",
"validation-regex": "^[0-9]+$",
diff --git a/contrib/tos/.gitignore b/contrib/tos/.gitignore
deleted file mode 100644
index fb83616..0000000
--- a/contrib/tos/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-sphinx.err
-sphinx.log
-_build/
diff --git a/contrib/tos/Makefile b/contrib/tos/Makefile
deleted file mode 100644
index ab29543..0000000
--- a/contrib/tos/Makefile
+++ /dev/null
@@ -1,109 +0,0 @@
-# Makefile for Sphinx documentation
-#
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-BUILDDIR = _build
-
-# User-friendly check for sphinx-build
-ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
-$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
-endif
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html json epub latex latexpdf text man doctest gettext
-
-help:
- @echo "Please use \`make <target>' where <target> is one of"
- @echo " html to make a single large HTML file"
- @echo " json to make JSON files"
- @echo " epub to make an epub"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " pdf to make LaTeX files and run them through pdflatex"
- @echo " txt to make text files"
- @echo " man to make manual pages"
- @echo " texinfo to make Texinfo files"
- @echo " info to make Texinfo files and run them through makeinfo"
- @echo " gettext to make PO message catalogs"
- @echo " xml to make Docutils-native XML files"
- @echo " pseudoxml to make pseudoxml-XML files for display purposes"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
-
-clean:
- rm -rf $(BUILDDIR)/*
-
-
-# The html-linked builder does not support caching, so we
-# remove all cached state first.
-html:
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML page is in $(BUILDDIR)/html."
-
-json:
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-epub:
- $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
- @echo
- @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo
- @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
- @echo "Run \`make' in that directory to run these through (pdf)latex" \
- "(use \`make latexpdf' here to do that automatically)."
-
-pdf:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/pdf
- @echo "Running LaTeX files through pdflatex..."
- $(MAKE) -C $(BUILDDIR)/pdf all-pdf
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/pdf."
-
-txt:
- $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/txt
- @echo
- @echo "Build finished. The text files are in $(BUILDDIR)/txt."
-
-man:
- $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
- @echo
- @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-texinfo:
- $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
- @echo
- @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
- @echo "Run \`make' in that directory to run these through makeinfo" \
- "(use \`make info' here to do that automatically)."
-
-info:
- $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/info
- @echo "Running Texinfo files through makeinfo..."
- make -C $(BUILDDIR)/texinfo info
- @echo "makeinfo finished; the Info files are in $(BUILDDIR)/info."
-
-gettext:
- $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
- @echo
- @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-doctest:
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in $(BUILDDIR)/doctest/output.txt."
-
-xml:
- $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
- @echo
- @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
diff --git a/contrib/tos/README b/contrib/tos/README
deleted file mode 100644
index fde5305..0000000
--- a/contrib/tos/README
+++ /dev/null
@@ -1,58 +0,0 @@
-This directory contains the terms of service (template) for exchange
-operators.
-
-
-Dependencies
-============
-
-Generating new Terms of Service requires Sphinx, LaTeX with babel
-packages for all supported languages. On Debian, you should
-at least install:
-
-$ apt install python3-sphinx sphinx-intl texlive-lang-german texlive-lang-english
-
-(NOTE: List may be incomplete.)
-
-
-Updating the Terms of Service
-=============================
-
-The master file with the Terms of service is 'tos.rst'.
-
-If you make substantial changes, you MUST change the "TOS_VERSION"
-in contrib/Makefile.am to the new Etag.
-
-To begin the translation into other languages after editing the master
-file, run
-
-$ make gettext
-
-to generate the master PO file. Then, run
-
-$ sphinx-intl update -p _build/locale/ -l de -l fr -l it
-
-to update the PO files for the various languages (extend the list of
-languages as necessary). The PO files for the translators are kept
-at locale/$LANG/LC_MESSAGES/tos.po for the language $LANG.
-
-Once all PO files have been updated with new translations, run
-
-$ make update-tos
-
-in the "contrib/" directory to generate all of the formats. The
-respective make rule calls the '../update-tos.sh' script in the
-contrib/ directory, which calls the 'Makefile' in the tos/
-directory for the various supported languages and file formats
-and then moves the generated files to the target directory
-('contrib/tos/$LANG/$VERSION.$FORMAT')
-
-
-Adding a new language
-=====================
-
-To add a new language $LANG, add $LANG to "TOS_LANGUAGES" in
-'contrib/Makefile.am' and run
-
-$ sphinx-intl update -p _build/gettext -l $LANG
-
-to generate the PO template.
diff --git a/contrib/tos/conf.py b/contrib/tos/conf.py
deleted file mode 100644
index 2939255..0000000
--- a/contrib/tos/conf.py
+++ /dev/null
@@ -1,282 +0,0 @@
-"""
- This file is part of GNU TALER.
- Copyright (C) 2014-2020 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
- Foundation; either version 2.1, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Florian Dold
- @author Benedikt Muller
- @author Sree Harsha Totakura
- @author Marcello Stanisci
-"""
-# -*- coding: utf-8 -*-
-#
-# neuro documentation build configuration file, created by
-# sphinx-quickstart on Sat May 31 13:11:06 2014.
-#
-# This file is execfile()d with the current directory set to its
-# containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
-import sys
-import os
-
-sys.path.append(os.path.abspath('_exts'))
-
-#import taler_sphinx_theme
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
-
-# -- General configuration ------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-needs_sphinx = '1.8.5'
-
-# Add any Sphinx extension module names here, as strings. They can be
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
-# ones.
-extensions = [
- 'sphinx.ext.todo',
- 'sphinx.ext.imgmath',
-]
-
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-source_suffix = {
- '.rst': 'restructuredtext',
-}
-
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
-# The master toctree document.
-master_doc = 'tos'
-
-# General information about the project.
-project = u'tos'
-copyright = u'2014-2020 Taler Systems SA (GPLv3+ or GFDL 1.3+)'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '0'
-# The full version, including alpha/beta/rc tags.
-release = '0'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-# language = "en de"
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-exclude_patterns = ['_build', '_exts', 'cf', 'prebuilt']
-
-# The reST default role (used for this markup: `text`) to use for all
-# documents.
-# default_role = "ts:type"
-
-locale_dirs = ['locale/']
-gettext_compact = False
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-# If true, keep warnings as "system message" paragraphs in the built documents.
-#keep_warnings = False
-
-# -- Options for HTML output ----------------------------------------------
-
-# The theme to use for HTML and HTML Help pages. See the documentation for
-# a list of builtin themes.
-html_theme = 'epub'
-
-#html_theme_path = taler_sphinx_theme.html_theme_path()
-
-#html_sidebars = {'**': ['logo-text.html', 'globaltoc.html', 'searchbox.html']}
-
-rst_epilog = ""
-
-html_show_sphinx = False
-
-html_theme_options = {
- # Set the name of the project to appear in the sidebar
- "relbar1": "false",
- "footer": "false",
-}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents. If None, it defaults to
-# "<project> v<release> documentation".
-html_title = "Taler Terms of Service"
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-html_short_title = "Terms of Service"
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-# html_static_path = ['_static']
-
-# Add any extra paths that contain custom files (such as robots.txt or
-# .htaccess) here, relative to this directory. These files are copied
-# directly to the root of the documentation.
-#html_extra_path = []
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-html_show_sphinx = False
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
-# -- Options for LaTeX output ---------------------------------------------
-
-latex_elements = {
- # The paper size ('letterpaper' or 'a4paper').
- #'papersize': 'letterpaper',
-
- # The font size ('10pt', '11pt' or '12pt').
- #'pointsize': '10pt',
-
- # Additional stuff for the LaTeX preamble.
- #'preamble': '',
-}
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title,
-# author, documentclass [howto, manual, or own class]).
-latex_documents = [
- ('tos', 'tos.tex',
- 'Terms of Service', 'GNU Taler team', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-# latex_appendices = ["fdl-1.3"]
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-# -- Options for manual page output ---------------------------------------
-
-# If true, show URL addresses after external links.
-#man_show_urls = False
-
-# -- Options for Texinfo output -------------------------------------------
-
-# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
-
-# If false, no module index is generated.
-#texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'
-
-# If true, do not generate a @detailmenu in the "Top" node's menu.
-#texinfo_no_detailmenu = False
-
-
-# -- Options for epub output ----------------------------
-
-epub_basename = "tos"
-
-epub_title = "Terms of Service"
diff --git a/contrib/tos/en/0.epub b/contrib/tos/en/0.epub
deleted file mode 100644
index 095d2c1..0000000
--- a/contrib/tos/en/0.epub
+++ /dev/null
Binary files differ
diff --git a/contrib/tos/en/0.html b/contrib/tos/en/0.html
deleted file mode 100644
index 59e816f..0000000
--- a/contrib/tos/en/0.html
+++ /dev/null
@@ -1,272 +0,0 @@
-
-
-<html lang="en">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Terms Of Service &#8212; Taler Terms of Service</title>
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
- <link rel="stylesheet" href="_static/epub.css" type="text/css" />
- <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script src="_static/jquery.js"></script>
- <script src="_static/underscore.js"></script>
- <script src="_static/doctools.js"></script>
- </head><body>
-
- <div class="document">
- <div class="documentwrapper">
- <div class="bodywrapper">
- <div class="body" role="main">
-
- <div class="section" id="terms-of-service">
-<h1>Terms Of Service<a class="headerlink" href="#terms-of-service" title="Permalink to this headline">¶</a></h1>
-<p>Last Updated: 07.09.2021</p>
-<p>Welcome! Anastasis SARL (“we,†“our,†or “usâ€) provides a distributed
-privacy-preserving backup and recovery service for key material
-through our Internet presence (collectively the “Servicesâ€). Before
-using our Services, please read the Terms of Service (the “Terms†or
-the “Agreementâ€) carefully.</p>
-<div class="section" id="overview">
-<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2>
-<p>This section provides a brief summary of the highlights of this
-Agreement. Please note that when you accept this Agreement, you are
-accepting all of the terms and conditions and not just this
-section. We and possibly other third parties provide Internet services
-which interact with the Anastasis key backup and recovery
-application. When using an application to interact with our Services,
-you are agreeing to our Terms, so please read carefully.</p>
-<div class="section" id="highlights">
-<h3>Highlights:<a class="headerlink" href="#highlights" title="Permalink to this headline">¶</a></h3>
-<blockquote>
-<div><ul class="simple">
-<li><p>You are responsible for selecting authentication methods and
-policies that are adequate to protect your key material.
-Any losses arising from you not being able to satisfy the
-selected authentication challenges or third parties being able
-successfully pass the challenges are your problem.</p></li>
-<li><p>We will store your encrypted key shares and disclose them upon
-successful authentication to the best of our ability within the
-limitations of the law and our implementation. Our liability will
-be limited to the liability limit exposed in the protocol.</p></li>
-<li><p>For our Services, we may charge various fees. The specific fee structure
-is provided based on the Anastasis protocol and should be shown to you when you
-use an application to interact with our services. You agree and understand
-that the Anastasis protocol allows for the fee structure to change.</p></li>
-<li><p>You agree to not intentionally overwhelm our systems with requests and
-follow responsible disclosure if you find security issues in our services.</p></li>
-<li><p>We cannot be held accountable for our Services not being available due to
-circumstances beyond our control. If we modify or terminate our services,
-we will announce this and ensure that you can recover your key material
-for at least one year before we completely terminate the Service.</p></li>
-</ul>
-</div></blockquote>
-<p>These terms outline approved uses of our Services. If you have any
-questions or comments related to this Agreement, please send us a
-message to <a class="reference external" href="mailto:legal&#37;&#52;&#48;anastasis&#46;lu">legal<span>&#64;</span>anastasis<span>&#46;</span>lu</a>. If you do not agree to this Agreement,
-you must not use our Services.</p>
-</div>
-</div>
-<div class="section" id="how-you-accept-this-policy">
-<h2>How you accept this policy<a class="headerlink" href="#how-you-accept-this-policy" title="Permalink to this headline">¶</a></h2>
-<p>By using our API (typically via an Anastasis-enabled application), you
-acknowledge that you have read, understood, and agreed to these
-Terms. We reserve the right to change these Terms at any time. If you
-disagree with the change, you must simply stop using our APIs. Your
-continued use of our Services following any such change will signify
-your acceptance to be bound by the then current Terms. Please check
-the effective date above to determine if there have been any changes
-since you have last reviewed these Terms.</p>
-</div>
-<div class="section" id="services">
-<h2>Services<a class="headerlink" href="#services" title="Permalink to this headline">¶</a></h2>
-<p>We will store your encrypted key shares (and the associated encrypted
-recovery policy document) to the best of our ability and within the
-limitations of the implementation. We will disclose the key shares only
-after the specific authentication challenge has been passed. We will
-rate-limit the use of the authentication APIs to limit brute-force
-attacks.</p>
-<p>We are not guaranteeing that the authentication procedures are effective.
-Other parties may be able to intercept authentication messages, or you
-may not be able to receive these messages anymore. You are responsible
-for choosing safe authentication methods with sufficient security.</p>
-<p>When using our Services, you agree to not take any action that
-intentionally imposes an unreasonable load on our infrastructure. If
-you find security problems in our Services, you agree to first report
-them to <a class="reference external" href="mailto:security&#37;&#52;&#48;anastasis&#46;lu">security<span>&#64;</span>anastasis<span>&#46;</span>lu</a> and grant us the right to publish your
-report. We warrant that we will ourselves publicly disclose any issues
-reported within 1 month, and that we will not prosecute anyone
-reporting security issues if they did not exploit the issue beyond a
-proof-of-concept, and followed the above responsible disclosure
-practice.</p>
-</div>
-<div class="section" id="fees">
-<h2>Fees<a class="headerlink" href="#fees" title="Permalink to this headline">¶</a></h2>
-<p>You agree to pay the fees for backup and recovery operations (“Feesâ€)
-as defined by us, which we may change from time to time. Your
-Anastasis client should obtain and display applicable fees during
-backup and recovery.</p>
-</div>
-<div class="section" id="eligibility">
-<h2>Eligibility<a class="headerlink" href="#eligibility" title="Permalink to this headline">¶</a></h2>
-<p>To be eligible to use our Services, you must be able to form legally binding
-contracts or have the permission of your legal guardian. By using our
-Services, you represent and warrant that you meet all eligibility requirements
-that we outline in these Terms.</p>
-</div>
-<div class="section" id="copyrights-and-trademarks">
-<h2>Copyrights and trademarks<a class="headerlink" href="#copyrights-and-trademarks" title="Permalink to this headline">¶</a></h2>
-<p>The Anastasis software is released under the terms of the GNU Affero
-General Public License (GNU AGPLv3+). You have the right to access,
-use, and share the Anastasis application, in modified or unmodified
-form. However, the Affero GPL is a strong copyleft license, which
-means that any derivative works must be distributed under the same
-license terms as the original software. If you have any questions, you
-should review the GNU AGPL’s full terms and conditions at
-<a class="reference external" href="https://www.gnu.org/licenses/agpl-3.0.en.html">https://www.gnu.org/licenses/agpl-3.0.en.html</a>. “Anastasis†itself is
-a trademark of Anastasis SARL. You are welcome to use the name in
-relation to implementations of the Anastasis protocol, assuming your
-use is compatible with an official release from the GNU Project that
-is not older than two years.</p>
-</div>
-<div class="section" id="limitation-of-liability-disclaimer-of-warranties">
-<h2>Limitation of liability &amp; disclaimer of warranties<a class="headerlink" href="#limitation-of-liability-disclaimer-of-warranties" title="Permalink to this headline">¶</a></h2>
-<p>You understand and agree that we have no control over, and no duty to
-take any action regarding: Failures, disruptions, errors, or delays in
-processing that you may experience while using our Services; The risk
-of failure of hardware, software, and Internet connections; The risk
-of malicious software being introduced or found in the software
-underlying the Anastasis implementation. You release us from all
-liability related to any losses, damages, or claims arising from:</p>
-<ol class="loweralpha simple">
-<li><p>user error such as forgotten security answers or loss of
-control over accounts used for authentication;</p></li>
-</ol>
-<p>(b) server failure or data loss;
-(d) bugs or other errors in the Anastasis client software; and
-(e) any unauthorized third party activities, including, but not limited to,</p>
-<blockquote>
-<div><p>the use of viruses, phishing, brute forcing, or other means of attack
-against the Anastasis client. We make no representations concerning any
-Third Party Content contained in or accessed through our Services.</p>
-</div></blockquote>
-<p>Any other terms, conditions, warranties, or representations associated with
-such content, are solely between you and such organizations and/or
-individuals.</p>
-<p>To the fullest extent permitted by applicable law, in no event will we
-or any of our officers, directors, representatives, agents, servants,
-counsel, employees, consultants, lawyers, and other personnel
-authorized to act, acting, or purporting to act on our behalf
-(collectively the “Anastasis Partiesâ€) be liable to you under
-contract, tort, strict liability, negligence, or any other legal or
-equitable theory, for:</p>
-<ol class="loweralpha simple">
-<li><p>any lost profits, data loss, cost of procurement of substitute goods or
-services, or direct, indirect, incidental, special, punitive, compensatory,
-or consequential damages of any kind whatsoever resulting from:</p></li>
-</ol>
-<blockquote>
-<div><ol class="lowerroman simple">
-<li><p>your use of, or conduct in connection with, our services;</p></li>
-<li><p>any unauthorized use of your wallet and/or private key due to your
-failure to maintain the confidentiality of your wallet;</p></li>
-<li><p>any interruption or cessation of transmission to or from the services; or</p></li>
-<li><p>any bugs, viruses, trojan horses, or the like that are found in the Taler
-Wallet software or that may be transmitted to or through our services by
-any third party (regardless of the source of origination), or</p></li>
-</ol>
-</div></blockquote>
-<ol class="loweralpha simple" start="2">
-<li><p>any direct damages.</p></li>
-</ol>
-<p>These limitations apply regardless of legal theory, whether based on tort,
-strict liability, breach of contract, breach of warranty, or any other legal
-theory, and whether or not we were advised of the possibility of such
-damages. Some jurisdictions do not allow the exclusion or limitation of
-liability for consequential or incidental damages, so the above limitation may
-not apply to you.</p>
-<p>Our services are provided “as is†and without warranty of any kind. To the
-maximum extent permitted by law, we disclaim all representations and
-warranties, express or implied, relating to the services and underlying
-software or any content on the services, whether provided or owned by us or by
-any third party, including without limitation, warranties of merchantability,
-fitness for a particular purpose, title, non-infringement, freedom from
-computer virus, and any implied warranties arising from course of dealing,
-course of performance, or usage in trade, all of which are expressly
-disclaimed. In addition, we do not represent or warrant that the content
-accessible via the services is accurate, complete, available, current, free of
-viruses or other harmful components, or that the results of using the services
-will meet your requirements. Some states do not allow the disclaimer of
-implied warranties, so the foregoing disclaimers may not apply to you. This
-paragraph gives you specific legal rights and you may also have other legal
-rights that vary from state to state.</p>
-</div>
-<div class="section" id="indemnity-and-time-limitation-on-claims-and-termination">
-<h2>Indemnity and Time limitation on claims and Termination<a class="headerlink" href="#indemnity-and-time-limitation-on-claims-and-termination" title="Permalink to this headline">¶</a></h2>
-<p>To the extent permitted by applicable law, you agree to defend,
-indemnify, and hold harmless the Anastasis Parties from and against
-any and all claims, damages, obligations, losses, liabilities, costs
-or debt, and expenses (including, but not limited to, attorney’s fees)
-arising from: (a) your use of and access to the Services; (b) any
-feedback or submissions you provide to us concerning the Anastasis
-software; (c) your violation of any term of this Agreement; or (d)
-your violation of any law, rule, or regulation, or the rights of any
-third party.</p>
-<p>You agree that any claim you may have arising out of or related to your
-relationship with us must be filed within one year after such claim arises,
-otherwise, your claim in permanently barred.</p>
-<p>In the event of termination concerning your use of our Services, your
-obligations under this Agreement will still continue.</p>
-</div>
-<div class="section" id="discontinuance-of-services-and-force-majeure">
-<h2>Discontinuance of services and Force majeure<a class="headerlink" href="#discontinuance-of-services-and-force-majeure" title="Permalink to this headline">¶</a></h2>
-<p>We shall not be held liable for any delays, failure in performance, or
-interruptions of service which result directly or indirectly from any cause or
-condition beyond our reasonable control, including but not limited to: any
-delay or failure due to any act of God, act of civil or military authorities,
-act of terrorism, civil disturbance, war, strike or other labor dispute, fire,
-interruption in telecommunications or Internet services or network provider
-services, failure of equipment and/or software, other catastrophe, or any
-other occurrence which is beyond our reasonable control and shall not affect
-the validity and enforceability of any remaining provisions.</p>
-</div>
-<div class="section" id="governing-law-waivers-severability-and-assignment">
-<h2>Governing law, Waivers, Severability and Assignment<a class="headerlink" href="#governing-law-waivers-severability-and-assignment" title="Permalink to this headline">¶</a></h2>
-<p>No matter where you’re located, the laws of Luxembourg will govern these
-Terms. If any provisions of these Terms are inconsistent with any applicable
-law, those provisions will be superseded or modified only to the extent such
-provisions are inconsistent. The parties agree to submit to the ordinary
-courts in Luxembourg for exclusive jurisdiction of any dispute
-arising out of or related to your use of the Services or your breach of these
-Terms.</p>
-<p>Our failure to exercise or delay in exercising any right, power, or privilege
-under this Agreement shall not operate as a waiver; nor shall any single or
-partial exercise of any right, power, or privilege preclude any other or
-further exercise thereof.</p>
-<p>You agree that we may assign any of our rights and/or transfer, sub-contract,
-or delegate any of our obligations under these Terms.</p>
-<p>If it turns out that any part of this Agreement is invalid, void, or for any
-reason unenforceable, that term will be deemed severable and limited or
-eliminated to the minimum extent necessary.</p>
-<p>This Agreement sets forth the entire understanding and agreement as to the
-subject matter hereof and supersedes any and all prior discussions,
-agreements, and understandings of any kind (including, without limitation, any
-prior versions of this Agreement) and every nature between us. Except as
-provided for above, any modification to this Agreement must be in writing and
-must be signed by both parties.</p>
-</div>
-<div class="section" id="questions-or-comments">
-<h2>Questions or comments<a class="headerlink" href="#questions-or-comments" title="Permalink to this headline">¶</a></h2>
-<p>We welcome comments, questions, concerns, or suggestions. Please send us a
-message on our contact page at <a class="reference external" href="mailto:legal&#37;&#52;&#48;anastasis&#46;lu">legal<span>&#64;</span>anastasis<span>&#46;</span>lu</a>.</p>
-</div>
-</div>
-
-
- <div class="clearer"></div>
- </div>
- </div>
- </div>
- <div class="clearer"></div>
- </div>
- </body>
-</html> \ No newline at end of file
diff --git a/contrib/tos/en/0.pdf b/contrib/tos/en/0.pdf
deleted file mode 100644
index cb1cc36..0000000
--- a/contrib/tos/en/0.pdf
+++ /dev/null
Binary files differ
diff --git a/contrib/tos/en/0.txt b/contrib/tos/en/0.txt
deleted file mode 100644
index 4f1c814..0000000
--- a/contrib/tos/en/0.txt
+++ /dev/null
@@ -1,287 +0,0 @@
-Terms Of Service
-****************
-
-Last Updated: 07.09.2021
-
-Welcome! Anastasis SARL (“we,†“our,†or “usâ€) provides a distributed
-privacy-preserving backup and recovery service for key material
-through our Internet presence (collectively the “Servicesâ€). Before
-using our Services, please read the Terms of Service (the “Terms†or
-the “Agreementâ€) carefully.
-
-
-Overview
-========
-
-This section provides a brief summary of the highlights of this
-Agreement. Please note that when you accept this Agreement, you are
-accepting all of the terms and conditions and not just this section.
-We and possibly other third parties provide Internet services which
-interact with the Anastasis key backup and recovery application. When
-using an application to interact with our Services, you are agreeing
-to our Terms, so please read carefully.
-
-
-Highlights:
------------
-
- * You are responsible for selecting authentication methods and
- policies that are adequate to protect your key material. Any
- losses arising from you not being able to satisfy the selected
- authentication challenges or third parties being able
- successfully pass the challenges are your problem.
-
- * We will store your encrypted key shares and disclose them upon
- successful authentication to the best of our ability within the
- limitations of the law and our implementation. Our liability will
- be limited to the liability limit exposed in the protocol.
-
- * For our Services, we may charge various fees. The specific fee
- structure is provided based on the Anastasis protocol and should
- be shown to you when you use an application to interact with our
- services. You agree and understand that the Anastasis protocol
- allows for the fee structure to change.
-
- * You agree to not intentionally overwhelm our systems with
- requests and follow responsible disclosure if you find security
- issues in our services.
-
- * We cannot be held accountable for our Services not being
- available due to circumstances beyond our control. If we modify
- or terminate our services, we will announce this and ensure that
- you can recover your key material for at least one year before we
- completely terminate the Service.
-
-These terms outline approved uses of our Services. If you have any
-questions or comments related to this Agreement, please send us a
-message to legal@anastasis.lu. If you do not agree to this Agreement,
-you must not use our Services.
-
-
-How you accept this policy
-==========================
-
-By using our API (typically via an Anastasis-enabled application), you
-acknowledge that you have read, understood, and agreed to these Terms.
-We reserve the right to change these Terms at any time. If you
-disagree with the change, you must simply stop using our APIs. Your
-continued use of our Services following any such change will signify
-your acceptance to be bound by the then current Terms. Please check
-the effective date above to determine if there have been any changes
-since you have last reviewed these Terms.
-
-
-Services
-========
-
-We will store your encrypted key shares (and the associated encrypted
-recovery policy document) to the best of our ability and within the
-limitations of the implementation. We will disclose the key shares
-only after the specific authentication challenge has been passed. We
-will rate-limit the use of the authentication APIs to limit brute-
-force attacks.
-
-We are not guaranteeing that the authentication procedures are
-effective. Other parties may be able to intercept authentication
-messages, or you may not be able to receive these messages anymore.
-You are responsible for choosing safe authentication methods with
-sufficient security.
-
-When using our Services, you agree to not take any action that
-intentionally imposes an unreasonable load on our infrastructure. If
-you find security problems in our Services, you agree to first report
-them to security@anastasis.lu and grant us the right to publish your
-report. We warrant that we will ourselves publicly disclose any issues
-reported within 1 month, and that we will not prosecute anyone
-reporting security issues if they did not exploit the issue beyond a
-proof-of-concept, and followed the above responsible disclosure
-practice.
-
-
-Fees
-====
-
-You agree to pay the fees for backup and recovery operations ("Fees")
-as defined by us, which we may change from time to time. Your
-Anastasis client should obtain and display applicable fees during
-backup and recovery.
-
-
-Eligibility
-===========
-
-To be eligible to use our Services, you must be able to form legally
-binding contracts or have the permission of your legal guardian. By
-using our Services, you represent and warrant that you meet all
-eligibility requirements that we outline in these Terms.
-
-
-Copyrights and trademarks
-=========================
-
-The Anastasis software is released under the terms of the GNU Affero
-General Public License (GNU AGPLv3+). You have the right to access,
-use, and share the Anastasis application, in modified or unmodified
-form. However, the Affero GPL is a strong copyleft license, which
-means that any derivative works must be distributed under the same
-license terms as the original software. If you have any questions, you
-should review the GNU AGPL’s full terms and conditions at
-https://www.gnu.org/licenses/agpl-3.0.en.html. “Anastasis†itself is
-a trademark of Anastasis SARL. You are welcome to use the name in
-relation to implementations of the Anastasis protocol, assuming your
-use is compatible with an official release from the GNU Project that
-is not older than two years.
-
-
-Limitation of liability & disclaimer of warranties
-==================================================
-
-You understand and agree that we have no control over, and no duty to
-take any action regarding: Failures, disruptions, errors, or delays in
-processing that you may experience while using our Services; The risk
-of failure of hardware, software, and Internet connections; The risk
-of malicious software being introduced or found in the software
-underlying the Anastasis implementation. You release us from all
-liability related to any losses, damages, or claims arising from:
-
-1. user error such as forgotten security answers or loss of control
- over accounts used for authentication;
-
-(b) server failure or data loss; (d) bugs or other errors in the
-Anastasis client software; and (e) any unauthorized third party
-activities, including, but not limited to,
-
- the use of viruses, phishing, brute forcing, or other means of
- attack against the Anastasis client. We make no representations
- concerning any Third Party Content contained in or accessed through
- our Services.
-
-Any other terms, conditions, warranties, or representations associated
-with such content, are solely between you and such organizations
-and/or individuals.
-
-To the fullest extent permitted by applicable law, in no event will we
-or any of our officers, directors, representatives, agents, servants,
-counsel, employees, consultants, lawyers, and other personnel
-authorized to act, acting, or purporting to act on our behalf
-(collectively the “Anastasis Partiesâ€) be liable to you under
-contract, tort, strict liability, negligence, or any other legal or
-equitable theory, for:
-
-1. any lost profits, data loss, cost of procurement of substitute
- goods or services, or direct, indirect, incidental, special,
- punitive, compensatory, or consequential damages of any kind
- whatsoever resulting from:
-
- 1. your use of, or conduct in connection with, our services;
-
- 2. any unauthorized use of your wallet and/or private key due to
- your failure to maintain the confidentiality of your wallet;
-
- 3. any interruption or cessation of transmission to or from the
- services; or
-
- 4. any bugs, viruses, trojan horses, or the like that are found in
- the Taler Wallet software or that may be transmitted to or
- through our services by any third party (regardless of the
- source of origination), or
-
-2. any direct damages.
-
-These limitations apply regardless of legal theory, whether based on
-tort, strict liability, breach of contract, breach of warranty, or any
-other legal theory, and whether or not we were advised of the
-possibility of such damages. Some jurisdictions do not allow the
-exclusion or limitation of liability for consequential or incidental
-damages, so the above limitation may not apply to you.
-
-Our services are provided "as is" and without warranty of any kind. To
-the maximum extent permitted by law, we disclaim all representations
-and warranties, express or implied, relating to the services and
-underlying software or any content on the services, whether provided
-or owned by us or by any third party, including without limitation,
-warranties of merchantability, fitness for a particular purpose,
-title, non-infringement, freedom from computer virus, and any implied
-warranties arising from course of dealing, course of performance, or
-usage in trade, all of which are expressly disclaimed. In addition, we
-do not represent or warrant that the content accessible via the
-services is accurate, complete, available, current, free of viruses or
-other harmful components, or that the results of using the services
-will meet your requirements. Some states do not allow the disclaimer
-of implied warranties, so the foregoing disclaimers may not apply to
-you. This paragraph gives you specific legal rights and you may also
-have other legal rights that vary from state to state.
-
-
-Indemnity and Time limitation on claims and Termination
-=======================================================
-
-To the extent permitted by applicable law, you agree to defend,
-indemnify, and hold harmless the Anastasis Parties from and against
-any and all claims, damages, obligations, losses, liabilities, costs
-or debt, and expenses (including, but not limited to, attorney’s fees)
-arising from: (a) your use of and access to the Services; (b) any
-feedback or submissions you provide to us concerning the Anastasis
-software; (c) your violation of any term of this Agreement; or (d)
-your violation of any law, rule, or regulation, or the rights of any
-third party.
-
-You agree that any claim you may have arising out of or related to
-your relationship with us must be filed within one year after such
-claim arises, otherwise, your claim in permanently barred.
-
-In the event of termination concerning your use of our Services, your
-obligations under this Agreement will still continue.
-
-
-Discontinuance of services and Force majeure
-============================================
-
-We shall not be held liable for any delays, failure in performance, or
-interruptions of service which result directly or indirectly from any
-cause or condition beyond our reasonable control, including but not
-limited to: any delay or failure due to any act of God, act of civil
-or military authorities, act of terrorism, civil disturbance, war,
-strike or other labor dispute, fire, interruption in
-telecommunications or Internet services or network provider services,
-failure of equipment and/or software, other catastrophe, or any other
-occurrence which is beyond our reasonable control and shall not affect
-the validity and enforceability of any remaining provisions.
-
-
-Governing law, Waivers, Severability and Assignment
-===================================================
-
-No matter where you’re located, the laws of Luxembourg will govern
-these Terms. If any provisions of these Terms are inconsistent with
-any applicable law, those provisions will be superseded or modified
-only to the extent such provisions are inconsistent. The parties agree
-to submit to the ordinary courts in Luxembourg for exclusive
-jurisdiction of any dispute arising out of or related to your use of
-the Services or your breach of these Terms.
-
-Our failure to exercise or delay in exercising any right, power, or
-privilege under this Agreement shall not operate as a waiver; nor
-shall any single or partial exercise of any right, power, or privilege
-preclude any other or further exercise thereof.
-
-You agree that we may assign any of our rights and/or transfer, sub-
-contract, or delegate any of our obligations under these Terms.
-
-If it turns out that any part of this Agreement is invalid, void, or
-for any reason unenforceable, that term will be deemed severable and
-limited or eliminated to the minimum extent necessary.
-
-This Agreement sets forth the entire understanding and agreement as to
-the subject matter hereof and supersedes any and all prior
-discussions, agreements, and understandings of any kind (including,
-without limitation, any prior versions of this Agreement) and every
-nature between us. Except as provided for above, any modification to
-this Agreement must be in writing and must be signed by both parties.
-
-
-Questions or comments
-=====================
-
-We welcome comments, questions, concerns, or suggestions. Please send
-us a message on our contact page at legal@anastasis.lu.
diff --git a/contrib/tos/en/0.xml b/contrib/tos/en/0.xml
deleted file mode 100644
index 3bf9332..0000000
--- a/contrib/tos/en/0.xml
+++ /dev/null
@@ -1,271 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE document PUBLIC "+//IDN docutils.sourceforge.net//DTD Docutils Generic//EN//XML" "http://docutils.sourceforge.net/docs/ref/docutils.dtd">
-<!-- Generated by Docutils 0.16 -->
-<document source="/research/anastasis/anastasis/contrib/tos/tos.rst">
- <section ids="terms-of-service" names="terms\ of\ service">
- <title>Terms Of Service</title>
- <paragraph>Last Updated: 07.09.2021</paragraph>
- <paragraph>Welcome! Anastasis SARL (“we,†“our,†or “usâ€) provides a distributed
- privacy-preserving backup and recovery service for key material
- through our Internet presence (collectively the “Servicesâ€). Before
- using our Services, please read the Terms of Service (the “Terms†or
- the “Agreementâ€) carefully.</paragraph>
- <section ids="overview" names="overview">
- <title>Overview</title>
- <paragraph>This section provides a brief summary of the highlights of this
- Agreement. Please note that when you accept this Agreement, you are
- accepting all of the terms and conditions and not just this
- section. We and possibly other third parties provide Internet services
- which interact with the Anastasis key backup and recovery
- application. When using an application to interact with our Services,
- you are agreeing to our Terms, so please read carefully.</paragraph>
- <section ids="highlights" names="highlights:">
- <title>Highlights:</title>
- <block_quote>
- <bullet_list bullet="•">
- <list_item>
- <paragraph>You are responsible for selecting authentication methods and
- policies that are adequate to protect your key material.
- Any losses arising from you not being able to satisfy the
- selected authentication challenges or third parties being able
- successfully pass the challenges are your problem.</paragraph>
- </list_item>
- <list_item>
- <paragraph>We will store your encrypted key shares and disclose them upon
- successful authentication to the best of our ability within the
- limitations of the law and our implementation. Our liability will
- be limited to the liability limit exposed in the protocol.</paragraph>
- </list_item>
- <list_item>
- <paragraph>For our Services, we may charge various fees. The specific fee structure
- is provided based on the Anastasis protocol and should be shown to you when you
- use an application to interact with our services. You agree and understand
- that the Anastasis protocol allows for the fee structure to change.</paragraph>
- </list_item>
- <list_item>
- <paragraph>You agree to not intentionally overwhelm our systems with requests and
- follow responsible disclosure if you find security issues in our services.</paragraph>
- </list_item>
- <list_item>
- <paragraph>We cannot be held accountable for our Services not being available due to
- circumstances beyond our control. If we modify or terminate our services,
- we will announce this and ensure that you can recover your key material
- for at least one year before we completely terminate the Service.</paragraph>
- </list_item>
- </bullet_list>
- </block_quote>
- <paragraph>These terms outline approved uses of our Services. If you have any
- questions or comments related to this Agreement, please send us a
- message to <reference refuri="mailto:legal@anastasis.lu">legal@anastasis.lu</reference>. If you do not agree to this Agreement,
- you must not use our Services.</paragraph>
- </section>
- </section>
- <section ids="how-you-accept-this-policy" names="how\ you\ accept\ this\ policy">
- <title>How you accept this policy</title>
- <paragraph>By using our API (typically via an Anastasis-enabled application), you
- acknowledge that you have read, understood, and agreed to these
- Terms. We reserve the right to change these Terms at any time. If you
- disagree with the change, you must simply stop using our APIs. Your
- continued use of our Services following any such change will signify
- your acceptance to be bound by the then current Terms. Please check
- the effective date above to determine if there have been any changes
- since you have last reviewed these Terms.</paragraph>
- </section>
- <section ids="services" names="services">
- <title>Services</title>
- <paragraph>We will store your encrypted key shares (and the associated encrypted
- recovery policy document) to the best of our ability and within the
- limitations of the implementation. We will disclose the key shares only
- after the specific authentication challenge has been passed. We will
- rate-limit the use of the authentication APIs to limit brute-force
- attacks.</paragraph>
- <paragraph>We are not guaranteeing that the authentication procedures are effective.
- Other parties may be able to intercept authentication messages, or you
- may not be able to receive these messages anymore. You are responsible
- for choosing safe authentication methods with sufficient security.</paragraph>
- <paragraph>When using our Services, you agree to not take any action that
- intentionally imposes an unreasonable load on our infrastructure. If
- you find security problems in our Services, you agree to first report
- them to <reference refuri="mailto:security@anastasis.lu">security@anastasis.lu</reference> and grant us the right to publish your
- report. We warrant that we will ourselves publicly disclose any issues
- reported within 1 month, and that we will not prosecute anyone
- reporting security issues if they did not exploit the issue beyond a
- proof-of-concept, and followed the above responsible disclosure
- practice.</paragraph>
- </section>
- <section ids="fees" names="fees">
- <title>Fees</title>
- <paragraph>You agree to pay the fees for backup and recovery operations (“Feesâ€)
- as defined by us, which we may change from time to time. Your
- Anastasis client should obtain and display applicable fees during
- backup and recovery.</paragraph>
- </section>
- <section ids="eligibility" names="eligibility">
- <title>Eligibility</title>
- <paragraph>To be eligible to use our Services, you must be able to form legally binding
- contracts or have the permission of your legal guardian. By using our
- Services, you represent and warrant that you meet all eligibility requirements
- that we outline in these Terms.</paragraph>
- </section>
- <section ids="copyrights-and-trademarks" names="copyrights\ and\ trademarks">
- <title>Copyrights and trademarks</title>
- <paragraph>The Anastasis software is released under the terms of the GNU Affero
- General Public License (GNU AGPLv3+). You have the right to access,
- use, and share the Anastasis application, in modified or unmodified
- form. However, the Affero GPL is a strong copyleft license, which
- means that any derivative works must be distributed under the same
- license terms as the original software. If you have any questions, you
- should review the GNU AGPL’s full terms and conditions at
- <reference refuri="https://www.gnu.org/licenses/agpl-3.0.en.html">https://www.gnu.org/licenses/agpl-3.0.en.html</reference>. “Anastasis†itself is
- a trademark of Anastasis SARL. You are welcome to use the name in
- relation to implementations of the Anastasis protocol, assuming your
- use is compatible with an official release from the GNU Project that
- is not older than two years.</paragraph>
- </section>
- <section ids="limitation-of-liability-disclaimer-of-warranties" names="limitation\ of\ liability\ &amp;\ disclaimer\ of\ warranties">
- <title>Limitation of liability &amp; disclaimer of warranties</title>
- <paragraph>You understand and agree that we have no control over, and no duty to
- take any action regarding: Failures, disruptions, errors, or delays in
- processing that you may experience while using our Services; The risk
- of failure of hardware, software, and Internet connections; The risk
- of malicious software being introduced or found in the software
- underlying the Anastasis implementation. You release us from all
- liability related to any losses, damages, or claims arising from:</paragraph>
- <enumerated_list enumtype="loweralpha" prefix="(" suffix=")">
- <list_item>
- <paragraph>user error such as forgotten security answers or loss of
- control over accounts used for authentication;</paragraph>
- </list_item>
- </enumerated_list>
- <paragraph>(b) server failure or data loss;
- (d) bugs or other errors in the Anastasis client software; and
- (e) any unauthorized third party activities, including, but not limited to,</paragraph>
- <block_quote>
- <paragraph>the use of viruses, phishing, brute forcing, or other means of attack
- against the Anastasis client. We make no representations concerning any
- Third Party Content contained in or accessed through our Services.</paragraph>
- </block_quote>
- <paragraph>Any other terms, conditions, warranties, or representations associated with
- such content, are solely between you and such organizations and/or
- individuals.</paragraph>
- <paragraph>To the fullest extent permitted by applicable law, in no event will we
- or any of our officers, directors, representatives, agents, servants,
- counsel, employees, consultants, lawyers, and other personnel
- authorized to act, acting, or purporting to act on our behalf
- (collectively the “Anastasis Partiesâ€) be liable to you under
- contract, tort, strict liability, negligence, or any other legal or
- equitable theory, for:</paragraph>
- <enumerated_list enumtype="loweralpha" prefix="(" suffix=")">
- <list_item>
- <paragraph>any lost profits, data loss, cost of procurement of substitute goods or
- services, or direct, indirect, incidental, special, punitive, compensatory,
- or consequential damages of any kind whatsoever resulting from:</paragraph>
- </list_item>
- </enumerated_list>
- <block_quote>
- <enumerated_list enumtype="lowerroman" prefix="(" suffix=")">
- <list_item>
- <paragraph>your use of, or conduct in connection with, our services;</paragraph>
- </list_item>
- <list_item>
- <paragraph>any unauthorized use of your wallet and/or private key due to your
- failure to maintain the confidentiality of your wallet;</paragraph>
- </list_item>
- <list_item>
- <paragraph>any interruption or cessation of transmission to or from the services; or</paragraph>
- </list_item>
- <list_item>
- <paragraph>any bugs, viruses, trojan horses, or the like that are found in the Taler
- Wallet software or that may be transmitted to or through our services by
- any third party (regardless of the source of origination), or</paragraph>
- </list_item>
- </enumerated_list>
- </block_quote>
- <enumerated_list enumtype="loweralpha" prefix="(" start="2" suffix=")">
- <list_item>
- <paragraph>any direct damages.</paragraph>
- </list_item>
- </enumerated_list>
- <paragraph>These limitations apply regardless of legal theory, whether based on tort,
- strict liability, breach of contract, breach of warranty, or any other legal
- theory, and whether or not we were advised of the possibility of such
- damages. Some jurisdictions do not allow the exclusion or limitation of
- liability for consequential or incidental damages, so the above limitation may
- not apply to you.</paragraph>
- <paragraph>Our services are provided “as is†and without warranty of any kind. To the
- maximum extent permitted by law, we disclaim all representations and
- warranties, express or implied, relating to the services and underlying
- software or any content on the services, whether provided or owned by us or by
- any third party, including without limitation, warranties of merchantability,
- fitness for a particular purpose, title, non-infringement, freedom from
- computer virus, and any implied warranties arising from course of dealing,
- course of performance, or usage in trade, all of which are expressly
- disclaimed. In addition, we do not represent or warrant that the content
- accessible via the services is accurate, complete, available, current, free of
- viruses or other harmful components, or that the results of using the services
- will meet your requirements. Some states do not allow the disclaimer of
- implied warranties, so the foregoing disclaimers may not apply to you. This
- paragraph gives you specific legal rights and you may also have other legal
- rights that vary from state to state.</paragraph>
- </section>
- <section ids="indemnity-and-time-limitation-on-claims-and-termination" names="indemnity\ and\ time\ limitation\ on\ claims\ and\ termination">
- <title>Indemnity and Time limitation on claims and Termination</title>
- <paragraph>To the extent permitted by applicable law, you agree to defend,
- indemnify, and hold harmless the Anastasis Parties from and against
- any and all claims, damages, obligations, losses, liabilities, costs
- or debt, and expenses (including, but not limited to, attorney’s fees)
- arising from: (a) your use of and access to the Services; (b) any
- feedback or submissions you provide to us concerning the Anastasis
- software; (c) your violation of any term of this Agreement; or (d)
- your violation of any law, rule, or regulation, or the rights of any
- third party.</paragraph>
- <paragraph>You agree that any claim you may have arising out of or related to your
- relationship with us must be filed within one year after such claim arises,
- otherwise, your claim in permanently barred.</paragraph>
- <paragraph>In the event of termination concerning your use of our Services, your
- obligations under this Agreement will still continue.</paragraph>
- </section>
- <section ids="discontinuance-of-services-and-force-majeure" names="discontinuance\ of\ services\ and\ force\ majeure">
- <title>Discontinuance of services and Force majeure</title>
- <paragraph>We shall not be held liable for any delays, failure in performance, or
- interruptions of service which result directly or indirectly from any cause or
- condition beyond our reasonable control, including but not limited to: any
- delay or failure due to any act of God, act of civil or military authorities,
- act of terrorism, civil disturbance, war, strike or other labor dispute, fire,
- interruption in telecommunications or Internet services or network provider
- services, failure of equipment and/or software, other catastrophe, or any
- other occurrence which is beyond our reasonable control and shall not affect
- the validity and enforceability of any remaining provisions.</paragraph>
- </section>
- <section ids="governing-law-waivers-severability-and-assignment" names="governing\ law,\ waivers,\ severability\ and\ assignment">
- <title>Governing law, Waivers, Severability and Assignment</title>
- <paragraph>No matter where you’re located, the laws of Luxembourg will govern these
- Terms. If any provisions of these Terms are inconsistent with any applicable
- law, those provisions will be superseded or modified only to the extent such
- provisions are inconsistent. The parties agree to submit to the ordinary
- courts in Luxembourg for exclusive jurisdiction of any dispute
- arising out of or related to your use of the Services or your breach of these
- Terms.</paragraph>
- <paragraph>Our failure to exercise or delay in exercising any right, power, or privilege
- under this Agreement shall not operate as a waiver; nor shall any single or
- partial exercise of any right, power, or privilege preclude any other or
- further exercise thereof.</paragraph>
- <paragraph>You agree that we may assign any of our rights and/or transfer, sub-contract,
- or delegate any of our obligations under these Terms.</paragraph>
- <paragraph>If it turns out that any part of this Agreement is invalid, void, or for any
- reason unenforceable, that term will be deemed severable and limited or
- eliminated to the minimum extent necessary.</paragraph>
- <paragraph>This Agreement sets forth the entire understanding and agreement as to the
- subject matter hereof and supersedes any and all prior discussions,
- agreements, and understandings of any kind (including, without limitation, any
- prior versions of this Agreement) and every nature between us. Except as
- provided for above, any modification to this Agreement must be in writing and
- must be signed by both parties.</paragraph>
- </section>
- <section ids="questions-or-comments" names="questions\ or\ comments">
- <title>Questions or comments</title>
- <paragraph>We welcome comments, questions, concerns, or suggestions. Please send us a
- message on our contact page at <reference refuri="mailto:legal@anastasis.lu">legal@anastasis.lu</reference>.</paragraph>
- </section>
- </section>
-</document>
diff --git a/contrib/tos/locale/de/LC_MESSAGES/tos.po b/contrib/tos/locale/de/LC_MESSAGES/tos.po
deleted file mode 100644
index 21aa9c8..0000000
--- a/contrib/tos/locale/de/LC_MESSAGES/tos.po
+++ /dev/null
@@ -1,517 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) 2014-2020 Taler Systems SA (GPLv3+ or GFDL 1.3+)
-# This file is distributed under the same license as the tos package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, 2020.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: tos 0\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-02-07 01:00+0100\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel 2.6.0\n"
-
-#: ../../tos.rst:2
-msgid "Terms Of Service"
-msgstr ""
-
-#: ../../tos.rst:4
-msgid "Last Updated: 12.4.2019"
-msgstr ""
-
-#: ../../tos.rst:6
-msgid ""
-"Welcome! Taler Systems SA (“we,†“our,†or “usâ€) provides a payment "
-"service through our Internet presence (collectively the “Servicesâ€). "
-"Before using our Services, please read the Terms of Service (the “Terms†"
-"or the “Agreementâ€) carefully."
-msgstr ""
-
-#: ../../tos.rst:12
-msgid "Overview"
-msgstr ""
-
-#: ../../tos.rst:14
-msgid ""
-"This section provides a brief summary of the highlights of this "
-"Agreement. Please note that when you accept this Agreement, you are "
-"accepting all of the terms and conditions and not just this section. We "
-"and possibly other third parties provide Internet services which interact"
-" with the Taler Wallet’s self-hosted personal payment application. When "
-"using the Taler Wallet to interact with our Services, you are agreeing to"
-" our Terms, so please read carefully."
-msgstr ""
-
-#: ../../tos.rst:23
-msgid "Highlights:"
-msgstr ""
-
-#: ../../tos.rst:25
-msgid ""
-"You are responsible for keeping the data in your Taler Wallet at all "
-"times under your control. Any losses arising from you not being in "
-"control of your private information are your problem."
-msgstr ""
-
-#: ../../tos.rst:28
-msgid ""
-"We will try to transfer funds we hold in escrow for our users to any "
-"legal recipient to the best of our ability within the limitations of the "
-"law and our implementation. However, the Services offered today are "
-"highly experimental and the set of recipients of funds is severely "
-"restricted."
-msgstr ""
-
-#: ../../tos.rst:32
-msgid ""
-"For our Services, we may charge transaction fees. The specific fee "
-"structure is provided based on the Taler protocol and should be shown to "
-"you when you withdraw electronic coins using a Taler Wallet. You agree "
-"and understand that the Taler protocol allows for the fee structure to "
-"change."
-msgstr ""
-
-#: ../../tos.rst:36
-msgid ""
-"You agree to not intentionally overwhelm our systems with requests and "
-"follow responsible disclosure if you find security issues in our "
-"services."
-msgstr ""
-
-#: ../../tos.rst:38
-msgid ""
-"We cannot be held accountable for our Services not being available due to"
-" circumstances beyond our control. If we modify or terminate our "
-"services, we will try to give you the opportunity to recover your funds. "
-"However, given the experimental state of the Services today, this may not"
-" be possible. You are strongly advised to limit your use of the Service "
-"to small-scale experiments expecting total loss of all funds."
-msgstr ""
-
-#: ../../tos.rst:45
-msgid ""
-"These terms outline approved uses of our Services. The Services and these"
-" Terms are still at an experimental stage. If you have any questions or "
-"comments related to this Agreement, please send us a message to legal"
-"@taler-systems.com. If you do not agree to this Agreement, you must not "
-"use our Services."
-msgstr ""
-
-#: ../../tos.rst:52
-msgid "How you accept this policy"
-msgstr ""
-
-#: ../../tos.rst:54
-msgid ""
-"By sending funds to us (to top-up your Taler Wallet), you acknowledge "
-"that you have read, understood, and agreed to these Terms. We reserve the"
-" right to change these Terms at any time. If you disagree with the "
-"change, we may in the future offer you with an easy option to recover "
-"your unspent funds. However, in the current experimental period you "
-"acknowledge that this feature is not yet available, resulting in your "
-"funds being lost unless you accept the new Terms. If you continue to use "
-"our Services other than to recover your unspent funds, your continued use"
-" of our Services following any such change will signify your acceptance "
-"to be bound by the then current Terms. Please check the effective date "
-"above to determine if there have been any changes since you have last "
-"reviewed these Terms."
-msgstr ""
-
-#: ../../tos.rst:67
-msgid "Services"
-msgstr ""
-
-#: ../../tos.rst:69
-msgid ""
-"We will try to transfer funds that we hold in escrow for our users to any"
-" legal recipient to the best of our ability and within the limitations of"
-" the law and our implementation. However, the Services offered today are "
-"highly experimental and the set of recipients of funds is severely "
-"restricted. The Taler Wallet can be loaded by exchanging fiat currencies"
-" against electronic coins. We are providing this exchange service. Once "
-"your Taler Wallet is loaded with electronic coins they can be spent for "
-"purchases if the seller is accepting Taler as a means of payment. We are "
-"not guaranteeing that any seller is accepting Taler at all or a "
-"particular seller. The seller or recipient of deposits of electronic "
-"coins must specify the target account, as per the design of the Taler "
-"protocol. They are responsible for following the protocol and specifying "
-"the correct bank account, and are solely liable for any losses that may "
-"arise from specifying the wrong account. We will allow the government to "
-"link wire transfers to the underlying contract hash. It is the "
-"responsibility of recipients to preserve the full contracts and to pay "
-"whatever taxes and charges may be applicable. Technical issues may lead "
-"to situations where we are unable to make transfers at all or lead to "
-"incorrect transfers that cannot be reversed. We will only refuse to "
-"execute transfers if the transfers are prohibited by a competent legal "
-"authority and we are ordered to do so."
-msgstr ""
-
-#: ../../tos.rst:91
-msgid "Fees"
-msgstr ""
-
-#: ../../tos.rst:93
-msgid ""
-"You agree to pay the fees for exchanges and withdrawals completed via the"
-" Taler Wallet (\"Fees\") as defined by us, which we may change from time "
-"to time. With the exception of wire transfer fees, Taler transaction fees"
-" are set for any electronic coin at the time of withdrawal and fixed "
-"throughout the validity period of the respective electronic coin. Your "
-"wallet should obtain and display applicable fees when withdrawing funds. "
-"Fees for coins obtained as change may differ from the fees applicable to "
-"the original coin. Wire transfer fees that are independent from "
-"electronic coins may change annually. You authorize us to charge or "
-"deduct applicable fees owed in connection with deposits, exchanges and "
-"withdrawals following the rules of the Taler protocol. We reserve the "
-"right to provide different types of rewards to users either in the form "
-"of discount for our Services or in any other form at our discretion and "
-"without prior notice to you."
-msgstr ""
-
-#: ../../tos.rst:108
-msgid "Eligibility"
-msgstr ""
-
-#: ../../tos.rst:110
-msgid ""
-"To be eligible to use our Services, you must be able to form legally "
-"binding contracts or have the permission of your legal guardian. By using"
-" our Services, you represent and warrant that you meet all eligibility "
-"requirements that we outline in these Terms."
-msgstr ""
-
-#: ../../tos.rst:116
-msgid "Financial self-responsibility"
-msgstr ""
-
-#: ../../tos.rst:118
-msgid ""
-"You will be responsible for maintaining the availability, integrity and "
-"confidentiality of the data stored in your wallet. When you setup a Taler"
-" Wallet, you are strongly advised to follow the precautionary measures "
-"offered by the software to minimize the chances to losse access to or "
-"control over your Wallet data. We will not be liable for any loss or "
-"damage arising from your failure to comply with this paragraph."
-msgstr ""
-
-#: ../../tos.rst:126
-msgid "Copyrights and trademarks"
-msgstr ""
-
-#: ../../tos.rst:128
-msgid ""
-"The Taler Wallet is released under the terms of the GNU General Public "
-"License (GNU GPL). You have the right to access, use, and share the Taler"
-" Wallet, in modified or unmodified form. However, the GPL is a strong "
-"copyleft license, which means that any derivative works must be "
-"distributed under the same license terms as the original software. If you"
-" have any questions, you should review the GNU GPL’s full terms and "
-"conditions at https://www.gnu.org/licenses/gpl-3.0.en.html. “Taler†"
-"itself is a trademark of Taler Systems SA. You are welcome to use the "
-"name in relation to processing payments using the Taler protocol, "
-"assuming your use is compatible with an official release from the GNU "
-"Project that is not older than two years."
-msgstr ""
-
-#: ../../tos.rst:140
-msgid "Your use of our services"
-msgstr ""
-
-#: ../../tos.rst:142
-msgid ""
-"When using our Services, you agree to not take any action that "
-"intentionally imposes an unreasonable load on our infrastructure. If you "
-"find security problems in our Services, you agree to first report them to"
-" security@taler-systems.com and grant us the right to publish your "
-"report. We warrant that we will ourselves publicly disclose any issues "
-"reported within 3 months, and that we will not prosecute anyone reporting"
-" security issues if they did not exploit the issue beyond a proof-of-"
-"concept, and followed the above responsible disclosure practice."
-msgstr ""
-
-#: ../../tos.rst:152
-msgid "Limitation of liability & disclaimer of warranties"
-msgstr ""
-
-#: ../../tos.rst:154
-msgid ""
-"You understand and agree that we have no control over, and no duty to "
-"take any action regarding: Failures, disruptions, errors, or delays in "
-"processing that you may experience while using our Services; The risk of "
-"failure of hardware, software, and Internet connections; The risk of "
-"malicious software being introduced or found in the software underlying "
-"the Taler Wallet; The risk that third parties may obtain unauthorized "
-"access to information stored within your Taler Wallet, including, but not"
-" limited to your Taler Wallet coins or backup encryption keys. You "
-"release us from all liability related to any losses, damages, or claims "
-"arising from:"
-msgstr ""
-
-#: ../../tos.rst:164
-msgid ""
-"user error such as forgotten passwords, incorrectly constructed "
-"transactions;"
-msgstr ""
-
-#: ../../tos.rst:166
-msgid "server failure or data loss;"
-msgstr ""
-
-#: ../../tos.rst:167
-msgid "unauthorized access to the Taler Wallet application;"
-msgstr ""
-
-#: ../../tos.rst:168
-msgid "bugs or other errors in the Taler Wallet software; and"
-msgstr ""
-
-#: ../../tos.rst:169
-msgid ""
-"any unauthorized third party activities, including, but not limited to, "
-"the use of viruses, phishing, brute forcing, or other means of attack "
-"against the Taler Wallet. We make no representations concerning any Third"
-" Party Content contained in or accessed through our Services."
-msgstr ""
-
-#: ../../tos.rst:174
-msgid ""
-"Any other terms, conditions, warranties, or representations associated "
-"with such content, are solely between you and such organizations and/or "
-"individuals."
-msgstr ""
-
-#: ../../tos.rst:179
-msgid "Limitation of liability"
-msgstr ""
-
-#: ../../tos.rst:181
-msgid ""
-"To the fullest extent permitted by applicable law, in no event will we or"
-" any of our officers, directors, representatives, agents, servants, "
-"counsel, employees, consultants, lawyers, and other personnel authorized "
-"to act, acting, or purporting to act on our behalf (collectively the "
-"“Taler Partiesâ€) be liable to you under contract, tort, strict liability,"
-" negligence, or any other legal or equitable theory, for:"
-msgstr ""
-
-#: ../../tos.rst:188
-msgid ""
-"any lost profits, data loss, cost of procurement of substitute goods or "
-"services, or direct, indirect, incidental, special, punitive, "
-"compensatory, or consequential damages of any kind whatsoever resulting "
-"from:"
-msgstr ""
-
-#: ../../tos.rst:192
-msgid "your use of, or conduct in connection with, our services;"
-msgstr ""
-
-#: ../../tos.rst:193
-msgid ""
-"any unauthorized use of your wallet and/or private key due to your "
-"failure to maintain the confidentiality of your wallet;"
-msgstr ""
-
-#: ../../tos.rst:195
-msgid "any interruption or cessation of transmission to or from the services; or"
-msgstr ""
-
-#: ../../tos.rst:196
-msgid ""
-"any bugs, viruses, trojan horses, or the like that are found in the Taler"
-" Wallet software or that may be transmitted to or through our services by"
-" any third party (regardless of the source of origination), or"
-msgstr ""
-
-#: ../../tos.rst:200
-msgid "any direct damages."
-msgstr ""
-
-#: ../../tos.rst:202
-msgid ""
-"These limitations apply regardless of legal theory, whether based on "
-"tort, strict liability, breach of contract, breach of warranty, or any "
-"other legal theory, and whether or not we were advised of the possibility"
-" of such damages. Some jurisdictions do not allow the exclusion or "
-"limitation of liability for consequential or incidental damages, so the "
-"above limitation may not apply to you."
-msgstr ""
-
-#: ../../tos.rst:210
-msgid "Warranty disclaimer"
-msgstr ""
-
-#: ../../tos.rst:212
-msgid ""
-"Our services are provided \"as is\" and without warranty of any kind. To "
-"the maximum extent permitted by law, we disclaim all representations and "
-"warranties, express or implied, relating to the services and underlying "
-"software or any content on the services, whether provided or owned by us "
-"or by any third party, including without limitation, warranties of "
-"merchantability, fitness for a particular purpose, title, non-"
-"infringement, freedom from computer virus, and any implied warranties "
-"arising from course of dealing, course of performance, or usage in trade,"
-" all of which are expressly disclaimed. In addition, we do not represent "
-"or warrant that the content accessible via the services is accurate, "
-"complete, available, current, free of viruses or other harmful "
-"components, or that the results of using the services will meet your "
-"requirements. Some states do not allow the disclaimer of implied "
-"warranties, so the foregoing disclaimers may not apply to you. This "
-"paragraph gives you specific legal rights and you may also have other "
-"legal rights that vary from state to state."
-msgstr ""
-
-#: ../../tos.rst:229
-msgid "Indemnity"
-msgstr ""
-
-#: ../../tos.rst:231
-msgid ""
-"To the extent permitted by applicable law, you agree to defend, "
-"indemnify, and hold harmless the Taler Parties from and against any and "
-"all claims, damages, obligations, losses, liabilities, costs or debt, and"
-" expenses (including, but not limited to, attorney’s fees) arising from: "
-"(a) your use of and access to the Services; (b) any feedback or "
-"submissions you provide to us concerning the Taler Wallet; (c) your "
-"violation of any term of this Agreement; or (d) your violation of any "
-"law, rule, or regulation, or the rights of any third party."
-msgstr ""
-
-#: ../../tos.rst:240
-msgid "Time limitation on claims"
-msgstr ""
-
-#: ../../tos.rst:242
-msgid ""
-"You agree that any claim you may have arising out of or related to your "
-"relationship with us must be filed within one year after such claim "
-"arises, otherwise, your claim in permanently barred."
-msgstr ""
-
-#: ../../tos.rst:247
-msgid "Governing law"
-msgstr ""
-
-#: ../../tos.rst:249
-msgid ""
-"No matter where you’re located, the laws of Switzerland will govern these"
-" Terms. If any provisions of these Terms are inconsistent with any "
-"applicable law, those provisions will be superseded or modified only to "
-"the extent such provisions are inconsistent. The parties agree to submit "
-"to the ordinary courts in Zurich, Switzerland for exclusive jurisdiction "
-"of any dispute arising out of or related to your use of the Services or "
-"your breach of these Terms."
-msgstr ""
-
-#: ../../tos.rst:258
-msgid "Termination"
-msgstr ""
-
-#: ../../tos.rst:260
-msgid ""
-"In the event of termination concerning your use of our Services, your "
-"obligations under this Agreement will still continue."
-msgstr ""
-
-#: ../../tos.rst:264
-msgid "Discontinuance of services"
-msgstr ""
-
-#: ../../tos.rst:266
-msgid ""
-"We may, in our sole discretion and without cost to you, with or without "
-"prior notice, and at any time, modify or discontinue, temporarily or "
-"permanently, any portion of our Services. We will use the Taler "
-"protocol’s provisions to notify Wallets if our Services are to be "
-"discontinued. It is your responsibility to ensure that the Taler Wallet "
-"is online at least once every three months to observe these "
-"notifications. We shall not be held responsible or liable for any loss of"
-" funds in the event that we discontinue or depreciate the Services and "
-"your Taler Wallet fails to transfer out the coins within a three months "
-"notification period."
-msgstr ""
-
-#: ../../tos.rst:277
-msgid "No waiver"
-msgstr ""
-
-#: ../../tos.rst:279
-msgid ""
-"Our failure to exercise or delay in exercising any right, power, or "
-"privilege under this Agreement shall not operate as a waiver; nor shall "
-"any single or partial exercise of any right, power, or privilege preclude"
-" any other or further exercise thereof."
-msgstr ""
-
-#: ../../tos.rst:285
-msgid "Severability"
-msgstr ""
-
-#: ../../tos.rst:287
-msgid ""
-"If it turns out that any part of this Agreement is invalid, void, or for "
-"any reason unenforceable, that term will be deemed severable and limited "
-"or eliminated to the minimum extent necessary."
-msgstr ""
-
-#: ../../tos.rst:292
-msgid "Force majeure"
-msgstr ""
-
-#: ../../tos.rst:294
-msgid ""
-"We shall not be held liable for any delays, failure in performance, or "
-"interruptions of service which result directly or indirectly from any "
-"cause or condition beyond our reasonable control, including but not "
-"limited to: any delay or failure due to any act of God, act of civil or "
-"military authorities, act of terrorism, civil disturbance, war, strike or"
-" other labor dispute, fire, interruption in telecommunications or "
-"Internet services or network provider services, failure of equipment "
-"and/or software, other catastrophe, or any other occurrence which is "
-"beyond our reasonable control and shall not affect the validity and "
-"enforceability of any remaining provisions."
-msgstr ""
-
-#: ../../tos.rst:305
-msgid "Assignment"
-msgstr ""
-
-#: ../../tos.rst:307
-msgid ""
-"You agree that we may assign any of our rights and/or transfer, sub-"
-"contract, or delegate any of our obligations under these Terms."
-msgstr ""
-
-#: ../../tos.rst:311
-msgid "Entire agreement"
-msgstr ""
-
-#: ../../tos.rst:313
-msgid ""
-"This Agreement sets forth the entire understanding and agreement as to "
-"the subject matter hereof and supersedes any and all prior discussions, "
-"agreements, and understandings of any kind (including, without "
-"limitation, any prior versions of this Agreement) and every nature "
-"between us. Except as provided for above, any modification to this "
-"Agreement must be in writing and must be signed by both parties."
-msgstr ""
-
-#: ../../tos.rst:321
-msgid "Questions or comments"
-msgstr ""
-
-#: ../../tos.rst:323
-msgid ""
-"We welcome comments, questions, concerns, or suggestions. Please send us "
-"a message on our contact page at legal@taler-systems.com."
-msgstr ""
-
-#~ msgid "Indemntiy"
-#~ msgstr ""
-
diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg
index 8c9df2c..af2d8e6 100644
--- a/contrib/uncrustify.cfg
+++ b/contrib/uncrustify.cfg
@@ -28,7 +28,7 @@ ls_code_width=true
pos_arith=lead
# Fully parenthesize boolean exprs
-mod_full_paren_if_bool=true
+mod_full_paren_if_bool=false
# Braces should be on their own line
nl_fdef_brace=add
diff --git a/contrib/update-pp.sh b/contrib/update-pp.sh
index db31ba1..03aa237 100755
--- a/contrib/update-pp.sh
+++ b/contrib/update-pp.sh
@@ -22,7 +22,16 @@ do
rm -rf _build
echo " Generating format $f"
make -e SPHINXOPTS="-D language='$l'" $f >>sphinx.log 2>>sphinx.err < /dev/null
- mv _build/$f/pp.$f $l/${VERSION}.$f
+ if test $f = "html"
+ then
+ htmlark -o $l/${VERSION}.$f _build/$f/${VERSION}.$f
+ else
+ mv _build/$f/${VERSION}.$f $l/${VERSION}.$f
+ fi
+ if test $f = "txt"
+ then
+ cp $l/${VERSION}.$f $l/${VERSION}.md
+ fi
done
done
cd ..
diff --git a/contrib/update-tos.sh b/contrib/update-tos.sh
index 47d3af7..26d65ed 100755
--- a/contrib/update-tos.sh
+++ b/contrib/update-tos.sh
@@ -22,7 +22,16 @@ do
rm -rf _build
echo " Generating format $f"
make -e SPHINXOPTS="-D language='$l'" $f >>sphinx.log 2>>sphinx.err < /dev/null
- mv _build/$f/tos.$f $l/${VERSION}.$f
+ if test $f = "html"
+ then
+ htmlark -o $l/${VERSION}.$f _build/$f/${VERSION}.$f
+ else
+ mv _build/$f/${VERSION}.$f $l/${VERSION}.$f
+ fi
+ if test $f = "txt"
+ then
+ cp $l/${VERSION}.$f $l/${VERSION}.md
+ fi
done
done
cd ..
diff --git a/debian/anastasis-httpd.config b/debian/anastasis-httpd.config
index 97f57bc..97d5101 100644
--- a/debian/anastasis-httpd.config
+++ b/debian/anastasis-httpd.config
@@ -6,17 +6,3 @@ set -e
_USERNAME=anastasis-httpd
_GROUPNAME=www-data
-
-# For now, we only support postgres
-dbc_dbtypes=pgsql
-dbc_dbuser=${_USERNAME}
-
-dbc_authmethod_user=ident
-dbc_authmethod_admin=ident
-
-if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
- . /usr/share/dbconfig-common/dpkg/config.pgsql
- dbc_go anastasis-httpd "$@"
-fi
-
-db_stop
diff --git a/debian/anastasis-httpd.install b/debian/anastasis-httpd.install
index 652caa0..6594f28 100644
--- a/debian/anastasis-httpd.install
+++ b/debian/anastasis-httpd.install
@@ -3,7 +3,9 @@ usr/lib/*/anastasis/
usr/lib/*/libanastasisauthorization.*
usr/lib/*/libanastasisdb.*
usr/lib/*/libanastasiseufin.so.*
-usr/share/man/man5/*
+usr/share/man/man5/anastasis.conf.5
+usr/share/man/man1/anastasis-dbconfig.1
+usr/share/man/man1/anastasis-dbinit.1
usr/share/man/man1/anastasis-httpd.1
usr/share/man/man1/anastasis-helper-authorization-iban.1
usr/share/man/man1/anastasis-config.1
@@ -11,4 +13,7 @@ usr/share/anastasis/*
usr/share/anastasis/sql/*
usr/share/anastasis/config.d/*
debian/etc/* /etc/
-debian/db/install/* usr/share/dbconfig-common/scripts/anastasis/install/
+# Terms of service / privacy policy templates
+usr/share/anastasis/terms/*.rst
+# Translations of ToS/PP
+usr/share/locale/*/LC_MESSAGES/*.po
diff --git a/debian/anastasis-httpd.postinst b/debian/anastasis-httpd.postinst
index 994b06b..1dd41f4 100644
--- a/debian/anastasis-httpd.postinst
+++ b/debian/anastasis-httpd.postinst
@@ -2,37 +2,43 @@
set -e
-TALER_HOME="/var/lib/taler/"
+if [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload >/dev/null || true
+fi
+if [ "$1" = "remove" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper mask 'anastasis-httpd.service' >/dev/null || true
+ fi
+fi
+
+if [ "$1" = "purge" ]; then
+ if [ -x "/usr/bin/deb-systemd-helper" ]; then
+ deb-systemd-helper purge 'anastasis-httpd.service' >/dev/null || true
+ deb-systemd-helper unmask 'anastasis-httpd.service' >/dev/null || true
+ fi
+fi
+
+ANASTASIS_HOME="/var/lib/anastasis/"
_USERNAME=anastasis-httpd
_GROUPNAME=www-data
-# Set permissions for sqlite3 file
-# (for when we support sqlite3 in the future)
-dbc_dbfile_owner="${_USERNAME}:${_GROUPNAME}"
-dbc_dbfile_perms="0600"
-
. /usr/share/debconf/confmodule
case "${1}" in
configure)
# Creating taler users if needed
- if ! getent passwd ${_USERNAME} >/dev/null; then
- adduser --quiet --system --ingroup ${_GROUPNAME} --no-create-home --home ${TALER_HOME} ${_USERNAME}
+ if ! getent passwd ${_USERNAME} >/dev/null
+ then
+ adduser --quiet --system --ingroup ${_GROUPNAME} --no-create-home --home ${ANASTASIS_HOME} ${_USERNAME}
fi
- if ! dpkg-statoverride --list /etc/anastasis/secrets/anastasis-db.secret.conf >/dev/null 2>&1; then
+ if ! dpkg-statoverride --list /etc/anastasis/secrets/anastasis-db.secret.conf >/dev/null 2>&1
+ then
dpkg-statoverride --add --update \
anastasis-httpd root 460 \
/etc/anastasis/secrets/anastasis-db.secret.conf
fi
- # Setup postgres database (needs dbconfig-pgsql package)
- if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
- . /usr/share/dbconfig-common/dpkg/postinst.pgsql
- dbc_pgsql_createdb_encoding="UTF8"
- dbc_go anastasis-httpd "$@"
- fi
-
;;
abort-upgrade | abort-remove | abort-deconfigure) ;;
diff --git a/debian/anastasis-httpd.postrm b/debian/anastasis-httpd.postrm
index 9954a33..ee84d38 100644
--- a/debian/anastasis-httpd.postrm
+++ b/debian/anastasis-httpd.postrm
@@ -2,18 +2,19 @@
set -e
+_USERNAME=anastasis-httpd
+
if [ -f /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
fi
-if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
- . /usr/share/dbconfig-common/dpkg/postrm.pgsql
- dbc_go anastasis-httpd "$@"
-fi
-
case "${1}" in
purge)
rm -rf /var/lib/anastasis/httpd/
+ rm -f /etc/anastasis/override.conf
+ deluser --system --quiet ${_USERNAME} || true
+ dpkg-statoverride --remove \
+ /etc/anastasis/secrets/anastasis-db.secret.conf || true
;;
remove | upgrade | failed-upgrade | abort-install | abort-upgrade | disappear)
;;
diff --git a/debian/anastasis-httpd.preinst b/debian/anastasis-httpd.preinst
deleted file mode 100644
index 2d6c261..0000000
--- a/debian/anastasis-httpd.preinst
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-# We prevent a few questions from being asked
-# upon installation by specifying defaults. Namely,
-# we want the database to be accessed via Unix domain
-# sockets and password-less.
-
-set -e
-
-# When purging this package after the selections in the preinst have been made,
-# the debconf database is left in an inconsistent state and the package cannot
-# be installed again. This happens because dbconf-common will create a
-# template for these questions with a shared owner. Purging will only delete
-# one of the two templates, leading to a DB state where debconf-set-selections
-# fails. We work around this by manually fixing up the debconf database.
-#
-# Unfortunately we can't do this in "postrm", because during "postrm"
-# the configuration database is locked (even after db_stop).
-#
-# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487300
-if [ -x /usr/share/debconf/fix_db.pl ]; then
- /usr/share/debconf/fix_db.pl || true
-fi
-
-echo anastasis-httpd anastasis-httpd/pgsql/method select Unix socket | debconf-set-selections
-echo anastasis-httpd anastasis-httpd/pgsql/authmethod-user select ident | debconf-set-selections
-echo anastasis-httpd anastasis-httpd/pgsql/app-pass password | debconf-set-selections
-
-exit 0
diff --git a/debian/anastasis-httpd.prerm b/debian/anastasis-httpd.prerm
index 24625c0..951f5ac 100644
--- a/debian/anastasis-httpd.prerm
+++ b/debian/anastasis-httpd.prerm
@@ -2,15 +2,8 @@
set -e
-if [ -f /usr/share/debconf/confmodule ]; then
- . /usr/share/debconf/confmodule
+if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
+ deb-systemd-invoke stop 'anastasis-httpd.service' >/dev/null || true
fi
-. /usr/share/dbconfig-common/dpkg/prerm
-if [ -f /usr/share/dbconfig-common/dpkg/prerm.pgsql ]; then
- . /usr/share/dbconfig-common/dpkg/prerm.pgsql
- dbc_go anastasis-httpd "$@"
-fi
-
-db_stop
exit 0
diff --git a/debian/anastasis-httpd.service b/debian/anastasis-httpd.service
index bd6919e..372e824 100644
--- a/debian/anastasis-httpd.service
+++ b/debian/anastasis-httpd.service
@@ -5,7 +5,7 @@ Description=Anastasis key recovery backend
User=anastasis-httpd
Type=simple
Restart=on-failure
-ExecStart=/usr/bin/anastasis-httpd -c /etc/anastasis/anastasis.conf
+ExecStart=/usr/bin/anastasis-httpd -c /etc/anastasis/anastasis.conf -L INFO
[Install]
WantedBy=multi-user.target
diff --git a/debian/changelog b/debian/changelog
index 374d9ac..d3231da 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,57 @@
+anastasis (0.4.1) unstable; urgency=low
+
+ * Actual v0.4.1 release.
+
+ -- Christian Grothoff <grothoff@gnu.org> Sat, 10 Feb 2024 03:50:12 +0200
+
+anastasis (0.4.0-2) unstable; urgency=low
+
+ * Updates for packaging with GNU Taler v0.9.4.
+
+ -- Christian Grothoff <grothoff@gnu.org> Sun, 21 Jan 2024 23:50:12 +0200
+
+anastasis (0.4.0-1) unstable; urgency=low
+
+ * Actual v0.4.0 release.
+
+ -- Christian Grothoff <grothoff@gnu.org> Wed, 27 Sep 2023 03:50:12 +0200
+
+anastasis (0.4.0) unstable; urgency=low
+
+ * First work towards packaging v0.4.0.
+
+ -- Christian Grothoff <grothoff@gnu.org> Thu, 7 Sep 2023 23:50:12 +0200
+
+anastasis (0.3.2) unstable; urgency=low
+
+ * Official Anastasis 0.3.2 release.
+
+ -- Christian Grothoff <grothoff@gnu.org> Tue, 21 Feb 2023 09:50:12 +0200
+
+anastasis (0.3.1) unstable; urgency=low
+
+ * Official Anastasis 0.3.1 release.
+
+ -- Christian Grothoff <grothoff@gnu.org> Tue, 17 Jan 2023 09:50:12 +0200
+
+anastasis (0.3.0) unstable; urgency=low
+
+ * Official Anastasis 0.3.0 release.
+
+ -- Christian Grothoff <grothoff@gnu.org> Mon, 26 Sep 2022 09:50:12 +0200
+
+anastasis (0.2.99-2) unstable; urgency=low
+
+ * Close to Anastasis 0.3.0, but testing package details.
+
+ -- Christian Grothoff <grothoff@gnu.org> Mon, 20 Jun 2022 14:02:10 +0100
+
+anastasis (0.2.99-1) unstable; urgency=low
+
+ * Close to Anastasis 0.3.0, but a preview release for UX testing.
+
+ -- Christian Grothoff <grothoff@gnu.org> Tue, 01 Feb 2022 14:02:10 +0100
+
anastasis (0.2.0) unstable; urgency=low
* New upstream release.
diff --git a/debian/control b/debian/control
index 0252c0d..e9e618e 100644
--- a/debian/control
+++ b/debian/control
@@ -8,19 +8,16 @@ Build-Depends:
autopoint,
debhelper-compat (= 12),
gettext,
- libgnunet-dev,
- libtalerexchange-dev (>= 0.8.5),
- libtalermerchant-dev (>= 0.8.4),
- libpq-dev (>=9.5),
+ libgnunet-dev (>=0.21),
+ libtalerexchange-dev (>= 0.9.4),
+ libtalermerchant-dev (>= 0.9.4),
+ libpq-dev (>=14),
libsqlite3-dev (>=3.8),
pkg-config,
po-debconf,
libqrencode-dev,
uuid-dev,
zlib1g-dev
-Build-Conflicts:
- autoconf2.13,
- automake1.4
Standards-Version: 4.5.0
Vcs-Git: https://salsa.debian.org/debian/anastasis.git
Vcs-browser: https://salsa.debian.org/debian/anastasis
@@ -35,44 +32,66 @@ Depends:
netbase,
${misc:Depends},
${shlibs:Depends}
-Description: libraries to talk to an Anastasis provider.
+Description: libraries to talk to a GNU Anastasis provider.
+ .
+ GNU Anastasis allows users to make backups of their
+ private key material to multiple providers while ensuring that
+ individual providers cannot learn the secret key material.
+ The libraries contained in this package implement the
+ client-side of the Anastasis backup and recovery protocol.
Package: anastasis-httpd
Architecture: any
Pre-Depends:
${misc:Pre-Depends}
Depends:
- libtalerexchange (>= 0.8.5),
+ libtalerexchange (>= 0.9.4),
libgnutls30 (>= 3.7.1),
adduser,
lsb-base,
netbase,
- apache2 | nginx | httpd,
- postgresql,
- dbconfig-pgsql | dbconfig-no-thanks,
${misc:Depends},
${shlibs:Depends}
+Recommends:
+ apache2 | nginx | httpd,
+ postgresql (>=14.0)
Description: GNU's key escrow provider.
+ .
+ GNU Anastasis allows users to make backups of their
+ private key material to multiple providers while ensuring that
+ individual providers cannot learn the secret key material.
+ This package contains the backend logic that must be run by
+ an Anastasis backup provider.
Package: anastasis-cli
Architecture: any
Pre-Depends:
${misc:Pre-Depends}
Depends:
- libanastasis (>= 0.0.0),
+ libanastasis,
${misc:Depends},
${shlibs:Depends}
-Description: Command-line interface for the Anastasis key escrow provider service.
+Description: Command-line interface for the GNU Anastasis key escrow provider service.
+ .
+ GNU Anastasis allows users to make backups of their
+ private key material to multiple providers while ensuring that
+ individual providers cannot learn the secret key material.
+ This package contains a command-line interface to the
+ Anastasis logic. Please note that we do not expect the CLI to
+ be useful to end-users. It may be useful for integration of
+ Anastasis into applications (and for testing).
+ If you are looking for a stand-alone Anastasis client, please
+ use anastasis-gtk.
Package: libanastasis-dev
Section: libdevel
Architecture: any
Depends:
- libtalermerchant-dev (>= 0.8.3),
- libtalerexchange-dev (>= 0.8.5),
- libgnunet-dev (>=0.15.3),
+ libtalermerchant-dev (>= 0.9.4),
+ libtalerexchange-dev (>= 0.9.4),
+ libgnunet-dev (>=0.21),
${misc:Depends},
${shlibs:Depends}
-Description: libraries to talk to a GNU Anastasis provider (development)
+Description: libraries to talk to a GNU Anastasis provider (development).
.
- This package contains the development files.
+ This package contains the development files for the libanastasis libraries.
diff --git a/debian/db/install/pgsql b/debian/db/install/pgsql
deleted file mode 100755
index f695fed..0000000
--- a/debian/db/install/pgsql
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-
-set -eu
-
-conf_anastasis_db=/etc/anastasis/secrets/anastasis-db.secret.conf
-conf_override=/etc/anastasis/override.conf
-
-# Get database settings from dbconfig-common and write anastasis configuration files.
-if [ -f /etc/dbconfig-common/anastasis-httpd.conf ]; then
- . /etc/dbconfig-common/anastasis-httpd.conf
- case "$dbc_dbtype" in
- pgsql)
- echo -e "# Config file auto-generated by Debian.\n[anastasis]\nDB=postgres\n\n" > \
- $conf_override
- # We assume ident auth here. We might support password auth later.
- echo -e "[stasis-postgres]\nCONFIG=postgres:///${dbc_dbname}\n\n" > \
- $conf_anastasis_db
-
- # Allow the taler-merchant-httpd user to create schemas, needed by dbinit
- echo "GRANT CREATE on database \"$dbc_dbname\" to \"anastasis-httpd\";" | sudo -u postgres psql -f -
- # Run database initialization logic
- sudo -u anastasis-httpd anastasis-dbinit -c /etc/anastasis/anastasis.conf
- ;;
- sqlite3)
- # Later: use something like:
- # sqlite:///$DATA_DIR/anastasis.db
- # But for now, sqlite is unsupported:
- echo "Unsupported database type $dbc_type."
- exit 1
- ;;
- "") ;;
-
- *)
- echo "Unsupported database type $dbc_type."
- exit 1
- ;;
- esac
-fi
diff --git a/debian/etc/anastasis/anastasis.conf b/debian/etc/anastasis/anastasis.conf
index 9938438..9b85754 100644
--- a/debian/etc/anastasis/anastasis.conf
+++ b/debian/etc/anastasis/anastasis.conf
@@ -14,7 +14,7 @@ SERVE = unix
# Name of your business
#BUSINESS_NAME = ""
-# Random server salt. Use output of 'uuidgen'
+# Random server salt. Use output of 'uuidgen'. Make a backup of the value.
#SERVER_SALT = ""
# How high is the per key share insurance offered
@@ -32,7 +32,7 @@ PAYMENT_BACKEND_URL = http://backend.demo.taler.net/instances/Tutorial/
[taler]
-# Currency accepted by anastasis via GNU Taler payments.
+# Currency accepted by GNU Anastasis via GNU Taler payments.
CURRENCY = KUDOS
[paths]
diff --git a/debian/etc/anastasis/secrets/anastasis-db.secret.conf b/debian/etc/anastasis/secrets/anastasis-db.secret.conf
index 8f9fb54..512366d 100644
--- a/debian/etc/anastasis/secrets/anastasis-db.secret.conf
+++ b/debian/etc/anastasis/secrets/anastasis-db.secret.conf
@@ -1,3 +1,3 @@
[stasis-postgres]
#The connection string the plugin has to use for connecting to the database
-CONFIG = postgres:///anastasis
+# CONFIG = postgres:///anastasis
diff --git a/debian/rules b/debian/rules
index 0307145..3a1911d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,9 @@ include /usr/share/dpkg/architecture.mk
%:
dh ${@}
+override_dh_builddeb:
+ dh_builddeb -- -Zgzip
+
override_dh_auto_configure-arch:
dh_auto_configure -- --disable-rpath --with-microhttpd=yes $(shell dpkg-buildflags --export=configure)
@@ -30,6 +33,11 @@ override_dh_auto_install-indep:
override_dh_auto_clean:
dh_auto_clean
+override_dh_installsystemd:
+ dh_installsystemd -panastasis-httpd --name=anastasis-httpd --no-start --no-enable
+ # final invocation to generate daemon reload
+ dh_installsystemd
+
override_dh_install:
dh_install
# Done manually for debhelper-compat<13
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 1bdb6d1..aa8ee42 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -3,6 +3,8 @@
# SUBDIRS = . doxygen
man_MANS = \
+ anastasis-dbconfig.1 \
+ anastasis-dbinit.1 \
anastasis-httpd.1 \
anastasis-helper-authorization-iban.1 \
anastasis-reducer.1 \
diff --git a/doc/anastasis-dbconfig.1 b/doc/anastasis-dbconfig.1
new file mode 100644
index 0000000..a739c7d
--- /dev/null
+++ b/doc/anastasis-dbconfig.1
@@ -0,0 +1,87 @@
+.\" Man page generated from reStructuredText.
+.
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.TH "ANASTASIS-DBCONFIG" "1" "Sep 08, 2023" "0.0" "Anastasis"
+.SH NAME
+anastasis-dbconfig \- configure Anastasis database
+.SH SYNOPSIS
+.sp
+\fBanastasis\-dbconfig\fP
+[\fB\-c\fP\ \fIFILENAME\fP\ \fI]
+[*\fP\-h**]
+[\fB\-n\fP\ \fINAME\fP\ \fI]
+[*\fP\-r**]
+[\fB\-s\fP]
+[\fB\-u\fP\ \fIUSER\fP\
+.nf
+*
+.fi
+]
+.SH DESCRIPTION
+.sp
+\fBanastasis\-dbconfig\fP is a simple shell script that configures
+a Postgresql database for use by the GNU Anastasis servers.
+.sp
+Its options are as follows:
+.INDENT 0.0
+.TP
+\fB\-c\fP \fIFILENAME\fP
+Write the database configuration to FILENAME. The tool
+will append the required \fBCONFIG\fP option for the
+Postgresql access to the respective file.
+.TP
+\fB\-h\fP
+Print short help on options.
+.TP
+\fB\-n\fP \fIDBNAME\fP
+Use DBNAME for the name of the created database.
+.TP
+\fB\-r\fP
+Reset any existing database. Looses all existing data. DANGEROUS.
+.TP
+\fB\-s\fP
+Skip database initialization. Useful if you want to run
+\fBanastasis\-dbinit\fP manually.
+.TP
+\fB\-u\fP \fIUSER\fP
+Specifies the (main) Anastasis user that will access the database.
+.UNINDENT
+.SH SEE ALSO
+.sp
+anastassis\-dbinit(1), anastasis.conf(5).
+.SH BUGS
+.sp
+Report bugs by using \fI\%https://bugs.taler.net\fP or by sending electronic
+mail to <\fI\%taler@gnu.org\fP>.
+.SH AUTHOR
+Anastasis SARL
+.SH COPYRIGHT
+2020-2021 Anastasis SARL (AGPLv3+ or GFDL 1.3+)
+.\" Generated by docutils manpage writer.
+.
diff --git a/doc/anastasis-dbinit.1 b/doc/anastasis-dbinit.1
new file mode 100644
index 0000000..9791f08
--- /dev/null
+++ b/doc/anastasis-dbinit.1
@@ -0,0 +1,89 @@
+.\" Man page generated from reStructuredText.
+.
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.TH "ANASTASIS-DBINIT" "1" "Sep 08, 2023" "0.0" "Anastasis"
+.SH NAME
+anastasis-dbinit \- initialize Anastasis database
+.SH SYNOPSIS
+.sp
+\fBanastasis\-dbinit\fP
+[\fB\-c\fP\ \fIFILENAME\fP\ |\ \fB\-\-config=\fP‌\fIFILENAME\fP]
+[\fB\-g\fP\ |\ \fB\-\-gc\fP]
+[\fB\-h\fP\ |\ \fB\-\-help\fP]
+[\fB\-L\fP\ \fILOGLEVEL\fP\ |\ \fB\-\-loglevel=\fP‌\fILOGLEVEL\fP]
+[\fB\-l\fP\ \fIFILENAME\fP\ |\ \fB\-\-logfile=\fP‌\fIFILENAME\fP]
+[\fB\-r\fP\ |\ \fB\-\-reset\fP]
+[\fB\-v\fP\ |\ \fB\-\-version\fP]
+.SH DESCRIPTION
+.sp
+\fBanastasis\-dbinit\fP is a command\-line tool to initialize the GNU
+Anastasis database. It creates the necessary tables and indices for
+an Anastasis server to operate.
+.sp
+Its options are as follows:
+.INDENT 0.0
+.TP
+\fB\-c\fP \fIFILENAME\fP | \fB\-\-config=\fP‌\fIFILENAME\fP
+Use the configuration and other resources for the exchange to operate
+from \fIFILENAME\fP\&.
+.TP
+\fB\-g\fP | \fB\-\-gc\fP
+Garbage collect database. Deletes all unnecessary data in the
+database.
+.TP
+\fB\-h\fP | \fB\-\-help\fP
+Print short help on options.
+.TP
+\fB\-L\fP \fILOGLEVEL\fP | \fB\-\-loglevel=\fP‌\fILOGLEVEL\fP
+Specifies the log level to use. Accepted values are: \fBDEBUG\fP, \fBINFO\fP,
+\fBWARNING\fP, \fBERROR\fP\&.
+.TP
+\fB\-l\fP \fIFILENAME\fP | \fB\-\-logfile=\fP‌\fIFILENAME\fP
+Send logging output to \fIFILENAME\fP\&.
+.TP
+\fB\-r\fP | \fB\-\-reset\fP
+Drop tables. Dangerous, will delete all existing data in the database
+before creating the tables.
+.TP
+\fB\-v\fP | \fB–version\fP
+Print version information.
+.UNINDENT
+.SH SEE ALSO
+.sp
+anastasis\-httpd(1), anastasis.conf(5).
+.SH BUGS
+.sp
+Report bugs by using \fI\%https://bugs.taler.net\fP or by sending electronic
+mail to <\fI\%taler@gnu.org\fP>.
+.SH AUTHOR
+Anastasis SARL
+.SH COPYRIGHT
+2020-2021 Anastasis SARL (AGPLv3+ or GFDL 1.3+)
+.\" Generated by docutils manpage writer.
+.
diff --git a/doc/anastasis.texi b/doc/anastasis.texi
index d0f281a..8ac8263 100644
--- a/doc/anastasis.texi
+++ b/doc/anastasis.texi
@@ -3,7 +3,7 @@
@setfilename anastasis.info
@documentencoding UTF-8
@ifinfo
-@*Generated by Sphinx 3.4.3.@*
+@*Generated by Sphinx 4.3.2.@*
@end ifinfo
@settitle Anastasis Manual
@defindex ge
@@ -21,7 +21,7 @@
@copying
@quotation
-Anastasis 0.0.0pre0, Aug 14, 2021
+Anastasis 0.0.0pre0, Aug 12, 2023
Anastasis SARL
@@ -64,7 +64,7 @@ Copyright @copyright{} 2020-2021 Anastasis SARL (AGPLv3+ or GFDL 1.3+)
@c
@c @author Christian Grothoff
-Anastasis is Free Software protocol and implementation that allows
+Anastasis is a Free Software protocol and implementation that allows
users to securely deposit @strong{core secrets} with an open set of escrow
providers and to recover these secrets if their original copies are
lost.
@@ -148,6 +148,16 @@ Configuration
* Configuration format::
* Using anastasis-config::
+* Terms of Service::
+* Privacy Policy::
+* Legal policies directory layout::
+* Generating the Legal Terms::
+* Adding translations::
+* Updating legal documents::
+
+Legal policies directory layout
+
+* Example::
Cryptography
@@ -170,6 +180,10 @@ REST API
* HTTP Request and Response::
* Protocol Version Ranges::
* Common encodings::
+* Receiving Configuration::
+* Receiving Terms of Service::
+* Managing policy::
+* Managing truth::
Common encodings
@@ -185,10 +199,6 @@ Common encodings
* Time::
* Cryptographic primitives::
* Signatures: Signatures<3>.
-* Receiving Configuration::
-* Receiving Terms of Service::
-* Manage policy::
-* Managing truth::
Reducer API
@@ -229,7 +239,10 @@ Anastasis-gtk (git://git.taler.net/anastasis-gtk)
Man Pages
* anastasis-config(1): anastasis-config 1.
+* anastasis-dbconfig(1): anastasis-dbconfig 1.
+* anastasis-dbinit(1): anastasis-dbinit 1.
* anastasis-gtk(1): anastasis-gtk 1.
+* anastasis-helper-authorization-iban(1): anastasis-helper-authorization-iban 1.
* anastasis-httpd(1): anastasis-httpd 1.
* anastasis-reducer(1): anastasis-reducer 1.
* anastasis.conf(5): anastasis conf 5.
@@ -241,40 +254,69 @@ anastasis-config(1)
* See Also::
* Bugs::
-anastasis-gtk(1)
+anastasis-dbconfig(1)
* Synopsis: Synopsis<2>.
* Description: Description<2>.
* See Also: See Also<2>.
* Bugs: Bugs<2>.
-anastasis-httpd(1)
+anastasis-dbinit(1)
* Synopsis: Synopsis<3>.
* Description: Description<3>.
-* Signals::
-* See also::
+* See Also: See Also<3>.
* Bugs: Bugs<3>.
-anastasis-reducer(1)
+anastasis-gtk(1)
* Synopsis: Synopsis<4>.
* Description: Description<4>.
-* See Also: See Also<3>.
+* See Also: See Also<4>.
* Bugs: Bugs<4>.
-anastasis.conf(5)
+anastasis-helper-authorization-iban(1)
+* Synopsis: Synopsis<5>.
* Description: Description<5>.
+* See Also: See Also<5>.
+* Bugs: Bugs<5>.
+
+anastasis-httpd(1)
+
+* Synopsis: Synopsis<6>.
+* Description: Description<6>.
+* Signals::
+* See also::
+* Bugs: Bugs<6>.
+
+anastasis-reducer(1)
+
+* Synopsis: Synopsis<7>.
+* Description: Description<7>.
+* See Also: See Also<6>.
+* Bugs: Bugs<7>.
+
+anastasis.conf(5)
+
+* Description: Description<8>.
* SEE ALSO::
* BUGS::
Description
* GLOBAL OPTIONS::
+* Backend options::
* Authorization options::
* Postgres database configuration::
+Authorization options
+
+* SMS Authorization options::
+* Email Authorization options::
+* Post Authorization options::
+* IBAN Authorization options::
+
GNU Free Documentation License
* 0. PREAMBLE: 0 PREAMBLE.
@@ -430,6 +472,20 @@ network traffic).
@section Installation
+@cartouche
+@quotation Note
+Currently, GNU Anastasis is released as alpha-quality software.
+When testing Anastasis, please choose @code{demoland} as
+your country of residence!
+@strong{It is not yet production ready! You cannot rely on it to keep
+your secrets recoverable today!} In particular, we need to
+still review the various country-specific questions used to create
+unique user identifiers at the beginning of the backup and
+recovery process. Community feedback on those inputs would be
+particularly welcome!
+@end quotation
+@end cartouche
+
Please install the following packages before proceeding with the
exchange compilation.
@@ -712,47 +768,14 @@ find the installed libraries and launching anastasis-gtk would then fail.
To install the GNU Taler Debian packages, first ensure that you have
the right Debian distribution. At this time, the packages are built for
-Sid, which means you should use a system which at least includes
-unstable packages in its source list. We recommend using APT pinning
-to limit unstable packages to those explicitly requested. To do this,
-set your @code{/etc/apt/preferences} as follows:
+Bullseye.
-@example
-Package: *
-Pin: release a=stable
-Pin-Priority: 700
-
-Package: *
-Pin: release a=testing
-Pin-Priority: 650
-
-Package: *
-Pin: release a=unstable
-Pin-Priority: 600
-
-Package: *
-Pin: release l=Debian-Security
-Pin-Priority: 1000
-@end example
-
-A typical @code{/etc/apt/sources.list} file for this setup
-which combines Debian stable with more recent packages
-from testing and unstable would look like this:
-
-@example
-deb http://ftp.ch.debian.org/debian/ buster main
-deb http://security.debian.org/debian-security buster/updates main
-deb http://ftp.ch.debian.org/debian/ testing main
-deb http://ftp.ch.debian.org/debian/ unstable main
-@end example
-
-Naturally, you may want to use different mirrors depending on your region.
-Additionally, you must add a file to import the GNU Taler packages. Typically,
+You need to add a file to import the GNU Taler packages. Typically,
this is done by adding a file @code{/etc/apt/sources.list.d/taler.list} that
looks like this:
@example
-deb https://deb.taler.net/apt/debian sid main
+deb https://deb.taler.net/apt/debian bullseye main
@end example
Next, you must import the Taler Systems SA public package signing key
@@ -944,6 +967,12 @@ configuration format.
@menu
* Configuration format::
* Using anastasis-config::
+* Terms of Service::
+* Privacy Policy::
+* Legal policies directory layout::
+* Generating the Legal Terms::
+* Adding translations::
+* Updating legal documents::
@end menu
@@ -1010,19 +1039,10 @@ Note that, in this stage of development, the file
component. For example, both an exchange and a bank can read values from
it.
-The repository @code{git://taler.net/deployment} contains examples of
+The repository @code{git://git.taler.net/deployment} contains examples of
configuration file used in our demos. See under @code{deployment/config}.
-@quotation
-
-@strong{Note}
-
-Expectably, some components will not work just by using default
-values, as their work is often interdependent. For example, a
-merchant needs to know an exchange URL, or a database name.
-@end quotation
-
-@node Using anastasis-config,,Configuration format,Configuration
+@node Using anastasis-config,Terms of Service,Configuration format,Configuration
@anchor{configuration using-anastasis-config}@anchor{1a}
@subsection Using anastasis-config
@@ -1075,6 +1095,240 @@ While the configuration file is typically located at
to @code{taler-merchant-httpd} and @code{anastasis-config} using the @code{-c}
option.
+@c This file is part of GNU TALER.
+@c
+@c Copyright (C) 2014-2023 Taler Systems SA
+@c
+@c TALER is free software; you can redistribute it and/or modify it under the
+@c terms of the GNU Affero General Public License as published by the Free Software
+@c Foundation; either version 2.1, or (at your option) any later version.
+@c
+@c TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+@c WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+@c A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+@c
+@c You should have received a copy of the GNU Affero General Public License along with
+@c TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+@c
+@c @author Christian Grothoff
+
+The service has well-known API endpoints to return its legal conditions to the
+user in various languages and various formats. This section describes how to
+setup and configure the legal conditions.
+
+@node Terms of Service,Privacy Policy,Using anastasis-config,Configuration
+@anchor{configuration terms-of-service}@anchor{1b}
+@subsection Terms of Service
+
+
+The service has an endpoint “/terms†to return the terms of service (in legal
+language) of the service operator. Client software show these terms of
+service to the user when the user is first interacting with the service.
+Terms of service are optional for experimental deployments, if none are
+configured, the service will return a simple statement saying that there are
+no terms of service available.
+
+To configure the terms of service response, there are two options
+in the configuration file for the service:
+
+
+@itemize -
+
+@item
+@code{TERMS_ETAG}: The current “Etag†to return for the terms of service.
+This value must be changed whenever the terms of service are
+updated. A common value to use would be a version number.
+Note that if you change the @code{TERMS_ETAG}, you MUST also provide
+the respective files in @code{TERMS_DIR} (see below).
+
+@item
+@code{TERMS_DIR}: The directory that contains the terms of service.
+The files in the directory must be readable to the service
+process.
+@end itemize
+
+@node Privacy Policy,Legal policies directory layout,Terms of Service,Configuration
+@anchor{configuration privacy-policy}@anchor{1c}
+@subsection Privacy Policy
+
+
+The service has an endpoint “/pp†to return the terms privacy policy (in legal
+language) of the service operator. Clients should show the privacy policy to
+the user when the user explicitly asks for it, but it should not be shown by
+default. Privacy policies are optional for experimental deployments, if none
+are configured, the service will return a simple statement saying that there
+is no privacy policy available.
+
+To configure the privacy policy response, there are two options
+in the configuration file for the service:
+
+
+@itemize -
+
+@item
+@code{PRIVACY_ETAG}: The current “Etag†to return for the privacy policy.
+This value must be changed whenever the privacy policy is
+updated. A common value to use would be a version number.
+Note that if you change the @code{PRIVACY_ETAG}, you MUST also provide
+the respective files in @code{PRIVACY_DIR} (see below).
+
+@item
+@code{PRIVACY_DIR}: The directory that contains the privacy policy.
+The files in the directory must be readable to the service
+process.
+@end itemize
+
+@node Legal policies directory layout,Generating the Legal Terms,Privacy Policy,Configuration
+@anchor{configuration legal-policies-directory-layout}@anchor{1d}
+@subsection Legal policies directory layout
+
+
+The @code{TERMS_DIR} and @code{PRIVACY_DIR} directory structures must follow a
+particular layout. You may use the same directory for both the terms of
+service and the privacy policy, as long as you use different ETAGs. Inside of
+the directory, there should be sub-directories using two-letter language codes
+like “enâ€, “deâ€, or “jpâ€. Each of these directories would then hold
+translations of the current terms of service into the respective language.
+Empty directories are permitted in case translations are not available.
+
+Then, inside each language directory, files with the name of the value set as
+the @code{TERMS_ETAG} or @code{PRIVACY_ETAG} must be provided. The extension of each
+of the files should be typical for the respective mime type. The set of
+supported mime types is currently hard-coded in the service, and includes
+“.epubâ€, “.htmlâ€, “.mdâ€, “.pdf†and “.txt†files. If other files are present,
+the service may show a warning on startup.
+
+@menu
+* Example::
+
+@end menu
+
+@node Example,,,Legal policies directory layout
+@anchor{configuration example}@anchor{1e}
+@subsubsection Example
+
+
+A sample file structure for a @code{TERMS_ETAG} of “tos-v0†would be:
+
+
+@itemize -
+
+@item
+TERMS_DIR/en/tos-v0.txt
+
+@item
+TERMS_DIR/en/tos-v0.html
+
+@item
+TERMS_DIR/en/tos-v0.pdf
+
+@item
+TERMS_DIR/en/tos-v0.epub
+
+@item
+TERMS_DIR/en/tos-v0.md
+
+@item
+TERMS_DIR/de/tos-v0.txt
+
+@item
+TERMS_DIR/de/tos-v0.html
+
+@item
+TERMS_DIR/de/tos-v0.pdf
+
+@item
+TERMS_DIR/de/tos-v0.epub
+
+@item
+TERMS_DIR/de/tos-v0.md
+@end itemize
+
+If the user requests an HTML format with language preferences “fr†followed by
+“enâ€, the service would return @code{TERMS_DIR/en/tos-v0.html} lacking a version in
+French.
+
+@node Generating the Legal Terms,Adding translations,Legal policies directory layout,Configuration
+@anchor{configuration generating-the-legal-terms}@anchor{1f}
+@subsection Generating the Legal Terms
+
+
+The @code{taler-terms-generator} script can be used to generate directories with
+terms of service and privacy policies in multiple languages and all required
+data formats from a single source file in @code{.rst} format and GNU gettext
+translations in @code{.po} format.
+
+To use the tool, you need to first write your legal conditions in English in
+reStructuredText (rst). You should find a templates in
+@code{$PREFIX/share/terms/*.rst} where @code{$PREFIX} is the location where you
+installed the service to. Whenever you make substantive changes to the legal
+terms, you must use a fresh filename and change the respective @code{ETAG}. The
+resulting file must be called @code{$ETAG.rst} and the first line of the file should be the title of the document.
+
+Once you have written the @code{$ETAG.rst} file in English, you can
+generate the first set of outputs:
+
+@example
+$ taler-terms-generator -i $ETAG
+@end example
+
+Afterwards, you should find the terms in various formats for all configured
+languages (initially only English) in @code{$PREFIX/share/terms/}. The generator
+has a few options which are documented in its man page.
+
+@node Adding translations,Updating legal documents,Generating the Legal Terms,Configuration
+@anchor{configuration adding-translations}@anchor{20}
+@subsection Adding translations
+
+
+Translations must be available in subdirectories
+@code{locale/$LANGUAGE/LC_MESSAGES/$ETAG.po}.
+To start translating, you first need to add a new
+language:
+
+@example
+$ taler-terms-generator -i $ETAG -l $LANGUAGE
+@end example
+
+Here, @code{$LANGUAGE} should be a two-letter language
+code like @code{de} or @code{fr}. The command will generate
+a file @code{locale/$LANGUAGE/LC_MESSAGES/$ETAG.po}
+which contains each English sentence or paragraph
+in the original document and an initially empty
+translation. Translators should update the @code{.po}
+file. Afterwards, simply re-run
+
+@example
+$ taler-terms-generator -i $ETAG
+@end example
+
+to make the current translation(s) available to the
+service.
+
+@cartouche
+@quotation Note
+You must restart the service whenever adding or updating legal documents or their translations.
+@end quotation
+@end cartouche
+
+@node Updating legal documents,,Adding translations,Configuration
+@anchor{configuration updating-legal-documents}@anchor{21}
+@subsection Updating legal documents
+
+
+When making minor changes without legal implications, edit the @code{.rst} file,
+then re-run the step to add a new language for each existing translation to
+produce an updated @code{.po} file. Translate the sentences that have changed and
+finally run the generator (without @code{-l}) on the ETAG (@code{-i $ETAG}) to
+create the final files.
+
+When making major changes with legal implications, you should first rename (or
+copy) the existing @code{.rst} file and the associated translation files to a new
+unique name. Afterwards, make the major changes, update the @code{.po} files,
+complete the translations and re-create the final files. Finally, do not
+forget to update the @code{ETAG} configuration option to the new name and to
+restart the service.
+
@c This file is part of Anastasis
@c Copyright (C) 2019-2021 Anastasis SARL
@c
@@ -1094,7 +1348,7 @@ option.
@c @author Dennis Neufeld
@node Cryptography,REST API,Configuration,Documentation Overview
-@anchor{cryptography doc}@anchor{1b}@anchor{cryptography cryptography}@anchor{1c}
+@anchor{cryptography doc}@anchor{22}@anchor{cryptography cryptography}@anchor{23}
@section Cryptography
@@ -1141,7 +1395,7 @@ encrypted @strong{core secret}, a set of escrow methods and a set of policies.
@end menu
@node Key derivations,Key Usage,,Cryptography
-@anchor{cryptography key-derivations}@anchor{1d}
+@anchor{cryptography key-derivations}@anchor{24}
@subsection Key derivations
@@ -1184,7 +1438,7 @@ kdf_id := Argon2( identifier, server_salt, keysize )
@end menu
@node Verification,Encryption,,Key derivations
-@anchor{cryptography verification}@anchor{1e}
+@anchor{cryptography verification}@anchor{25}
@subsubsection Verification
@@ -1204,7 +1458,7 @@ HKDF to ensure that the result differs from other cases where we hash
@example
ver_secret := HKDF(kdf_id, "ver", keysize)
-eddsa_priv := eddsa_d_to_a(ver_secret)
+eddsa_priv := ver_secret
eddsa_pub := get_EdDSA_Pub(eddsa_priv)
@end example
@@ -1216,19 +1470,12 @@ eddsa_pub := get_EdDSA_Pub(eddsa_priv)
@strong{ver_secret}: Derived key from the @code{kdf_id}, serves as intermediate step for the generation of the private key.
-@strong{eddsa_d_to_a()}: Function which converts the ver_key to a valid EdDSA private key. Specifically, assuming the value @code{eddsa_priv} is in a 32-byte array “digestâ€, the function clears and sets certain bits as follows:
-
-@example
-digest[0] = (digest[0] & 0x7f) | 0x40;
-digest[31] &= 0xf8;
-@end example
-
@strong{eddsa_priv}: The generated EdDSA private key.
@strong{eddsa_pub}: The generated EdDSA public key.
@node Encryption,,Verification,Key derivations
-@anchor{cryptography encryption}@anchor{1f}
+@anchor{cryptography encryption}@anchor{26}
@subsubsection Encryption
@@ -1259,7 +1506,7 @@ avoid key reuse. So, we have to use different nonces to get different keys and I
@strong{iv}: IV which will be used for AES-GCM.
@node Key Usage,Availability Considerations,Key derivations,Cryptography
-@anchor{cryptography key-usage}@anchor{20}
+@anchor{cryptography key-usage}@anchor{27}
@subsection Key Usage
@@ -1273,7 +1520,7 @@ the @strong{key_share} of the user.
@end menu
@node Encryption<2>,Signatures,,Key Usage
-@anchor{cryptography id1}@anchor{21}
+@anchor{cryptography id1}@anchor{28}
@subsubsection Encryption
@@ -1295,7 +1542,7 @@ individual @strong{key share}, we use different salts (“erd†and “eksâ€,
and the encrypted @strong{core secret}.
@strong{nonce0}: Nonce which is used to generate @emph{key0} and @emph{iv0} which are used for the encryption of the @emph{recovery document}.
-Nonce must contain the string “ERDâ€.
+This key derivation must be done using the salt “erdâ€.
@strong{optional data}: Key material that optionally is contributed from the authentication method to further obfuscate the key share from the escrow provider.
@@ -1304,7 +1551,8 @@ Here, @strong{i} must be a positive number used to iterate over the various @str
at the various providers.
@strong{nonce_i}: Nonce which is used to generate @emph{key_i} and @emph{iv_i} which are used for the encryption of the @strong{key share}. @strong{i} must be
-the same number as specified above for @emph{encrypted_key_share_i}. Nonce must contain the string “EKS†plus the according @emph{i}.
+the same number as specified above for @emph{encrypted_key_share_i}.
+Key derivation must be done using the salt “eksâ€.
As a special rule, when a @strong{security question} is used to authorize access to an
@strong{encrypted_key_share_i}, then the salt “eks†is replaced with an (expensive) hash
@@ -1330,12 +1578,14 @@ ekss := HKDF("Anastasis-secure-question-uuid-salting",
@strong{ekss}: Replacement salt to be used instead of “eks†when deriving the key to encrypt/decrypt the key share.
@node Signatures,,Encryption<2>,Key Usage
-@anchor{cryptography signatures}@anchor{22}
+@anchor{cryptography signatures}@anchor{29}
@subsubsection Signatures
The EdDSA keys are used to sign the data sent from the client to the
-server. Everything the client sends to server is signed. The following
+server. This signature ensures that an adversary that observes the upload is not
+able to upload a new version of the policy without knowing the user’s identity attributes.
+The signature is made over a hash of the request body. The following
algorithm is equivalent for @strong{Anastasis-Policy-Signature}.
@example
@@ -1349,21 +1599,8 @@ ver_res := eddsa_verifiy(h_body, anastasis-account-signature, eddsa_pub)
@strong{ver_res}: A boolean value. True: Signature verification passed, False: Signature verification failed.
-When requesting policy downloads, the client must also provide a signature:
-
-@example
-(anastasis-account-signature) := eddsa_sign(version, eddsa_priv)
-ver_res := eddsa_verifiy(version, anastasis-account-signature, eddsa_pub)
-@end example
-
-@strong{anastasis-account-signature}: Signature over the SHA-512 hash of the body using the purpose code @code{TALER_SIGNATURE_ANASTASIS_POLICY_DOWNLOAD} (1401) (see GNUnet EdDSA signature API for the use of purpose).
-
-@strong{version}: The version requested as a 64-bit integer, 2^64-1 for the “latest versionâ€.
-
-@strong{ver_res}: A boolean value. True: Signature verification passed, False: Signature verification failed.
-
@node Availability Considerations,,Key Usage,Cryptography
-@anchor{cryptography availability-considerations}@anchor{23}
+@anchor{cryptography availability-considerations}@anchor{2a}
@subsection Availability Considerations
@@ -1393,7 +1630,7 @@ from using the append-only policy storage from exhausting Anastasis server
capacity.
@c This file is part of Anastasis
-@c Copyright (C) 2019-2021 Anastasis SARL
+@c Copyright (C) 2019-2022 Anastasis SARL
@c
@c Anastasis is free software; you can redistribute it and/or modify it under the
@c terms of the GNU Affero General Public License as published by the Free Software
@@ -1411,7 +1648,7 @@ capacity.
@c @author Dennis Neufeld
@node REST API,Reducer API,Cryptography,Documentation Overview
-@anchor{rest doc}@anchor{24}@anchor{rest rest-api}@anchor{25}
+@anchor{rest doc}@anchor{2b}@anchor{rest rest-api}@anchor{2c}
@section REST API
@@ -1436,11 +1673,15 @@ capacity.
* HTTP Request and Response::
* Protocol Version Ranges::
* Common encodings::
+* Receiving Configuration::
+* Receiving Terms of Service::
+* Managing policy::
+* Managing truth::
@end menu
@node HTTP Request and Response,Protocol Version Ranges,,REST API
-@anchor{rest http-common}@anchor{26}@anchor{rest http-request-and-response}@anchor{27}
+@anchor{rest http-common}@anchor{2d}@anchor{rest http-request-and-response}@anchor{2e}
@subsection HTTP Request and Response
@@ -1450,7 +1691,7 @@ theoretically fail to receive any response. In this case, the client should
verify that the Internet connection is working properly, and then proceed to
handle the error as if an internal error (500) had been returned.
-@anchor{rest any--*}@anchor{28}
+@anchor{rest any--*}@anchor{2f}
@deffn {HTTP Any} ANY /*
@strong{Request:}
@@ -1505,7 +1746,7 @@ within 24h.
@end table
Unless specified otherwise, all error status codes (4xx and 5xx) have a message
-body with an @ref{29,,ErrorDetail} JSON object.
+body with an @ref{30,,ErrorDetail} JSON object.
@strong{Details:}
@@ -1525,7 +1766,7 @@ interface ErrorDetail @{
@end deffn
@node Protocol Version Ranges,Common encodings,HTTP Request and Response,REST API
-@anchor{rest protocol-version-ranges}@anchor{2a}
+@anchor{rest protocol-version-ranges}@anchor{31}
@subsection Protocol Version Ranges
@@ -1609,8 +1850,8 @@ to decide whether it will talk to the service.
@end quotation
@end cartouche
-@node Common encodings,,Protocol Version Ranges,REST API
-@anchor{rest common-encodings}@anchor{2b}@anchor{rest encodings-ref}@anchor{2c}
+@node Common encodings,Receiving Configuration,Protocol Version Ranges,REST API
+@anchor{rest common-encodings}@anchor{32}@anchor{rest encodings-ref}@anchor{33}
@subsection Common encodings
@@ -1629,15 +1870,11 @@ This section describes how certain types of values are represented throughout th
* Time::
* Cryptographic primitives::
* Signatures: Signatures<3>.
-* Receiving Configuration::
-* Receiving Terms of Service::
-* Manage policy::
-* Managing truth::
@end menu
@node Binary Data,Hash codes,,Common encodings
-@anchor{rest base32}@anchor{2d}@anchor{rest binary-data}@anchor{2e}
+@anchor{rest base32}@anchor{34}@anchor{rest binary-data}@anchor{35}
@subsubsection Binary Data
@@ -1652,12 +1889,12 @@ type “base32†and the term “Crockford Base32†in the text to refer to th
resulting encoding.
@node Hash codes,Large numbers,Binary Data,Common encodings
-@anchor{rest hash-codes}@anchor{2f}
+@anchor{rest hash-codes}@anchor{36}
@subsubsection Hash codes
Hash codes are strings representing base32 encoding of the respective
-hashed data. See @ref{2d,,base32}.
+hashed data. See @ref{34,,base32}.
@example
// 64-byte hash code.
@@ -1670,7 +1907,7 @@ type ShortHashCode = string;
@end example
@node Large numbers,Timestamps,Hash codes,Common encodings
-@anchor{rest large-numbers}@anchor{30}
+@anchor{rest large-numbers}@anchor{37}
@subsubsection Large numbers
@@ -1678,7 +1915,7 @@ Large numbers such as 256 bit keys, are transmitted as other binary data in
Crockford Base32 encoding.
@node Timestamps,Integers,Large numbers,Common encodings
-@anchor{rest timestamps}@anchor{31}
+@anchor{rest timestamps}@anchor{38}
@subsubsection Timestamps
@@ -1702,7 +1939,7 @@ interface Duration @{
@end example
@node Integers,Objects,Timestamps,Common encodings
-@anchor{rest integers}@anchor{32}@anchor{rest publickey}@anchor{33}
+@anchor{rest integers}@anchor{39}@anchor{rest publickey}@anchor{3a}
@subsubsection Integers
@@ -1712,7 +1949,7 @@ type Integer = number;
@end example
@node Objects,Keys,Integers,Common encodings
-@anchor{rest objects}@anchor{34}
+@anchor{rest objects}@anchor{3b}
@subsubsection Objects
@@ -1722,7 +1959,7 @@ type Object = object;
@end example
@node Keys,Signatures<2>,Objects,Common encodings
-@anchor{rest keys}@anchor{35}
+@anchor{rest keys}@anchor{3c}
@subsubsection Keys
@@ -1741,7 +1978,7 @@ type EddsaPrivateKey = string;
@end example
@node Signatures<2>,Amounts,Keys,Common encodings
-@anchor{rest signature}@anchor{36}@anchor{rest signatures}@anchor{37}
+@anchor{rest signature}@anchor{3d}@anchor{rest signatures}@anchor{3e}
@subsubsection Signatures
@@ -1752,7 +1989,7 @@ type EddsaSignature = string;
@end example
@node Amounts,Time,Signatures<2>,Common encodings
-@anchor{rest amount}@anchor{38}@anchor{rest amounts}@anchor{39}
+@anchor{rest amount}@anchor{3f}@anchor{rest amounts}@anchor{40}
@subsubsection Amounts
@@ -1791,7 +2028,7 @@ An amount that is prefixed with a @code{+} or @code{-} character is also used in
When no sign is present, the amount is assumed to be positive.
@node Time,Cryptographic primitives,Amounts,Common encodings
-@anchor{rest time}@anchor{3a}
+@anchor{rest time}@anchor{41}
@subsubsection Time
@@ -1805,10 +2042,18 @@ struct GNUNET_TIME_Absolute @{
struct GNUNET_TIME_AbsoluteNBO @{
uint64_t abs_value_us__; // in network byte order
@};
+struct GNUNET_TIME_Timestamp @{
+ // must be round value (multiple of seconds)
+ struct GNUNET_TIME_Absolute abs_time;
+@};
+struct GNUNET_TIME_TimestampNBO @{
+ // must be round value (multiple of seconds)
+ struct GNUNET_TIME_AbsoluteNBO abs_time;
+@};
@end example
@node Cryptographic primitives,Signatures<3>,Time,Common encodings
-@anchor{rest cryptographic-primitives}@anchor{3b}
+@anchor{rest cryptographic-primitives}@anchor{42}
@subsubsection Cryptographic primitives
@@ -1821,12 +2066,18 @@ struct GNUNET_HashCode @{
uint8_t hash[64]; // usually SHA-512
@};
@end example
-@anchor{rest taler-ecdhephemeralpublickeyp}@anchor{3c}
+@anchor{rest taler-ecdhephemeralpublickeyp}@anchor{43}
@example
struct TALER_EcdhEphemeralPublicKeyP @{
uint8_t ecdh_pub[32];
@};
@end example
+@anchor{rest anastasis-truthkeyp}@anchor{44}
+@example
+struct ANASTASIS_TruthKeyP @{
+ struct GNUNET_HashCode key;
+@};
+@end example
@example
struct UUID @{
@@ -1834,8 +2085,8 @@ struct UUID @{
@};
@end example
-@node Signatures<3>,Receiving Configuration,Cryptographic primitives,Common encodings
-@anchor{rest id1}@anchor{3d}@anchor{rest id2}@anchor{3e}
+@node Signatures<3>,,Cryptographic primitives,Common encodings
+@anchor{rest id1}@anchor{45}@anchor{rest id2}@anchor{46}
@subsubsection Signatures
@@ -1869,21 +2120,21 @@ struct GNUNET_CRYPTO_EccSignaturePurpose @{
uint32_t size;
@};
@end example
-@anchor{rest salt}@anchor{3f}
-@node Receiving Configuration,Receiving Terms of Service,Signatures<3>,Common encodings
-@anchor{rest config}@anchor{40}@anchor{rest receiving-configuration}@anchor{41}
-@subsubsection Receiving Configuration
+@anchor{rest salt}@anchor{47}
+@node Receiving Configuration,Receiving Terms of Service,Common encodings,REST API
+@anchor{rest config}@anchor{48}@anchor{rest receiving-configuration}@anchor{49}
+@subsection Receiving Configuration
-@anchor{rest get--config}@anchor{42}
+@anchor{rest get--config}@anchor{4a}
@deffn {HTTP Get} GET /config
Obtain the configuration details of the escrow provider.
@strong{Response:}
-Returns an @ref{43,,EscrowConfigurationResponse}.
-@anchor{rest escrowconfigurationresponse}@anchor{43}
+Returns an @ref{4b,,EscrowConfigurationResponse}.
+@anchor{rest escrowconfigurationresponse}@anchor{4b}
@example
interface EscrowConfigurationResponse @{
@@ -1921,11 +2172,11 @@ interface EscrowConfigurationResponse @{
// **provider salt** is then used in various operations to ensure
// cryptographic operations differ by provider. A provider must
// never change its salt value.
- server_salt: string;
+ provider_salt: string;
@}
@end example
-@anchor{rest authorizationmethodconfig}@anchor{44}
+@anchor{rest authorizationmethodconfig}@anchor{4c}
@example
interface AuthorizationMethodConfig @{
// Name of the authorization method.
@@ -1938,12 +2189,12 @@ interface AuthorizationMethodConfig @{
@end example
@end deffn
-@node Receiving Terms of Service,Manage policy,Receiving Configuration,Common encodings
-@anchor{rest receiving-terms-of-service}@anchor{45}@anchor{rest terms}@anchor{46}
-@subsubsection Receiving Terms of Service
+@node Receiving Terms of Service,Managing policy,Receiving Configuration,REST API
+@anchor{rest receiving-terms-of-service}@anchor{4d}@anchor{rest terms}@anchor{4e}
+@subsection Receiving Terms of Service
-@anchor{rest get--terms}@anchor{47}
+@anchor{rest get--terms}@anchor{4f}
@deffn {HTTP Get} GET /terms
Obtain the terms of service provided by the escrow provider.
@@ -1954,7 +2205,7 @@ Returns the terms of service of the provider, in the best language
and format available based on the client’s request.
@end deffn
-@anchor{rest get--privacy}@anchor{48}
+@anchor{rest get--privacy}@anchor{50}
@deffn {HTTP Get} GET /privacy
Obtain the privacy policy of the service provided by the escrow provider.
@@ -1965,9 +2216,9 @@ Returns the privacy policy of the provider, in the best language
and format available based on the client’s request.
@end deffn
-@node Manage policy,Managing truth,Receiving Terms of Service,Common encodings
-@anchor{rest id3}@anchor{49}@anchor{rest manage-policy}@anchor{4a}
-@subsubsection Manage policy
+@node Managing policy,Managing truth,Receiving Terms of Service,REST API
+@anchor{rest manage-policy}@anchor{51}@anchor{rest managing-policy}@anchor{52}
+@subsection Managing policy
This API is used by the Anastasis client to deposit or request encrypted
@@ -1981,7 +2232,59 @@ public key using the Crockford base32-encoding.
In the following, UUID is always defined and used according to RFC 4122@footnote{https://tools.ietf.org/html/rfc4122}.
-@anchor{rest get--policy-$ACCOUNT_PUB[?version=$NUMBER]}@anchor{4b}
+@anchor{rest get--policy-$ACCOUNT_PUB-meta[?max_version=$NUMBER]}@anchor{53}
+@deffn {HTTP Get} GET /policy/$ACCOUNT_PUB/meta[?max_version=$NUMBER]
+
+Get meta data about a customer’s encrypted recovery documents.
+If @code{max_version} is specified, only return results up to the
+given version number. The response may not contain meta data
+for all versions if there are way too many. In this case,
+@code{max_version} must be used to incrementally fetch more versions.
+
+@strong{Response}:
+
+
+@table @asis
+
+@item 200 OK@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}:
+
+The escrow provider responds with a @ref{54,,RecoveryMetaSummary} object.
+
+@item 400 Bad request@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1}:
+
+The @code{$ACCOUNT_PUB} is not an EdDSA public key.
+
+@item 402 Payment Required@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.3}:
+
+The account’s balance is too low for the specified operation.
+See the Taler payment protocol specification for how to pay.
+
+@item 404 Not found@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5}:
+
+The requested resource was not found.
+@end table
+
+@strong{Details:}
+@anchor{rest recoverymetasummary}@anchor{54}
+@example
+interface RecoveryMetaSummary @{
+ // Version numbers as a string (!) are used as keys.
+ "$VERSION": MetaData;
+@}
+
+interface MetaData @{
+ // The meta value can be NULL if the document
+ // exists but no meta data was provided.
+ meta: string;
+
+ // Server-time indicative of when the recovery
+ // document was uploaded.
+ upload_time: Timestamp;
+@}
+@end example
+@end deffn
+
+@anchor{rest get--policy-$ACCOUNT_PUB[?version=$NUMBER]}@anchor{55}
@deffn {HTTP Get} GET /policy/$ACCOUNT_PUB[?version=$NUMBER]
Get the customer’s encrypted recovery document. If @code{version}
@@ -2017,7 +2320,7 @@ code in case the resource matches the provided Etag.
@item 200 OK@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}:
-The escrow provider responds with an @ref{4c,,EncryptedRecoveryDocument} object.
+The escrow provider responds with an @ref{56,,EncryptedRecoveryDocument} object.
@item 304 Not modified@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5}:
@@ -2032,10 +2335,6 @@ The @code{$ACCOUNT_PUB} is not an EdDSA public key.
The account’s balance is too low for the specified operation.
See the Taler payment protocol specification for how to pay.
-@item 403 Forbidden@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4}:
-
-The required account signature was invalid.
-
@item 404 Not found@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5}:
The requested resource was not found.
@@ -2043,17 +2342,15 @@ The requested resource was not found.
@emph{Anastasis-Version}: $NUMBER — The server must return actual version of the encrypted recovery document via this header.
If the client specified a version number in the header of the request, the server must return that version. If the client
-did not specify a version in the request, the server returns latest version of the @ref{4c,,EncryptedRecoveryDocument}.
+did not specify a version in the request, the server returns latest version of the @ref{56,,EncryptedRecoveryDocument}.
@emph{Etag}: Set by the server to the Base32-encoded SHA512 hash of the body. Used for caching and to prevent redundancies. The server MUST send the Etag if the status code is @code{200 OK}.
@emph{If-None-Match}: If this is not the very first request of the client, this contains the Etag-value which the client has received before from the server.
The client SHOULD send this header with every request (except for the first request) to avoid unnecessary downloads.
-
-@emph{Anastasis-Account-Signature}: The client must provide Base-32 encoded EdDSA signature over hash of body with @code{$ACCOUNT_PRIV}, affirming desire to download the requested encrypted recovery document. The purpose used MUST be @code{TALER_SIGNATURE_ANASTASIS_POLICY_DOWNLOAD} (1401).
@end deffn
-@anchor{rest post--policy-$ACCOUNT_PUB}@anchor{4d}
+@anchor{rest post--policy-$ACCOUNT_PUB}@anchor{57}
@deffn {HTTP Post} POST /policy/$ACCOUNT_PUB
Upload a new version of the customer’s encrypted recovery document.
@@ -2088,7 +2385,7 @@ case.
@code{timeout_ms=NUMBER} – @emph{Optional.} If specified, the Anastasis server will
wait up to @code{timeout_ms} milliseconds for completion of the payment before
sending the HTTP response. A client must never rely on this behavior, as the
-backend may return a response immediately.
+backend may return a response immediately. If a @code{timeout_ms} is not given, the Anastasis server may apply a default timeout (usually 30s) when talking to the merchant backend.
@end itemize
@@ -2099,9 +2396,11 @@ use the Etag to check whether it already knows the encrypted recovery document t
The server MUST refuse the upload with a @code{304} status code if the Etag matches
the latest version already known to the server.
+@emph{Anastasis-Policy-Meta-Data}: Encrypted meta data to be stored by the server and returned with the respective endpoint to provide an overview of the available policies. Encrypted using a random nonce and a key derived from the user ID using the salt “rmdâ€. The plaintext metadata must consist of the policy hash (for deduplication) and the (human readable) secret name.
+
@emph{Anastasis-Policy-Signature}: The client must provide Base-32 encoded EdDSA signature over hash of body with @code{$ACCOUNT_PRIV}, affirming desire to upload an encrypted recovery document.
-@emph{Payment-Identifier}: Base-32 encoded 32-byte payment identifier that was included in a previous payment (see @code{402} status code). Used to allow the server to check that the client paid for the upload (to protect the server against DoS attacks) and that the client knows a real secret of financial value (as the @strong{kdf_id} might be known to an attacker). If this header is missing in the client’s request (or the associated payment has exceeded the upload limit), the server must return a @code{402} response. When making payments, the server must include a fresh, randomly-generated payment-identifier in the payment request.
+@emph{Payment-Identifier}: Base-32 encoded 32-byte payment identifier that was included in a previous payment (see @code{402} status code). Used to allow the server to check that the client paid for the upload (to protect the server against DoS attacks) and that the client knows a real secret of financial value (as the @strong{kdf_id} might be known to an attacker). If this header is missing in the client’s request (or the associated payment has exceeded the upload limit), the server must return a @code{402} response. When making payments, the server must include a fresh, randomly-generated payment-identifier in the payment request. If a payment identifier is given, the Anastasis backend may block for the payment to be confirmed by Taler as specified by the @code{timeout_ms} argument.
@strong{Response}:
@@ -2110,8 +2409,10 @@ the latest version already known to the server.
@item 204 No content@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5}:
-The encrypted recovery document was accepted and stored. @code{Anastasis-Version} and @code{Anastasis-UUID} headers
-indicate what version and UUID was assigned to this encrypted recovery document upload by the server.
+The encrypted recovery document was accepted and stored. @code{Anastasis-Version}
+indicates what version was assigned to this encrypted recovery document upload by the server.
+@code{Anastasis-Policy-Expiration} indicates the time until the server promises to store the policy,
+in seconds since epoch.
@item 304 Not modified@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5}:
@@ -2139,7 +2440,7 @@ The upload is too large @emph{or} too small. The response body may elaborate on
@end table
@strong{Details:}
-@anchor{rest encryptedrecoverydocument}@anchor{4c}
+@anchor{rest encryptedrecoverydocument}@anchor{56}
@example
interface EncryptedRecoveryDocument @{
// Nonce used to compute the (iv,key) pair for encryption of the
@@ -2151,35 +2452,34 @@ interface EncryptedRecoveryDocument @{
// Variable-size encrypted recovery document. After decryption,
// this contains a gzip compressed JSON-encoded `RecoveryDocument`.
- // The nonce of the HKDF for this encryption must include the
- // string "ERD".
+ // The salt of the HKDF for this encryption must include the
+ // string "erd".
encrypted_compressed_recovery_document: []; //bytearray of undefined length
@}
@end example
-@anchor{rest recoverydocument}@anchor{4e}
+@anchor{rest recoverydocument}@anchor{58}
@example
interface RecoveryDocument @{
- // Account identifier at backup provider, AES-encrypted with
- // the (symmetric) master_key, i.e. an URL
- // https://sync.taler.net/$BACKUP_ID and
- // a private key to decrypt the backup. Anastasis is oblivious
- // to the details of how this is ultimately encoded.
- backup_account: []; //bytearray of undefined length
+ // Human-readable name of the secret
+ secret_name?: string;
+
+ // Encrypted core secret.
+ encrypted_core_secret: string; // bytearray of undefined length
// List of escrow providers and selected authentication method.
- methods: EscrowMethod[];
+ escrow_methods: EscrowMethod[];
// List of possible decryption policies.
- policy: DecryptionPolicy[];
+ policies: DecryptionPolicy[];
@}
@end example
-@anchor{rest escrowmethod}@anchor{4f}
+@anchor{rest escrowmethod}@anchor{59}
@example
interface EscrowMethod @{
// URL of the escrow provider (including possibly this Anastasis server).
- provider_url : string;
+ url : string;
// Type of the escrow method (e.g. security question, SMS etc.).
escrow_type: string;
@@ -2189,46 +2489,48 @@ interface EscrowMethod @{
// Key used to encrypt the `Truth` this `EscrowMethod` is related to.
// Client has to provide this key to the server when using `@w{`}/truth/`@w{`}.
- truth_encryption_key: [32]; //bytearray
+ truth_key: [32]; //bytearray
- // Salt used to encrypt the truth on the Anastasis server.
- truth_salt: [32]; //bytearray
+ // Salt used to hash the security answer if appliccable.
+ question_salt: [32]; //bytearray
- // The challenge to give to the user (i.e. the security question
+ // Salt from the provider to derive the user ID
+ // at this provider.
+ provider_salt: [32]; //bytearray
+
+ // The instructions to give to the user (i.e. the security question
// if this is challenge-response).
// (Q: as string in base32 encoding?)
// (Q: what is the mime-type of this value?)
//
- // For some methods, this value may be absent.
- //
// The plaintext challenge is not revealed to the
// Anastasis server.
- challenge: []; //bytearray of undefined length
+ instructions: string;
@}
@end example
-@anchor{rest decryptionpolicy}@anchor{50}
+@anchor{rest decryptionpolicy}@anchor{5a}
@example
interface DecryptionPolicy @{
// Salt included to encrypt master key share when
// using this decryption policy.
- policy_salt: [32]; //bytearray
+ master_salt: [32]; //bytearray
// Master key, AES-encrypted with key derived from
// salt and keyshares revealed by the following list of
// escrow methods identified by UUID.
- encrypted_master_key: [32]; //bytearray
+ master_key: [32]; //bytearray
// List of escrow methods identified by their UUID.
- uuid: string[];
+ uuids: string[];
@}
@end example
@end deffn
-@node Managing truth,,Manage policy,Common encodings
-@anchor{rest managing-truth}@anchor{51}@anchor{rest truth}@anchor{52}
-@subsubsection Managing truth
+@node Managing truth,,Managing policy,REST API
+@anchor{rest managing-truth}@anchor{5b}@anchor{rest truth}@anchor{5c}
+@subsection Managing truth
Truth always consists of an encrypted key share and encrypted
@@ -2249,14 +2551,14 @@ data required for such a respective escrow method.
An Anastasis-server may store truth for free for a certain time period, or
charge per truth operation using GNU Taler.
-@anchor{rest post--truth-$UUID}@anchor{53}
+@anchor{rest post--truth-$UUID}@anchor{5d}
@deffn {HTTP Post} POST /truth/$UUID
-Upload a @ref{54,,TruthUploadRequest}-Object according to the policy the client created before (see @ref{4e,,RecoveryDocument}).
-If request has been seen before, the server should do nothing, and otherwise store the new object.
-
@strong{Request:}
+Upload a @ref{5e,,TruthUploadRequest}-Object according to the policy the client created before (see @ref{58,,RecoveryDocument}).
+If request has been seen before, the server should do nothing, and otherwise store the new object.
+
@*Query Parameters:
@itemize *
@@ -2301,7 +2603,7 @@ The selected authentication method is not supported on this provider.
@end table
@strong{Details:}
-@anchor{rest truthuploadrequest}@anchor{54}
+@anchor{rest truthuploadrequest}@anchor{5e}
@example
interface TruthUploadRequest @{
// Contains the information of an interface `EncryptedKeyShare`, but simply
@@ -2325,38 +2627,32 @@ interface TruthUploadRequest @{
// For how many years from now would the client like us to
// store the truth?
- storage_duration_years: Integer;
+ storage_duration_years: number;
@}
@end example
-@end deffn
-@anchor{rest get--truth-$UUID}@anchor{55}
-@deffn {HTTP Get} GET /truth/$UUID
+@anchor{rest post--truth-$UUID-solve}@anchor{5f}
+@deffn {HTTP Post} POST /truth/$UUID/solve
+@end deffn
-Get the stored encrypted key share.
-Also, the user has to provide the correct @emph{truth_encryption_key} with every get request (see below).
+Solve the challenge and get the stored encrypted key share.
+Also, the user has to provide the correct @emph{truth_encryption_key} with the request (see below).
The encrypted key share is returned simply as a byte array and not in JSON format.
-@*Query Parameters:
+@strong{Request}:
-@itemize *
+@quotation
-@item
-@code{response=H_RESPONSE} – @emph{Optional.} If @code{$H_RESPONSE} is specified by the client,
-the server checks if @code{$H_RESPONSE} matches the expected response. This can be the
-hash of the security question (as specified before by the client
-within the @ref{54,,TruthUploadRequest} (see @code{encrypted_truth})), or the hash of the
-PIN code sent via SMS, E-mail or postal communication channels.
-When @code{$H_RESPONSE} is correct, the server responds with the encrypted key share.
+Upload a @ref{60,,TruthSolutionRequest}-Object.
-@item
-@code{timeout_ms=NUMBER} – @emph{Optional.} If specified, the Anastasis server will
+@*query timeout_ms=NUMBER:
+@emph{Optional.} If specified, the Anastasis server will
wait up to @code{timeout_ms} milliseconds for completion of the payment or the
challenge before sending the HTTP response. A client must never rely on this
behavior, as the backend may return a response immediately.
-@end itemize
+@end quotation
@strong{Response}:
@@ -2365,24 +2661,7 @@ behavior, as the backend may return a response immediately.
@item 200 OK@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}:
-@ref{56,,EncryptedKeyShare} is returned in body (in binary).
-
-@item 202 Accepted@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3}:
-
-The escrow provider will respond out-of-band (i.e. SMS).
-The body may contain human-readable instructions on next steps.
-
-@item >>208 Already Reported<<:
-
-An authentication challenge was recently send, client should
-simply respond to the pending challenge.
-
-@item 303 See other@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4}:
-
-The provider redirects for authentication (i.e. video identification/WebRTC).
-If the client is not a browser, it should launch a browser at the URL
-given in the @code{Location} header and allow the user to re-try the operation
-after successful authorization.
+@ref{61,,EncryptedKeyShare} is returned in body (in binary).
@item 402 Payment required@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.3}:
@@ -2392,39 +2671,50 @@ The response body MAY provide alternative means for payment.
@item 403 Forbidden@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4}:
-The server requires a valid “response†to the challenge associated with the UUID.
+The h_response provided is not a good response to the challenge associated
+with the UUID, or at least the answer is not valid yet. A generic
+response is provided with an error code.
@item 404 Not found@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5}:
The server does not know any truth under the given UUID.
-@item 408 Request Timeout@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.9}:
-
-Accessing this truth requires satisfying an external authentication challenge
-(and not merely passing a response in the request) and this has not happened
-before the timeout was reached.
-
-@item 410 Gone@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.11}:
+@item 429 Too Many Requests@footnote{http://tools.ietf.org/html/rfc6585#section-4}:
-The server has not (recently) issued a challenge under the given UUID,
-but a reply was provided. (This does not apply for secure question.)
-
-@item 417 Expectation Failed@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18}:
-
-The decrypted @code{truth} does not match the expectations of the authentication
-backend, i.e. a phone number for sending an SMS is not a number, or
-an e-mail address for sending an E-mail is not a valid e-mail address.
+The client exceeded the number of allowed attempts at providing
+a valid response for the given time interval.
+The response format is given by @ref{62,,RateLimitedMessage}.
@item 503 Service Unavailable@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4}:
Server is out of Service.
@end table
-@emph{Truth-Decryption-Key}: Key used to encrypt the @strong{truth} (see encrypted_truth within @ref{54,,TruthUploadRequest}) and which has to provided by the user. The key is stored with
-the according @ref{4f,,EscrowMethod}. The server needs this key to get the info out of @ref{54,,TruthUploadRequest} needed to verify the @code{$RESPONSE}.
-
@strong{Details:}
-@anchor{rest encryptedkeyshare}@anchor{56}
+@anchor{rest truthsolutionrequest}@anchor{60}
+@example
+interface TruthSolutionRequest @{
+
+ // Hash over the response that solves the challenge
+ // issued for this truth. This can be the
+ // hash of the security question (as specified before by the client
+ // within the `TruthUploadRequest`_ (see `@w{`}encrypted_truth`@w{`})), or the hash of the
+ // PIN code sent via SMS, E-mail or postal communication channels.
+ // Only when `@w{`}$H_RESPONSE`@w{`} is correct, the server responds with the encrypted key share.
+ h_response: HashCode;
+
+ // Key that was used to encrypt the **truth** (see encrypted_truth within `TruthUploadRequest`_)
+ // and which has to provided by the user. The key is stored with
+ // the according `EscrowMethod`_. The server needs this key to get the
+ // info out of `TruthUploadRequest`_ to verify the `@w{`}h_response`@w{`}.
+ truth_decryption_key: ANASTASIS_TruthKeyP;
+
+ // Reference to a payment made by the client to
+ // pay for this request. Optional.
+ payment_secret?: ANASTASIS_PaymentSecretP;
+@}
+@end example
+@anchor{rest encryptedkeyshare}@anchor{61}
@example
interface EncryptedKeyShare @{
// Nonce used to compute the decryption (iv,key) pair.
@@ -2447,23 +2737,161 @@ interface EncryptedKeyShare @{
encrypted_key_share_i: [32]; //bytearray
@}
-@end example
-@anchor{rest keyshare}@anchor{57}
-@example
+
+
interface KeyShare @{
- // Key material to concatenate with policy_salt and KDF to derive
- // the key to decrypt the master key.
+ // Key material to derive the key to decrypt the master key.
key_share: [32]; //bytearray
+@}
+@end example
+@anchor{rest ratelimitedmessage}@anchor{62}
+@example
+interface RateLimitedMessage @{
- // Signature over method, UUID, and `@w{`}key_share`@w{`}.
- account_sig: EddsaSignature;
+ // Taler error code, TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED.
+ code: number;
+
+ // How many attempts are allowed per challenge?
+ request_limit: number;
+
+ // At what frequency are new challenges issued?
+ request_frequency: RelativeTime;
+
+ // The error message.
+ hint: string;
+
+@}
+@end example
+
+@anchor{rest post--truth-$UUID-challenge}@anchor{63}
+@deffn {HTTP Post} POST /truth/$UUID/challenge
+@end deffn
+
+NEW API (#7064):
+
+Initiate process to solve challenge associated with the given truth object.
+
+@strong{Request}:
+
+@quotation
+
+Upload a @ref{64,,TruthChallengeRequest}-Object.
+@end quotation
+
+@strong{Response}:
+
+
+@table @asis
+
+@item 200 Ok@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1}:
+
+The escrow provider will respond out-of-band (i.e. SMS).
+The body may contain human- or machine-readable instructions on next steps.
+In case the response is in JSON, the format is given
+by @ref{65,,ChallengeInstructionMessage}.
+
+@item 402 Payment required@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.3}:
+
+The service requires payment to issue a challenge.
+See the Taler payment protocol specification for how to pay.
+The response body MAY provide alternative means for payment.
+
+@item 403 Forbidden@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4}:
+
+This type of truth does not permit requests to trigger a challenge.
+This is the case for security questions and TOTP methods.
+
+@item 404 Not found@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5}:
+
+The server does not know any truth under the given UUID.
+
+@item 424 Failed Dependency@footnote{http://tools.ietf.org/html/rfc4918#section-11.4}:
+
+The decrypted @code{truth} does not match the expectations of the authentication
+backend, i.e. a phone number for sending an SMS is not a number, or
+an e-mail address for sending an E-mail is not a valid e-mail address.
+
+@item 503 Service Unavailable@footnote{http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4}:
+
+Server is out of Service.
+@end table
+
+@strong{Details:}
+@anchor{rest truthchallengerequest}@anchor{64}
+@example
+interface TruthChallengeRequest @{
+
+ // Key that was used to encrypt the **truth** (see encrypted_truth within `TruthUploadRequest`_)
+ // and which has to provided by the user. The key is stored with
+ // the according `EscrowMethod`_. The server needs this key to get the
+ // info out of `TruthUploadRequest`_ to verify the `@w{`}h_response`@w{`}.
+ truth_decryption_key: ANASTASIS_TruthKeyP;
+
+ // Reference to a payment made by the client to
+ // pay for this request. Optional.
+ payment_secret?: ANASTASIS_PaymentSecretP;
+@}
+@end example
+@anchor{rest challengeinstructionmessage}@anchor{65}
+@example
+type ChallengeInstructionMessage =
+ | FileChallengeInstructionMessage
+ | IbanChallengeInstructionMessage
+ | PinChallengeInstructionMessage;
+
+interface IbanChallengeInstructionMessage @{
+
+ // What kind of challenge is this?
+ method: "IBAN_WIRE";
+
+ // How much should be wired?
+ amount: Amount;
+
+ // What is the target IBAN?
+ credit_iban: string;
+
+ // What is the receiver name?
+ business_name: string;
+
+ // What is the expected wire transfer subject?
+ wire_transfer_subject: string;
+
+ // What is the numeric code (also part of the
+ // wire transfer subject) to be hashed when
+ // solving the challenge?
+ answer_code: number;
+
+ // Hint about the origin account that must be used.
+ debit_account_hint: string;
+
+@}
+
+interface PinChallengeInstructionMessage @{
+
+ // What kind of challenge is this?
+ method: "TAN_SENT";
+
+ // Where was the PIN code sent? Note that this
+ // address will most likely have been obscured
+ // to improve privacy.
+ tan_address_hint: string;
+
+@}
+
+interface FileChallengeInstructionMessage @{
+
+ // What kind of challenge is this?
+ method: "FILE_WRITTEN";
+
+ // Name of the file where the PIN code was written.
+ filename: string;
@}
@end example
@end deffn
@c This file is part of Anastasis
-@c Copyright (C) 2019-2021 Anastasis SARL
+@c Copyright (C) 2019-2022 Anastasis SARL
@c
@c Anastasis is free software; you can redistribute it and/or modify it under the
@c terms of the GNU Affero General Public License as published by the Free Software
@@ -2481,13 +2909,13 @@ interface KeyShare @{
@c @author Dennis Neufeld
@node Reducer API,Authentication Methods,REST API,Documentation Overview
-@anchor{reducer doc}@anchor{58}@anchor{reducer reducer-api}@anchor{59}
+@anchor{reducer doc}@anchor{66}@anchor{reducer reducer-api}@anchor{67}
@section Reducer API
This section describes the Anastasis Reducer API which is used by client applications
to store or load the different states the client application can have.
-The reducer takes a @ref{5a,,state} in JSON syntax and returns the new state in JSON syntax.
+The reducer takes a @ref{68,,state} in JSON syntax and returns the new state in JSON syntax.
For example a @strong{state} may take the following structure:
@@ -2501,7 +2929,7 @@ For example a @strong{state} may take the following structure:
@}
@end example
-The new state depends on the previous one and on the transition @ref{5b,,action} with its
+The new state depends on the previous one and on the transition @ref{69,,action} with its
arguments given to the reducer. A @strong{transition argument} also is a statement in JSON syntax:
@example
@@ -2511,7 +2939,7 @@ arguments given to the reducer. A @strong{transition argument} also is a stateme
@end example
The new state returned by the reducer with the state and transition argument defined
-above would look like following for the transition @ref{5b,,action} @code{select_continent}:
+above would look like following for the transition @ref{69,,action} @code{select_continent}:
@example
@{
@@ -2553,6 +2981,18 @@ above would look like following for the transition @ref{5b,,action} @code{select
@}
@end example
+An action may also result into an @emph{error response} instead of a new state.
+Clients should then render this error response to the user and allow the user
+to continue from the old state. An error response looks like this:
+
+@example
+@{
+ "code": 123,
+ "hint": "something went wrong",
+ "details": "parameter foo failed to frobnify"
+@}
+@end example
+
@menu
* States::
* Backup Reducer::
@@ -2562,7 +3002,7 @@ above would look like following for the transition @ref{5b,,action} @code{select
@end menu
@node States,Backup Reducer,,Reducer API
-@anchor{reducer states}@anchor{5c}
+@anchor{reducer states}@anchor{6a}
@subsection States
@@ -2577,15 +3017,6 @@ Overall, the reducer knows the following states:
@table @asis
-@item @strong{ERROR}: The transition led to an error. No further transitions are possible from
-
-this state, but the client may want to continue from a previous state.
-@end table
-
-@item
-
-@table @asis
-
@item @strong{CONTINENT_SELECTING}: The user should specify the continent where they are living,
so that we can show a list of countries to choose from.
@@ -2697,10 +3128,10 @@ in FINISHED-states, the operation has definitively concluded.
@end quotation
@node Backup Reducer,Recovery Reducer,States,Reducer API
-@anchor{reducer backup-reducer}@anchor{5d}
+@anchor{reducer backup-reducer}@anchor{6b}
@subsection Backup Reducer
-@anchor{reducer state}@anchor{5a}@anchor{reducer action}@anchor{5b}
+@anchor{reducer state}@anchor{68}@anchor{reducer action}@anchor{69}
@float Figure
@@ -2715,7 +3146,7 @@ The illustration above shows the different states the reducer can have during a
process.
@node Recovery Reducer,Reducer transitions,Backup Reducer,Reducer API
-@anchor{reducer recovery-reducer}@anchor{5e}
+@anchor{reducer recovery-reducer}@anchor{6c}
@subsection Recovery Reducer
@@ -2733,7 +3164,7 @@ The illustration above shows the different states the reducer can have during a
process.
@node Reducer transitions,,Recovery Reducer,Reducer API
-@anchor{reducer reducer-transitions}@anchor{5f}
+@anchor{reducer reducer-transitions}@anchor{6d}
@subsection Reducer transitions
@@ -2750,7 +3181,7 @@ state is preserved to enable “back†transitions to function smoothly.
@end menu
@node Initial state,Common transitions,,Reducer transitions
-@anchor{reducer initial-state}@anchor{60}
+@anchor{reducer initial-state}@anchor{6e}
@subsubsection Initial state
@@ -2813,7 +3244,7 @@ continent names:
Translations must be given in the same order as the main English array.
@node Common transitions,Backup transitions,Initial state,Reducer transitions
-@anchor{reducer common-transitions}@anchor{61}
+@anchor{reducer common-transitions}@anchor{6f}
@subsubsection Common transitions
@@ -2939,7 +3370,7 @@ providers that accept payments in the selected currency:
@},
@{
"type": "string",
- "name": "tax_number",
+ "name": "tax_number",
"label": "Taxpayer identification number",
"label_i18n":@{
"de_DE": "Steuerliche Identifikationsnummer",
@@ -2947,7 +3378,7 @@ providers that accept payments in the selected currency:
"en": "German taxpayer identification number"
@},
"widget": "anastasis_gtk_ia_tax_de",
- "uuid": "dae48f85-e3ff-47a4-a4a3-ed981ed8c3c6",
+ "uuid": "dae48f85-e3ff-47a4-a4a3-ed981ed8c3c6",
"validation-regex": "^[0-9]@{11@}$",
"validation-logic": "DE_TIN_check"
@},
@@ -2962,8 +3393,8 @@ providers that accept payments in the selected currency:
"en": "Social security number"
@},
"widget": "anastasis_gtk_ia_ssn",
- "validation-regex": "^[0-9]@{8@}[[:upper:]][0-9]@{3@}$",
- "validation-logic": "DE_SVN_check"
+ "validation-regex": "^[0-9]@{8@}[[:upper:]][0-9]@{3@}$",
+ "validation-logic": "DE_SVN_check"
"optional" : true
@}
],
@@ -3126,37 +3557,44 @@ we did not even obtain an HTTP response).
@strong{add_provider}:
-This operation can be performed in state @code{USER_ATTRIBUTES_COLLECTING}. It
+This operation can be performed in state @code{USER_ATTRIBUTES_COLLECTING}.
+It
adds one or more Anastasis providers to the list of providers the reducer
should henceforth consider. Note that removing providers is not possible at
this time.
-Here, the client must provide an array with the base URLs of the
-providers to add, for example:
+Here, the client must provide an object with the base URLs of the
+providers to add or disable. The object maps the
+URLs to status information about the provider to
+use. For example:
@example
@{
- "urls": [
- "http://localhost:8888/",
- "http://localhost:8089/"
- ]
+ "http://localhost:8088/" : @{ "disabled" : false @},
+ "http://localhost:8089/" : @{ "disabled" : false @},
+ "http://localhost:8090/" : @{ "disabled" : true @}
@}
@end example
-Note that existing providers will remain in the state. The following is an
+Note that existing providers will remain in the state they were in. The following is an
example for an expected new state where the service on port 8089 is
-unreachable, the service on port 8088 was previously known, and service on
-port 8888 was now added:
+unreachable, the services on port 8088 and 8888 were previously known, and service on
+port 8088 was now added, and on 8090 is disabled:
@example
@{
"backup_state": "USER_ATTRIBUTES_COLLECTING",
"authentication_providers": @{
"http://localhost:8089/": @{
+ "disabled": false,
"error_code": 11,
"http_status": 0
@},
+ "http://localhost:8090/": @{
+ "disabled": true
+ @},
"http://localhost:8088/": @{
+ "disabled": false,
"http_status": 200,
"methods": [
@{ "type" : "question",
@@ -3194,7 +3632,7 @@ port 8888 was now added:
@end example
@node Backup transitions,Recovery transitions,Common transitions,Reducer transitions
-@anchor{reducer backup-transitions}@anchor{62}
+@anchor{reducer backup-transitions}@anchor{70}
@subsubsection Backup transitions
@@ -3238,15 +3676,17 @@ to it:
@end example
If required attributes are missing, do not match the required regular
-expression, or fail the custom validation logic, the reducer SHOULD transition
-to an error state indicating what was wrong about the input. A reducer that
-does not support some specific validation logic MAY accept the invalid input
-and proceed anyway. The error state will include a Taler error code that
-is specific to the failure, and optional details. Example:
+expression, or fail the custom validation logic, the reducer SHOULD return an
+error response indicating that the transition has failed and what is wrong about
+the input and not transition to a new state. A reducer that does not support
+some specific validation logic MAY accept the invalid input and proceed anyway.
+The error state will include a Taler error code that is specific to the
+failure, and optional details.
+
+Example:
@example
@{
- "backup_state": "ERROR",
"code": 8404,
"hint": "An input did not match the regular expression.",
"detail": "social_security_number"
@@ -3338,8 +3778,8 @@ response:
@}
@end example
-If the index is invalid, the reducer will instead
-transition into an @code{ERROR} state.
+If the index is invalid, the reducer will return an error
+response instead of making a transition.
@strong{next} (from @code{AUTHENTICATIONS_EDITING}):
@@ -3413,8 +3853,8 @@ policy. The @code{methods} array specifies the index of the
@code{authentication_method} in the @code{authentication_methods} array, as well as
the provider that was selected to supervise this authentication.
-If no authentication method was provided, the reducer will transition into an
-@code{ERROR} state instead of suggesting policies.
+If no authentication method was provided, the reducer will
+return an error response instead of making a transition.
@strong{add_policy}:
@@ -3500,7 +3940,7 @@ the “policies†array, returning an updated state:
If the new policy is invalid, for example because it adds an unknown
authentication method, or the selected provider does not support the type of
-authentication, the reducer will transition into an @code{ERROR} state instead of
+authentication, the reducer return an error response instead of
adding the new policy.
@strong{update_policy}:
@@ -3530,7 +3970,7 @@ An example for a possible argument would thus be:
If the new policy is invalid, for example because it adds an unknown
authentication method, or the selected provider does not support the type of
-authentication, the reducer will transition into an @code{ERROR} state instead of
+authentication, the reducer will return an error response instead of
modifying the policy.
@strong{delete_policy:}
@@ -3591,7 +4031,7 @@ be:
@}
@end example
-If the index given is invalid, the reducer will transition into an @code{ERROR} state
+If the index given is invalid, the reducer will return an error response
instead of deleting a policy.
@strong{delete_challenge:}
@@ -3651,7 +4091,7 @@ be:
@}
@end example
-If the index given is invalid, the reducer will transition into an @code{ERROR} state
+If the index given is invalid, the reducer will return an error response
instead of deleting a challenge.
@strong{next} (from @code{POLICIES_REVIEWING}):
@@ -3664,7 +4104,7 @@ The reducer will simply transition to the @code{SECRET_EDITING} state:
@example
@{
"backup_state": "SECRET_EDITING",
- "upload_fees" : [ "KUDOS:42" ],
+ "upload_fees" : [ @{ "fee": "KUDOS:42" @} ],
"expiration" : @{ "t_ms" : 1245362362 @}
@}
@end example
@@ -3674,8 +4114,8 @@ given policy expiration time. This is an array because fees could
be in different currencies. The final cost may be lower if the
user already paid for some of the time.
-If the array of @code{policies} is currently empty, the reducer will transition
-into an @code{ERROR} state instead of allowing the user to continue.
+If the array of @code{policies} is currently empty, the reducer will
+return an error response instead of allowing the user to continue.
@strong{enter_secret:}
@@ -3709,7 +4149,7 @@ be updated.
"mime" : "text/plain"
@},
"expiration" : @{ "t_ms" : 1245362362 @},
- "upload_fees" : [ "KUDOS:42" ]
+ "upload_fees" : [ @{ "fee": "KUDOS:42" @} ]
@}
@end example
@@ -3775,8 +4215,8 @@ Using this transition, the user confirms that the secret and expiration
settings in the current state are acceptable. The transition does not take any
arguments.
-If the secret is currently empty, the reducer will transition into an
-@code{ERROR} state instead of allowing the user to continue.
+If the secret is currently empty, the reducer will return an
+error response instead of allowing the user to continue.
After adding a secret, the reducer may transition into different states
depending on whether payment(s) are necessary. If payments are needed, the
@@ -3852,13 +4292,12 @@ will wait this long before giving up. If no timeout is given, the check is
done as quickly as possible without additional delays. The reducer will continue
to either an updated state with the remaining payment requests, to the
@code{BACKUP_FINISHED} state (if all payments have been completed and the backup
-finished), or into an @code{ERROR} state in case there was an irrecoverable error,
+finished), or return an error response in case there was an irrecoverable error,
indicating the specific provider and how it failed. An example for this
final error state would be:
@example
@{
- "backup_state": "ERROR",
"http_status" : 500,
"upload_status" : 52,
"provider_url" : "https://bad.example.com/",
@@ -3887,7 +4326,7 @@ In the above example, 52 would thus imply that the Anastasis provider failed to
store information into its database.
@node Recovery transitions,,Backup transitions,Reducer transitions
-@anchor{reducer recovery-transitions}@anchor{63}
+@anchor{reducer recovery-transitions}@anchor{71}
@subsubsection Recovery transitions
@@ -3911,11 +4350,71 @@ the backup process. Example arguments would thus be:
@}
@end example
-However, in contrast to the backup process, the reducer will attempt to
-retrieve the latest recovery document from all known providers for the
-selected currency given the above inputs. If a recovery document was found
-by any provider, the reducer will attempt to load it and transition to
-a state where the user can choose which challenges to satisfy:
+Afterwards, the reducer transitions into the @code{SECRET_SELECTING} state:
+
+@example
+@{
+ "recovery_state": "SECRET_SELECTING",
+ "identity_attributes": @{
+ "full_name": "Max Musterman",
+ "social_security_number": "123456789",
+ "birthdate": "2000-01-01",
+ "birthplace": "Earth"
+ @}
+@}
+@end example
+
+Typically, the special policy discovery process (outside of the state
+machine) is expected to be run in this state. The discovery process
+will use the state (and in particular the identity attributes and the
+list of active providers) to discover a set of possible recovery
+documents with their respective provider URLs, policy version and
+identity attribute mask. An identity attribute mask is a bitmask that
+describes which of the optional attributes from the identity
+attributes should be omitted to recover this backup. Once the user
+has selected a backup providing this triplet, it is possible to
+proceed using @code{next}.
+
+Especially if the discovered policies are inadequate, it is again
+possible to add providers using @code{add_provider}.
+
+@strong{add_provider}:
+
+This operation can be performed in state @code{SECRET_SELECTING}. It
+adds one additional Anastasis provider to the list of providers that
+the discovery process should henceforth consider. Note that removing
+providers is not possible at this time.
+
+Here, the client must provide an object with the base URL of the
+providers to add, for example:
+
+@example
+@{
+ "provider_url" : "http://localhost:8088/"
+@}
+@end example
+
+@strong{select_version}:
+
+Using the @code{select_version} transition in the @code{SECRET_SELECTING} state,
+it is possible to trigger the download and decryption of a recovery
+policy document. Here, the arguments specify which provider, version
+and mask should be used to download the document:
+
+@example
+@{
+ "providers" : [ @{
+ "url": "https://localhost:8088/",
+ "version": 0
+ @} ],
+ "attribute_mask": 0
+@}
+@end example
+
+The reducer will attempt to retrieve the specified recovery document
+from that provider. If a recovery document was found, the reducer
+will attempt to load it and transition to a state where the user can
+choose which challenges to satisfy:
@example
@{
@@ -3924,13 +4423,13 @@ a state where the user can choose which challenges to satisfy:
"challenges": [
@{
"uuid": "MW2R3RCBZPHNC78AW8AKWRCHF9KV3Y82EN62T831ZP54S3K5599G",
- "cost": "TESTKUDOS:0",
+ "uuid-display": "MW2R3RC",
"type": "question",
"instructions": "q1"
@},
@{
"uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
- "cost": "TESTKUDOS:0",
+ "uuid-display": "TXYKGE",
"type": "email",
"instructions": "e-mail address m?il@@f*.bar"
@},
@@ -3971,14 +4470,13 @@ four mandatory fields:
@item
@strong{uuid}: A unique identifier of the challenge; this is what the
-UUIDs in the policies array refer to, but also this UUID may be
-included in messages sent to the user. They allow the user to
-distinguish different PIN/TANs should say the same phone number be
-used for SMS-authentication with different providers.
+UUIDs in the policies array refer to.
@item
-@strong{cost}: This is the amount the Anastasis provider will charge
-to allow the user to pass the challenge.
+@strong{uuid-display}: Shortened idenfier which is included in messages
+send to the user. Allows the user to
+distinguish different PIN/TANs should say the same phone number be
+used for SMS-authentication with different providers.
@item
@strong{type}: This is the type of the challenge, as a string.
@@ -4001,7 +4499,6 @@ message together with a transition failure:
@example
@{
- "recovery_state": "ERROR",
"error_message": "account unknown to Anastasis server",
"error_code": 9,
@}
@@ -4015,26 +4512,33 @@ translations should be available in the @code{anastasis} text domain.
However, in general it should be sufficient to display the slightly
more generic Taler error code that is returned with the new state.
-@strong{change_version:}
+@strong{sync_providers}
+
+The downloaded policy may include secrets from providers for which
+we do not (yet) have the cost structure or even the salt. So here
+an application can use the @code{sync_providers} request to download
+@code{/config} from providers that are in the challenge list but not
+yet known with their salt and other attributes in the provider list.
-Even if a recovery document was found, it is possible that the user
-intended to recover a different version, or recover a backup where
-the recovery document is stored at a different provider. Thus, the
-reducer allows the user to explicitly switch to a different provider
-or recovery document version using the @code{change_version} transition,
-which takes a provider URL and policy version as arguments:
+The transition fails if all providers relevant for the selected
+policy are already downloaded. Applications may either internally
+check the state for this, or call @code{sync_providers} until it fails
+with this error:
@example
@{
- "provider_url": "https://localhost:8080/",
- "version": 2
+ "detail": "already in sync",
+ "code": 8400,
+ "hint": "The given action is invalid for the current state of the reducer."
@}
@end example
-Note that using a version of 0 implies fetching “the latest versionâ€. The
-resulting states are the same as those of the @code{enter_user_attributes}
-transition, except that the recovery document version is not necessarily the
-latest available version at the provider.
+As providers may fail to respond, this action may need to be called
+repeatedly. The action will block until progress is made on any provider.
+As some providers may never respond, the application should disable
+challenge buttons for challenges where providers are down. However,
+users should be able to solve challenges where the provider is up while
+the reducer is polling for @code{/config} in the background.
@strong{select_challenge:}
@@ -4089,8 +4593,6 @@ information about attempted challenges, with the final state being @code{solved}
Challenges feedback for a challenge can have many different @code{state} values
that applications must all handle. States other than @code{solved} are:
-@quotation
-
@itemize -
@@ -4111,12 +4613,6 @@ that applications must all handle. States other than @code{solved} are:
@}
@}
@end example
-@end itemize
-
-@quotation
-
-
-@itemize -
@item
@strong{body}: Here, the server provided an HTTP reply for
@@ -4173,7 +4669,7 @@ related to solving the challenge:
@{
"recovery_state": "CHALLENGE_SOLVING",
"recovery_information": @{
- "...": "..."
+ "...": "..."
@}
"selected_challenge_uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
"challenge_feedback": @{
@@ -4189,25 +4685,16 @@ related to solving the challenge:
@}
@}
@end example
-@end itemize
-
-@quotation
-
-
-@itemize -
@item
@strong{redirect}: To solve the challenge, the user must visit the indicated
Web site at @code{redirect_url}, for example to perform video authentication:
-@end itemize
-
-@quotation
@example
@{
"recovery_state": "CHALLENGE_SOLVING",
"recovery_information": @{
- "...": "..."
+ "...": "..."
@}
"selected_challenge_uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
"challenge_feedback": @{
@@ -4220,26 +4707,22 @@ Web site at @code{redirect_url}, for example to perform video authentication:
@}
@end example
-
-@itemize -
-
@item
@strong{server-failure}: This indicates that the Anastasis provider encountered
a failure and recovery using this challenge cannot proceed at this time.
Examples for failures might be that the provider is unable to send SMS
messages at this time due to an outage. The body includes details about
the failure. The user may try again later or continue with other challenges.
-@end itemize
@example
-@{
- "recovery_state": "CHALLENGE_SELECTING",
- "recovery_information": @{
- "...": "..."
- @}
- "selected_challenge_uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
- "challenge_feedback": @{
- "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0": @{
+ @{
+ "recovery_state": "CHALLENGE_SELECTING",
+ "recovery_information": @{
+ "...": "..."
+ @}
+ "selected_challenge_uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
+ "challenge_feedback": @{
+ "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0": @{
"state": "server-failure",
"http_status": "500",
"error_code": 52
@@ -4248,14 +4731,10 @@ the failure. The user may try again later or continue with other challenges.
@}
@end example
-
-@itemize -
-
@item
@strong{truth-unknown}: This indicates that the Anastasis provider is unaware of
the specified challenge. This is typically a permanent failure, and user
interfaces should not allow users to re-try this challenge.
-@end itemize
@example
@{
@@ -4273,12 +4752,8 @@ interfaces should not allow users to re-try this challenge.
@}
@end example
-
-@itemize -
-
@item
-@strong{rate-limit-exceeded}:
-@end itemize
+@strong{rate-limit-exceeded}: This indicates that the user has made too many invalid attempts in too short an amount of time.
@example
@{
@@ -4295,10 +4770,88 @@ interfaces should not allow users to re-try this challenge.
@}
@}
@end example
-@end quotation
-@end quotation
-@end quotation
-@end quotation
+
+@item
+@strong{authentication-timeout}: This indicates that the challenge is awaiting for some external authentication process to complete. The application should @code{poll} for it to complete, or proceed with selecting other challenges.
+
+@example
+@{
+ "recovery_state": "CHALLENGE_SELECTING",
+ "recovery_information": @{
+ "...": "..."
+ @}
+ "selected_challenge_uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
+ "challenge_feedback": @{
+ "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0": @{
+ "state": "authentication-timeout",
+ "error_code": 8122
+ @}
+ @}
+@}
+@end example
+
+@item
+@strong{external-instructions}: This indicates that the challenge requires the user to perform some authentication method-specific actions. Details about what the user should do are provided.
+
+@example
+@{
+ "recovery_state": "CHALLENGE_SELECTING",
+ "recovery_information": @{
+ "...": "..."
+ @}
+ "selected_challenge_uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
+ "challenge_feedback": @{
+ "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0": @{
+ "state": "external-instructions",
+ "method": "iban",
+ "async": true, // optional
+ "answer_code": 987654321, // optional
+ "details": @{
+ "...": "..."
+ @}
+ @}
+ @}
+@}
+@end example
+
+If “async†is “trueâ€, then the client should
+poll for the challenge being satisfied using
+the “answer_code†that has been provided.
+
+The specific instructions on how to satisfy
+the challenge depend on the @code{method}.
+They include:
+
+
+@itemize -
+
+@item
+@strong{iban}: The user must perform a wire transfer from their account to the Anastasis provider.
+
+@example
+@{
+ "challenge_amount": "EUR:1",
+ "credit_iban": "DE12345789000",
+ "business_name": "Data Loss Incorporated",
+ "wire_transfer_subject": "Anastasis 987654321"
+@}
+@end example
+
+Note that the actual wire transfer subject must contain both
+the numeric @code{answer_code} as well as
+the string @code{Anastasis}.
+@end itemize
+@end itemize
+
+@strong{poll:}
+
+With a @code{poll} transition, the application indicates that it wants to wait longer for one or more of the challenges that are awaiting some external authentication (state @code{external-instructions}) or experienced some kind of timeout (state @code{authentication-timeout}) to possibly complete. While technically optional, the @code{timeout} argument should really be provided to enable long-polling, for example:
+
+@example
+@{
+ "timeout" : @{ "d_ms" : 5000 @},
+@}
+@end example
@strong{pay:}
@@ -4364,7 +4917,7 @@ formats are:
@c @author Dennis Neufeld
@node Authentication Methods,DB Schema,Reducer API,Documentation Overview
-@anchor{authentication doc}@anchor{64}@anchor{authentication anastasis-auth-methods}@anchor{65}@anchor{authentication authentication-methods}@anchor{66}
+@anchor{authentication doc}@anchor{72}@anchor{authentication anastasis-auth-methods}@anchor{73}@anchor{authentication authentication-methods}@anchor{74}
@section Authentication Methods
@@ -4392,29 +4945,29 @@ maximum permissible frequency.
@end menu
@node SMS sms,Email verification email,,Authentication Methods
-@anchor{authentication sms-sms}@anchor{67}
+@anchor{authentication sms-sms}@anchor{75}
@subsection SMS (sms)
Sends an SMS with a code (prefixed with @code{A-}) to the user’s phone, including
a UUID which identifies the challenge the code is for. The user must send
-this code back with his request (see @code{$RESPONSE} under @ref{52,,Managing truth}).
+this code back with his request (see @code{$RESPONSE} under @ref{5c,,Managing truth}).
If the transmitted code is correct, the server responses with the requested
encrypted key share.
@node Email verification email,Video identification vid,SMS sms,Authentication Methods
-@anchor{authentication email-verification-email}@anchor{68}
+@anchor{authentication email-verification-email}@anchor{76}
@subsection Email verification (email)
Sends an email with a code (prefixed with @code{A-}) to the user’s mail address,
including a UUID which identifies the challenge the code is for. The user
-must send this code back with his request (see @code{$RESPONSE} under @ref{52,,Managing truth}).
+must send this code back with his request (see @code{$RESPONSE} under @ref{5c,,Managing truth}).
If the transmitted code is correct, the server responses with the
requested encrypted key share.
@node Video identification vid,Security question qa,Email verification email,Authentication Methods
-@anchor{authentication video-identification-vid}@anchor{69}
+@anchor{authentication video-identification-vid}@anchor{77}
@subsection Video identification (vid)
@@ -4432,7 +4985,7 @@ requesting the user to be redirected to a Web site (or other URL) for the
video-call.
@node Security question qa,Snail mail verification post,Video identification vid,Authentication Methods
-@anchor{authentication security-question-qa}@anchor{6a}
+@anchor{authentication security-question-qa}@anchor{78}
@subsection Security question (qa)
@@ -4455,14 +5008,14 @@ remains irrecoverable without the answer even if the Anastasis provider
storing the security question is malicious.
@node Snail mail verification post,,Security question qa,Authentication Methods
-@anchor{authentication snail-mail-verification-post}@anchor{6b}
+@anchor{authentication snail-mail-verification-post}@anchor{79}
@subsection Snail mail verification (post)
Sends physical mail (snail mail) with a code (prefixed with @code{A-}) to the
user’s mail address, including a UUID which identifies the challenge the code
is for. The user must send this code back with their request (see
-@code{$RESPONSE} under @ref{52,,Managing truth}). If the transmitted code is correct,
+@code{$RESPONSE} under @ref{5c,,Managing truth}). If the transmitted code is correct,
the server responds with the requested encrypted key share.
@c This file is part of Anastasis
@@ -4484,7 +5037,7 @@ the server responds with the requested encrypted key share.
@c @author Dennis Neufeld
@node DB Schema,Anastasis licensing information,Authentication Methods,Documentation Overview
-@anchor{db doc}@anchor{6c}@anchor{db db-schema}@anchor{6d}
+@anchor{db doc}@anchor{7a}@anchor{db db-schema}@anchor{7b}
@section DB Schema
@@ -4499,7 +5052,7 @@ the server responds with the requested encrypted key share.
@image{anastasis-figures/anastasis_truth_payment,,,,png}
@node Anastasis licensing information,Man Pages,DB Schema,Documentation Overview
-@anchor{global-licensing doc}@anchor{6e}@anchor{global-licensing anastasis-licensing-information}@anchor{6f}
+@anchor{global-licensing doc}@anchor{7c}@anchor{global-licensing anastasis-licensing-information}@anchor{7d}
@section Anastasis licensing information
@@ -4521,7 +5074,7 @@ GPL.
@end menu
@node Anastasis git //git taler net/anastasis,Anastasis-gtk git //git taler net/anastasis-gtk,,Anastasis licensing information
-@anchor{global-licensing anastasis-git-git-taler-net-anastasis}@anchor{70}@anchor{global-licensing exchange-repo}@anchor{71}
+@anchor{global-licensing anastasis-git-git-taler-net-anastasis}@anchor{7e}@anchor{global-licensing exchange-repo}@anchor{7f}
@subsection Anastasis (git://git.taler.net/anastasis)
@@ -4533,7 +5086,7 @@ Anastasis core logic is under AGPL.
@end menu
@node Runtime dependencies,,,Anastasis git //git taler net/anastasis
-@anchor{global-licensing runtime-dependencies}@anchor{72}
+@anchor{global-licensing runtime-dependencies}@anchor{80}
@subsubsection Runtime dependencies
@@ -4563,7 +5116,7 @@ GNU Taler: LGPLv3+ / GPLv3+ / AGPLv3+: owned by Taler Systems SA
@end itemize
@node Anastasis-gtk git //git taler net/anastasis-gtk,Documentation,Anastasis git //git taler net/anastasis,Anastasis licensing information
-@anchor{global-licensing anastasis-gtk-git-git-taler-net-anastasis-gtk}@anchor{73}
+@anchor{global-licensing anastasis-gtk-git-git-taler-net-anastasis-gtk}@anchor{81}
@subsection Anastasis-gtk (git://git.taler.net/anastasis-gtk)
@@ -4575,7 +5128,7 @@ Anastasis-gtk is under AGPL.
@end menu
@node Runtime dependencies<2>,,,Anastasis-gtk git //git taler net/anastasis-gtk
-@anchor{global-licensing id1}@anchor{74}
+@anchor{global-licensing id1}@anchor{82}
@subsubsection Runtime dependencies
@@ -4608,28 +5161,31 @@ GNU Taler: LGPLv3+ / GPLv3+ / AGPLv3+: owned by Taler Systems SA
@end itemize
@node Documentation,,Anastasis-gtk git //git taler net/anastasis-gtk,Anastasis licensing information
-@anchor{global-licensing documentation}@anchor{75}
+@anchor{global-licensing documentation}@anchor{83}
@subsection Documentation
The documentation is licensed under the GNU Free Documentation License Version 1.3 or later.
@node Man Pages,Complete Index,Anastasis licensing information,Documentation Overview
-@anchor{manindex doc}@anchor{76}@anchor{manindex man-pages}@anchor{77}
+@anchor{manindex doc}@anchor{84}@anchor{manindex man-pages}@anchor{85}
@section Man Pages
@menu
* anastasis-config(1): anastasis-config 1.
+* anastasis-dbconfig(1): anastasis-dbconfig 1.
+* anastasis-dbinit(1): anastasis-dbinit 1.
* anastasis-gtk(1): anastasis-gtk 1.
+* anastasis-helper-authorization-iban(1): anastasis-helper-authorization-iban 1.
* anastasis-httpd(1): anastasis-httpd 1.
* anastasis-reducer(1): anastasis-reducer 1.
* anastasis.conf(5): anastasis conf 5.
@end menu
-@node anastasis-config 1,anastasis-gtk 1,,Man Pages
-@anchor{manpages/anastasis-config 1 doc}@anchor{78}@anchor{manpages/anastasis-config 1 anastasis-config-1}@anchor{79}
+@node anastasis-config 1,anastasis-dbconfig 1,,Man Pages
+@anchor{manpages/anastasis-config 1 doc}@anchor{86}@anchor{manpages/anastasis-config 1 anastasis-config-1}@anchor{87}
@subsection anastasis-config(1)
@@ -4643,7 +5199,7 @@ The documentation is licensed under the GNU Free Documentation License Version 1
@end menu
@node Synopsis,Description,,anastasis-config 1
-@anchor{manpages/anastasis-config 1 synopsis}@anchor{7a}
+@anchor{manpages/anastasis-config 1 synopsis}@anchor{88}
@subsubsection Synopsis
@@ -4663,7 +5219,7 @@ The documentation is licensed under the GNU Free Documentation License Version 1
[@strong{-v} | @strong{––version}]
@node Description,See Also,Synopsis,anastasis-config 1
-@anchor{manpages/anastasis-config 1 description}@anchor{7b}
+@anchor{manpages/anastasis-config 1 description}@anchor{89}
@subsubsection Description
@@ -4747,23 +5303,23 @@ Print Anastasis version number.
@end table
@node See Also,Bugs,Description,anastasis-config 1
-@anchor{manpages/anastasis-config 1 see-also}@anchor{7c}
+@anchor{manpages/anastasis-config 1 see-also}@anchor{8a}
@subsubsection See Also
anastasis.conf(5)
@node Bugs,,See Also,anastasis-config 1
-@anchor{manpages/anastasis-config 1 bugs}@anchor{7d}
+@anchor{manpages/anastasis-config 1 bugs}@anchor{8b}
@subsubsection Bugs
Report bugs by using @indicateurl{https://bugs.anastasis.lu} or by sending electronic
mail to <@email{contact@@anastasis.lu}>.
-@node anastasis-gtk 1,anastasis-httpd 1,anastasis-config 1,Man Pages
-@anchor{manpages/anastasis-gtk 1 doc}@anchor{7e}@anchor{manpages/anastasis-gtk 1 anastasis-gtk-1}@anchor{7f}
-@subsection anastasis-gtk(1)
+@node anastasis-dbconfig 1,anastasis-dbinit 1,anastasis-config 1,Man Pages
+@anchor{manpages/anastasis-dbconfig 1 doc}@anchor{8c}@anchor{manpages/anastasis-dbconfig 1 anastasis-dbconfig-1}@anchor{8d}
+@subsection anastasis-dbconfig(1)
@@ -4775,20 +5331,194 @@ mail to <@email{contact@@anastasis.lu}>.
@end menu
-@node Synopsis<2>,Description<2>,,anastasis-gtk 1
-@anchor{manpages/anastasis-gtk 1 synopsis}@anchor{80}
+@node Synopsis<2>,Description<2>,,anastasis-dbconfig 1
+@anchor{manpages/anastasis-dbconfig 1 synopsis}@anchor{8e}
+@subsubsection Synopsis
+
+
+@strong{anastasis-dbconfig}
+[@strong{-c} @emph{FILENAME} @emph{]
+[*}-h**]
+[@strong{-n} @emph{NAME} @emph{]
+[*}-r**]
+[@strong{-s}]
+[@strong{-u} @emph{USER} >>*<<]
+
+@node Description<2>,See Also<2>,Synopsis<2>,anastasis-dbconfig 1
+@anchor{manpages/anastasis-dbconfig 1 description}@anchor{8f}
+@subsubsection Description
+
+
+@strong{anastasis-dbconfig} is a simple shell script that configures
+a Postgresql database for use by the GNU Anastasis servers.
+
+Its options are as follows:
+
+
+@table @asis
+
+@item @strong{-c} @emph{FILENAME}
+
+Write the database configuration to FILENAME. The tool
+will append the required @code{CONFIG} option for the
+Postgresql access to the respective file.
+
+@item @strong{-h}
+
+Print short help on options.
+
+@item @strong{-n} @emph{DBNAME}
+
+Use DBNAME for the name of the created database.
+
+@item @strong{-r}
+
+Reset any existing database. Looses all existing data. DANGEROUS.
+
+@item @strong{-s}
+
+Skip database initialization. Useful if you want to run
+@code{anastasis-dbinit} manually.
+
+@item @strong{-u} @emph{USER}
+
+Specifies the (main) Anastasis user that will access the database.
+@end table
+
+@node See Also<2>,Bugs<2>,Description<2>,anastasis-dbconfig 1
+@anchor{manpages/anastasis-dbconfig 1 see-also}@anchor{90}
+@subsubsection See Also
+
+
+anastassis-dbinit(1), anastasis.conf(5).
+
+@node Bugs<2>,,See Also<2>,anastasis-dbconfig 1
+@anchor{manpages/anastasis-dbconfig 1 bugs}@anchor{91}
+@subsubsection Bugs
+
+
+Report bugs by using @indicateurl{https://bugs.taler.net} or by sending electronic
+mail to <@email{taler@@gnu.org}>.
+
+@node anastasis-dbinit 1,anastasis-gtk 1,anastasis-dbconfig 1,Man Pages
+@anchor{manpages/anastasis-dbinit 1 doc}@anchor{92}@anchor{manpages/anastasis-dbinit 1 anastasis-dbinit-1}@anchor{93}
+@subsection anastasis-dbinit(1)
+
+
+
+@menu
+* Synopsis: Synopsis<3>.
+* Description: Description<3>.
+* See Also: See Also<3>.
+* Bugs: Bugs<3>.
+
+@end menu
+
+@node Synopsis<3>,Description<3>,,anastasis-dbinit 1
+@anchor{manpages/anastasis-dbinit 1 synopsis}@anchor{94}
+@subsubsection Synopsis
+
+
+@strong{anastasis-dbinit}
+[@strong{-c} @emph{FILENAME} | @strong{–config=}‌@emph{FILENAME}]
+[@strong{-g} | @strong{–gc}]
+[@strong{-h} | @strong{–help}]
+[@strong{-L} @emph{LOGLEVEL} | @strong{–loglevel=}‌@emph{LOGLEVEL}]
+[@strong{-l} @emph{FILENAME} | @strong{–logfile=}‌@emph{FILENAME}]
+[@strong{-r} | @strong{–reset}]
+[@strong{-v} | @strong{–version}]
+
+@node Description<3>,See Also<3>,Synopsis<3>,anastasis-dbinit 1
+@anchor{manpages/anastasis-dbinit 1 description}@anchor{95}
+@subsubsection Description
+
+
+@strong{anastasis-dbinit} is a command-line tool to initialize the GNU
+Anastasis database. It creates the necessary tables and indices for
+an Anastasis server to operate.
+
+Its options are as follows:
+
+
+@table @asis
+
+@item @strong{-c} @emph{FILENAME} | @strong{–config=}‌@emph{FILENAME}
+
+Use the configuration and other resources for the exchange to operate
+from @emph{FILENAME}.
+
+@item @strong{-g} | @strong{–gc}
+
+Garbage collect database. Deletes all unnecessary data in the
+database.
+
+@item @strong{-h} | @strong{–help}
+
+Print short help on options.
+
+@item @strong{-L} @emph{LOGLEVEL} | @strong{–loglevel=}‌@emph{LOGLEVEL}
+
+Specifies the log level to use. Accepted values are: @code{DEBUG}, @code{INFO},
+@code{WARNING}, @code{ERROR}.
+
+@item @strong{-l} @emph{FILENAME} | @strong{–logfile=}‌@emph{FILENAME}
+
+Send logging output to @emph{FILENAME}.
+
+@item @strong{-r} | @strong{–reset}
+
+Drop tables. Dangerous, will delete all existing data in the database
+before creating the tables.
+
+@item @strong{-v} | @strong{–version}
+
+Print version information.
+@end table
+
+@node See Also<3>,Bugs<3>,Description<3>,anastasis-dbinit 1
+@anchor{manpages/anastasis-dbinit 1 see-also}@anchor{96}
+@subsubsection See Also
+
+
+anastasis-httpd(1), anastasis.conf(5).
+
+@node Bugs<3>,,See Also<3>,anastasis-dbinit 1
+@anchor{manpages/anastasis-dbinit 1 bugs}@anchor{97}
+@subsubsection Bugs
+
+
+Report bugs by using @indicateurl{https://bugs.taler.net} or by sending electronic
+mail to <@email{taler@@gnu.org}>.
+
+@node anastasis-gtk 1,anastasis-helper-authorization-iban 1,anastasis-dbinit 1,Man Pages
+@anchor{manpages/anastasis-gtk 1 doc}@anchor{98}@anchor{manpages/anastasis-gtk 1 anastasis-gtk-1}@anchor{99}
+@subsection anastasis-gtk(1)
+
+
+
+@menu
+* Synopsis: Synopsis<4>.
+* Description: Description<4>.
+* See Also: See Also<4>.
+* Bugs: Bugs<4>.
+
+@end menu
+
+@node Synopsis<4>,Description<4>,,anastasis-gtk 1
+@anchor{manpages/anastasis-gtk 1 synopsis}@anchor{9a}
@subsubsection Synopsis
@strong{anastasis-gtk}
+[@strong{-A**_*ID*_|_}–application=**@emph{ID}]
[@strong{-c} @emph{FILENAME} | @strong{––config=}‌@emph{FILENAME}]
[@strong{-h} | @strong{––help}]
[@strong{-L} @emph{LOGLEVEL} | @strong{––loglevel=}‌@emph{LOGLEVEL}]
[@strong{-l} @emph{FILENAME} | @strong{––logfile=}‌@emph{FILENAME}]
[@strong{-v} | @strong{––version}]
-@node Description<2>,See Also<2>,Synopsis<2>,anastasis-gtk 1
-@anchor{manpages/anastasis-gtk 1 description}@anchor{81}
+@node Description<4>,See Also<4>,Synopsis<4>,anastasis-gtk 1
+@anchor{manpages/anastasis-gtk 1 description}@anchor{9b}
@subsubsection Description
@@ -4798,6 +5528,21 @@ key recover and backup operations.
@table @asis
+@item @strong{-A} @emph{ID} | @strong{–application=}@emph{ID}
+
+Set the application ID to @emph{ID}. Default is @code{anastasis-gtk}. Used
+to store different types of secrets from different applications
+while using the same user attributes. Basically the application ID
+is included in the user attributes. Not changable by the GUI as
+only advanced users should even known about this. Applications that
+tightly integrate Anastasis should set the application ID to their
+respective unique name, for example the GNU Taler wallet may use
+@code{gnu-taler-wallet} for the application ID. If anastasis-gtk is
+to be used to recover such a secret, the respective application ID
+must be provided on the command-line. Users that only use
+anastasis-gtk to backup and restore secrets should not set the
+application ID, as forgetting the ID makes the secrets irrecoverable.
+
@item @strong{-c} @emph{FILENAME} | @strong{––config=}‌@emph{FILENAME}
Use the configuration from @emph{FILENAME}.
@@ -4820,45 +5565,123 @@ Send logging output to @emph{FILENAME}.
Print version information.
@end table
-@node See Also<2>,Bugs<2>,Description<2>,anastasis-gtk 1
-@anchor{manpages/anastasis-gtk 1 see-also}@anchor{82}
+@node See Also<4>,Bugs<4>,Description<4>,anastasis-gtk 1
+@anchor{manpages/anastasis-gtk 1 see-also}@anchor{9c}
@subsubsection See Also
anastasis-reducer(1), anastasis-httpd(1), anastasis.conf(5).
-@node Bugs<2>,,See Also<2>,anastasis-gtk 1
-@anchor{manpages/anastasis-gtk 1 bugs}@anchor{83}
+@node Bugs<4>,,See Also<4>,anastasis-gtk 1
+@anchor{manpages/anastasis-gtk 1 bugs}@anchor{9d}
@subsubsection Bugs
Report bugs by using @indicateurl{https://bugs.anastasis.lu/} or by sending electronic
mail to <@email{contact@@anastasis.lu}>.
-@node anastasis-httpd 1,anastasis-reducer 1,anastasis-gtk 1,Man Pages
-@anchor{manpages/anastasis-httpd 1 doc}@anchor{84}@anchor{manpages/anastasis-httpd 1 anastasis-httpd-1}@anchor{85}
+@node anastasis-helper-authorization-iban 1,anastasis-httpd 1,anastasis-gtk 1,Man Pages
+@anchor{manpages/anastasis-helper-authorization-iban 1 doc}@anchor{9e}@anchor{manpages/anastasis-helper-authorization-iban 1 anastasis-helper-authorization-iban-1}@anchor{9f}
+@subsection anastasis-helper-authorization-iban(1)
+
+
+
+@menu
+* Synopsis: Synopsis<5>.
+* Description: Description<5>.
+* See Also: See Also<5>.
+* Bugs: Bugs<5>.
+
+@end menu
+
+@node Synopsis<5>,Description<5>,,anastasis-helper-authorization-iban 1
+@anchor{manpages/anastasis-helper-authorization-iban 1 synopsis}@anchor{a0}
+@subsubsection Synopsis
+
+
+@strong{anastasis-helper-authorization-iban}
+[@strong{-c} @emph{FILENAME} | @strong{––config=}‌@emph{FILENAME}]
+[@strong{-h} | @strong{––help}]
+[@strong{-L} @emph{LOGLEVEL} | @strong{––loglevel=}‌@emph{LOGLEVEL}]
+[@strong{-l} @emph{FILENAME} | @strong{––logfile=}‌@emph{FILENAME}]
+[@strong{-t} | @strong{––test}]
+[@strong{-v} | @strong{––version}]
+
+@node Description<5>,See Also<5>,Synopsis<5>,anastasis-helper-authorization-iban 1
+@anchor{manpages/anastasis-helper-authorization-iban 1 description}@anchor{a1}
+@subsubsection Description
+
+
+@strong{anastasis-helper-authorization-iban} monitors the Anastasis provider’s bank account for incoming wire transfers. This process supports the IBAN authentication method. It must be configured with the respective wire configuration to talk to LibEuFin/Nexus.
+
+
+@table @asis
+
+@item @strong{-c} @emph{FILENAME} | @strong{––config=}‌@emph{FILENAME}
+
+Use the configuration from @emph{FILENAME}.
+
+@item @strong{-h} | @strong{––help}
+
+Print short help on options.
+
+@item @strong{-L} @emph{LOGLEVEL} | @strong{––loglevel=}‌@emph{LOGLEVEL}
+
+Specifies the log level to use. Accepted values are: @code{DEBUG}, @code{INFO},
+@code{WARNING}, @code{ERROR}.
+
+@item @strong{-l} @emph{FILENAME} | @strong{––logfile=}‌@emph{FILENAME}
+
+Send logging output to @emph{FILENAME}.
+
+@item @strong{-t} | @strong{––test}
+
+Run in test mode. Causes the process to terminate after importing current wire transfers instead of running forever in the background.
+
+@item @strong{-v} | @strong{––version}
+
+Print version information.
+@end table
+
+@node See Also<5>,Bugs<5>,Description<5>,anastasis-helper-authorization-iban 1
+@anchor{manpages/anastasis-helper-authorization-iban 1 see-also}@anchor{a2}
+@subsubsection See Also
+
+
+anastasis-httpd(1), anastasis.conf(5).
+
+@node Bugs<5>,,See Also<5>,anastasis-helper-authorization-iban 1
+@anchor{manpages/anastasis-helper-authorization-iban 1 bugs}@anchor{a3}
+@subsubsection Bugs
+
+
+Report bugs by using @indicateurl{https://bugs.anastasis.lu/} or by sending electronic
+mail to <@email{contact@@anastasis.lu}>.
+
+@node anastasis-httpd 1,anastasis-reducer 1,anastasis-helper-authorization-iban 1,Man Pages
+@anchor{manpages/anastasis-httpd 1 doc}@anchor{a4}@anchor{manpages/anastasis-httpd 1 anastasis-httpd-1}@anchor{a5}
@subsection anastasis-httpd(1)
@menu
-* Synopsis: Synopsis<3>.
-* Description: Description<3>.
+* Synopsis: Synopsis<6>.
+* Description: Description<6>.
* Signals::
* See also::
-* Bugs: Bugs<3>.
+* Bugs: Bugs<6>.
@end menu
-@node Synopsis<3>,Description<3>,,anastasis-httpd 1
-@anchor{manpages/anastasis-httpd 1 synopsis}@anchor{86}
+@node Synopsis<6>,Description<6>,,anastasis-httpd 1
+@anchor{manpages/anastasis-httpd 1 synopsis}@anchor{a6}
@subsubsection Synopsis
@strong{anastasis-httpd}
-@node Description<3>,Signals,Synopsis<3>,anastasis-httpd 1
-@anchor{manpages/anastasis-httpd 1 description}@anchor{87}
+@node Description<6>,Signals,Synopsis<6>,anastasis-httpd 1
+@anchor{manpages/anastasis-httpd 1 description}@anchor{a7}
@subsubsection Description
@@ -4889,8 +5712,8 @@ Print short help on options.
Print version information.
@end table
-@node Signals,See also,Description<3>,anastasis-httpd 1
-@anchor{manpages/anastasis-httpd 1 signals}@anchor{88}
+@node Signals,See also,Description<6>,anastasis-httpd 1
+@anchor{manpages/anastasis-httpd 1 signals}@anchor{a8}
@subsubsection Signals
@@ -4904,15 +5727,15 @@ Print version information.
Sending a SIGTERM to the process will cause it to shutdown cleanly.
@end table
-@node See also,Bugs<3>,Signals,anastasis-httpd 1
-@anchor{manpages/anastasis-httpd 1 see-also}@anchor{89}
+@node See also,Bugs<6>,Signals,anastasis-httpd 1
+@anchor{manpages/anastasis-httpd 1 see-also}@anchor{a9}
@subsubsection See also
anastasis-dbinit(1), anastasis-config(1), anastasis-gtk(1), anastasis-reducer(1)
-@node Bugs<3>,,See also,anastasis-httpd 1
-@anchor{manpages/anastasis-httpd 1 bugs}@anchor{8a}
+@node Bugs<6>,,See also,anastasis-httpd 1
+@anchor{manpages/anastasis-httpd 1 bugs}@anchor{aa}
@subsubsection Bugs
@@ -4920,25 +5743,26 @@ Report bugs by using @indicateurl{https://bugs.anastasis.lu} or by sending
electronic mail to <@email{contact@@anastasis.lu}>.
@node anastasis-reducer 1,anastasis conf 5,anastasis-httpd 1,Man Pages
-@anchor{manpages/anastasis-reducer 1 doc}@anchor{8b}@anchor{manpages/anastasis-reducer 1 anastasis-reducer-1}@anchor{8c}
+@anchor{manpages/anastasis-reducer 1 doc}@anchor{ab}@anchor{manpages/anastasis-reducer 1 anastasis-reducer-1}@anchor{ac}
@subsection anastasis-reducer(1)
@menu
-* Synopsis: Synopsis<4>.
-* Description: Description<4>.
-* See Also: See Also<3>.
-* Bugs: Bugs<4>.
+* Synopsis: Synopsis<7>.
+* Description: Description<7>.
+* See Also: See Also<6>.
+* Bugs: Bugs<7>.
@end menu
-@node Synopsis<4>,Description<4>,,anastasis-reducer 1
-@anchor{manpages/anastasis-reducer 1 synopsis}@anchor{8d}
+@node Synopsis<7>,Description<7>,,anastasis-reducer 1
+@anchor{manpages/anastasis-reducer 1 synopsis}@anchor{ad}
@subsubsection Synopsis
@strong{anastasis-reducer}
+[@strong{-A**_*ID*_|_}–application=**@emph{ID}]
[@strong{-a**_*JSON*_|_}–arguments=@emph{JSON}]
[@strong{-b**_|_}–backup]
[@strong{-c} @emph{FILENAME} | @strong{––config=}‌@emph{FILENAME}]
@@ -4948,8 +5772,8 @@ electronic mail to <@email{contact@@anastasis.lu}>.
[@strong{-r**_|_}–restore]
[@strong{-v} | @strong{––version}] COMMAND
-@node Description<4>,See Also<3>,Synopsis<4>,anastasis-reducer 1
-@anchor{manpages/anastasis-reducer 1 description}@anchor{8e}
+@node Description<7>,See Also<6>,Synopsis<7>,anastasis-reducer 1
+@anchor{manpages/anastasis-reducer 1 description}@anchor{ae}
@subsubsection Description
@@ -4959,7 +5783,7 @@ The reducer will read the current state from standard input and
write the resulting state to standard output. A COMMAND must
be given on the command line. The arguments (if any) are to
be given in JSON format to the @strong{-a} option. A list of
-commands can be found in the @ref{58,,Reducer API}
+commands can be found in the @ref{66,,Reducer API}
chapter.
@@ -4969,6 +5793,20 @@ chapter.
Provide JSON inputs for the given command.
+@item @strong{-A} @emph{ID} | @strong{–application=}@emph{ID}
+
+Set the application ID to @emph{ID}. Default is empty, which means the application-id must be explicitly provided
+as part of the JSON inputs or it will be omitted.
+The @strong{-A} option overrides any application ID that
+may be given in the @strong{-a} arguments. Application IDs
+are used to store different types of secrets from different applications
+while using the same user attributes. Basically the application ID
+is included in the user attributes. Applications that
+tightly integrate Anastasis should set the application ID to their
+respective unique name, for example the GNU Taler wallet may use
+@code{gnu-taler-wallet} for the application ID.
+Forgetting the application ID makes the secrets irrecoverable.
+
@item @strong{-b} | @strong{–backup}
Begin fresh reducer operation for a back up operation.
@@ -4999,15 +5837,15 @@ Begin fresh reducer operation for a restore operation.
Print version information.
@end table
-@node See Also<3>,Bugs<4>,Description<4>,anastasis-reducer 1
-@anchor{manpages/anastasis-reducer 1 see-also}@anchor{8f}
+@node See Also<6>,Bugs<7>,Description<7>,anastasis-reducer 1
+@anchor{manpages/anastasis-reducer 1 see-also}@anchor{af}
@subsubsection See Also
anastasis-gtk(1), anastasis-httpd(1), anastasis.conf(5).
-@node Bugs<4>,,See Also<3>,anastasis-reducer 1
-@anchor{manpages/anastasis-reducer 1 bugs}@anchor{90}
+@node Bugs<7>,,See Also<6>,anastasis-reducer 1
+@anchor{manpages/anastasis-reducer 1 bugs}@anchor{b0}
@subsubsection Bugs
@@ -5015,20 +5853,20 @@ Report bugs by using @indicateurl{https://bugs.anastasis.lu/} or by sending elec
mail to <@email{contact@@anastasis.lu}>.
@node anastasis conf 5,,anastasis-reducer 1,Man Pages
-@anchor{manpages/anastasis conf 5 doc}@anchor{91}@anchor{manpages/anastasis conf 5 anastasis-conf-5}@anchor{92}
+@anchor{manpages/anastasis conf 5 doc}@anchor{b1}@anchor{manpages/anastasis conf 5 anastasis-conf-5}@anchor{b2}
@subsection anastasis.conf(5)
@menu
-* Description: Description<5>.
+* Description: Description<8>.
* SEE ALSO::
* BUGS::
@end menu
-@node Description<5>,SEE ALSO,,anastasis conf 5
-@anchor{manpages/anastasis conf 5 description}@anchor{93}
+@node Description<8>,SEE ALSO,,anastasis conf 5
+@anchor{manpages/anastasis conf 5 description}@anchor{b3}
@subsubsection Description
@@ -5076,13 +5914,14 @@ include the entirety of @code{sub.conf} at that point in @code{main.conf}.
@menu
* GLOBAL OPTIONS::
+* Backend options::
* Authorization options::
* Postgres database configuration::
@end menu
-@node GLOBAL OPTIONS,Authorization options,,Description<5>
-@anchor{manpages/anastasis conf 5 global-options}@anchor{94}
+@node GLOBAL OPTIONS,Backend options,,Description<8>
+@anchor{manpages/anastasis conf 5 global-options}@anchor{b4}
@subsubsection GLOBAL OPTIONS
@@ -5092,11 +5931,6 @@ the @strong{anastasis-httpd} service.
@table @asis
-@item PAYMENT_BACKEND_URL
-
-Base-URL of the Taler merchant backend instance to use for payments.
-FIXME: How do we pass the access token?
-
@item ANNUAL_FEE
Annual fee to be paid for policy uploads, i.e. “EUR:1.5â€.
@@ -5105,6 +5939,10 @@ Annual fee to be paid for policy uploads, i.e. “EUR:1.5â€.
Annual fee to be paid for truth uploads, i.e. “EUR:1.5â€.
+@item INSURANCE
+
+Amount up to which key shares are warranted, i.e. “EUR:1000000â€.
+
@item DB
Database backend to use, only @code{postgres} is supported right now.
@@ -5131,14 +5969,36 @@ change after the initial configuration.
TCP port on which the HTTP service should listen on.
@end table
-@node Authorization options,Postgres database configuration,GLOBAL OPTIONS,Description<5>
-@anchor{manpages/anastasis conf 5 authorization-options}@anchor{95}
+@node Backend options,Authorization options,GLOBAL OPTIONS,Description<8>
+@anchor{manpages/anastasis conf 5 backend-options}@anchor{b5}
+@subsubsection Backend options
+
+
+The following options are from the @code{[anastasis-merchant-backend]} section and used by
+the @strong{anastasis-httpd} service.
+
+
+@table @asis
+
+@item PAYMENT_BACKEND_URL
+
+Base-URL of the Taler merchant backend instance to use for payments.
+
+@item API_KEY
+
+API key to transmit to the merchant backend for authentication.
+@end table
+
+@node Authorization options,Postgres database configuration,Backend options,Description<8>
+@anchor{manpages/anastasis conf 5 authorization-options}@anchor{b6}
@subsubsection Authorization options
-For each active authorization plugin, options must be configured in
-a section called @code{[authorization-$PLUGIN]} where @code{$PLUGIN} is
-the name of the authorization plugin.
+For each active authorization plugin, options must be configured in a
+section called @code{[authorization-$PLUGIN]} where @code{$PLUGIN} is the
+name of the authorization plugin. Specific plugins may require
+additional options, which are described in the respective sections
+below.
@table @asis
@@ -5151,14 +6011,91 @@ authorization plugin during recovery.
@item ENABLED
@code{yes} to enable this plugin, @code{no} to disable.
+@end table
+
+@menu
+* SMS Authorization options::
+* Email Authorization options::
+* Post Authorization options::
+* IBAN Authorization options::
+
+@end menu
+
+@node SMS Authorization options,Email Authorization options,,Authorization options
+@anchor{manpages/anastasis conf 5 sms-authorization-options}@anchor{b7}
+@subsubsection SMS Authorization options
+
+
+
+@table @asis
@item COMMAND
-Helper command to run (only relevant for some plugins).
+Helper command to run to send SMS. The command will be given the phone number as its first argument. The message to be transmitted will be passed via STDIN.
+@end table
+
+@node Email Authorization options,Post Authorization options,SMS Authorization options,Authorization options
+@anchor{manpages/anastasis conf 5 email-authorization-options}@anchor{b8}
+@subsubsection Email Authorization options
+
+
+
+@table @asis
+
+@item COMMAND
+
+Helper command to run to send E-mail. The command will be given the e-mail address as its first argument. The message to be transmitted will be passed via STDIN.
+@end table
+
+@node Post Authorization options,IBAN Authorization options,Email Authorization options,Authorization options
+@anchor{manpages/anastasis conf 5 post-authorization-options}@anchor{b9}
+@subsubsection Post Authorization options
+
+
+
+@table @asis
+
+@item COMMAND
+
+Helper command to run to send physical mail. The command will be given the mailing address address as its first argument in JSON object fields ‘full_name’, ‘street’, ‘city’, ‘postcode’ and ‘country’. The message to be transmitted will be passed via STDIN.
+@end table
+
+@node IBAN Authorization options,,Post Authorization options,Authorization options
+@anchor{manpages/anastasis conf 5 iban-authorization-options}@anchor{ba}
+@subsubsection IBAN Authorization options
+
+
+
+@table @asis
+
+@item CREDIT_IBAN
+
+IBAN number where the consumers must
+wire the money to for authentication.
+
+@item BUSINESS_NAME
+
+Name of the account holder.
+
+@item WIRE_GATEWAY_URL
+
+Base URL of the LibEuFin wire gateway (Anastasis facade).
+
+@item WIRE_GATEWAY_AUTH_METHOD
+
+Authentication method used to talk to the LibEuFin wire gateway, i.e. ‘basic’ for HTTP basic authentication.
+
+@item USERNAME
+
+Username to use when using HTTP basic authentication.
+
+@item PASSWORD
+
+Password to use when using HTTP basic authentication.
@end table
-@node Postgres database configuration,,Authorization options,Description<5>
-@anchor{manpages/anastasis conf 5 postgres-database-configuration}@anchor{96}
+@node Postgres database configuration,,Authorization options,Description<8>
+@anchor{manpages/anastasis conf 5 postgres-database-configuration}@anchor{bb}
@subsubsection Postgres database configuration
@@ -5175,15 +6112,15 @@ Path under which the Postgres database is that the service
should use, i.e. @code{postgres://anastasis}.
@end table
-@node SEE ALSO,BUGS,Description<5>,anastasis conf 5
-@anchor{manpages/anastasis conf 5 see-also}@anchor{97}
+@node SEE ALSO,BUGS,Description<8>,anastasis conf 5
+@anchor{manpages/anastasis conf 5 see-also}@anchor{bc}
@subsubsection SEE ALSO
anastasis-httpd(1), anastasis-config(1)
@node BUGS,,SEE ALSO,anastasis conf 5
-@anchor{manpages/anastasis conf 5 bugs}@anchor{98}
+@anchor{manpages/anastasis conf 5 bugs}@anchor{bd}
@subsubsection BUGS
@@ -5191,12 +6128,12 @@ Report bugs by using @indicateurl{https://bugs.anastasis.lu/} or by sending elec
mail to <@email{contact@@anastasis.lu}>.
@node Complete Index,GNU Free Documentation License,Man Pages,Documentation Overview
-@anchor{genindex doc}@anchor{99}@anchor{genindex complete-index}@anchor{9a}
+@anchor{genindex doc}@anchor{be}@anchor{genindex complete-index}@anchor{bf}
@section Complete Index
@node GNU Free Documentation License,,Complete Index,Documentation Overview
-@anchor{fdl-1 3 doc}@anchor{9b}@anchor{fdl-1 3 gnu-fdl-1-3}@anchor{9c}@anchor{fdl-1 3 gnu-free-documentation-license}@anchor{9d}
+@anchor{fdl-1 3 doc}@anchor{c0}@anchor{fdl-1 3 gnu-fdl-1-3}@anchor{c1}@anchor{fdl-1 3 gnu-free-documentation-license}@anchor{c2}
@section GNU Free Documentation License
@@ -5226,7 +6163,7 @@ license document, but changing it is not allowed.
@end menu
@node 0 PREAMBLE,1 APPLICABILITY AND DEFINITIONS,,GNU Free Documentation License
-@anchor{fdl-1 3 preamble}@anchor{9e}
+@anchor{fdl-1 3 preamble}@anchor{c3}
@subsection 0. PREAMBLE
@@ -5252,7 +6189,7 @@ published as a printed book. We recommend this License principally for
works whose purpose is instruction or reference.
@node 1 APPLICABILITY AND DEFINITIONS,2 VERBATIM COPYING,0 PREAMBLE,GNU Free Documentation License
-@anchor{fdl-1 3 applicability-and-definitions}@anchor{9f}
+@anchor{fdl-1 3 applicability-and-definitions}@anchor{c4}
@subsection 1. APPLICABILITY AND DEFINITIONS
@@ -5342,7 +6279,7 @@ these Warranty Disclaimers may have is void and has no effect on the
meaning of this License.
@node 2 VERBATIM COPYING,3 COPYING IN QUANTITY,1 APPLICABILITY AND DEFINITIONS,GNU Free Documentation License
-@anchor{fdl-1 3 verbatim-copying}@anchor{a0}
+@anchor{fdl-1 3 verbatim-copying}@anchor{c5}
@subsection 2. VERBATIM COPYING
@@ -5360,7 +6297,7 @@ You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@node 3 COPYING IN QUANTITY,4 MODIFICATIONS,2 VERBATIM COPYING,GNU Free Documentation License
-@anchor{fdl-1 3 copying-in-quantity}@anchor{a1}
+@anchor{fdl-1 3 copying-in-quantity}@anchor{c6}
@subsection 3. COPYING IN QUANTITY
@@ -5400,7 +6337,7 @@ Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@node 4 MODIFICATIONS,5 COMBINING DOCUMENTS,3 COPYING IN QUANTITY,GNU Free Documentation License
-@anchor{fdl-1 3 modifications}@anchor{a2}
+@anchor{fdl-1 3 modifications}@anchor{c7}
@subsection 4. MODIFICATIONS
@@ -5536,7 +6473,7 @@ give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@node 5 COMBINING DOCUMENTS,6 COLLECTIONS OF DOCUMENTS,4 MODIFICATIONS,GNU Free Documentation License
-@anchor{fdl-1 3 combining-documents}@anchor{a3}
+@anchor{fdl-1 3 combining-documents}@anchor{c8}
@subsection 5. COMBINING DOCUMENTS
@@ -5563,7 +6500,7 @@ sections Entitled “Dedicationsâ€. You must delete all sections Entitled
“Endorsementsâ€.
@node 6 COLLECTIONS OF DOCUMENTS,7 AGGREGATION WITH INDEPENDENT WORKS,5 COMBINING DOCUMENTS,GNU Free Documentation License
-@anchor{fdl-1 3 collections-of-documents}@anchor{a4}
+@anchor{fdl-1 3 collections-of-documents}@anchor{c9}
@subsection 6. COLLECTIONS OF DOCUMENTS
@@ -5579,7 +6516,7 @@ License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@node 7 AGGREGATION WITH INDEPENDENT WORKS,8 TRANSLATION,6 COLLECTIONS OF DOCUMENTS,GNU Free Documentation License
-@anchor{fdl-1 3 aggregation-with-independent-works}@anchor{a5}
+@anchor{fdl-1 3 aggregation-with-independent-works}@anchor{ca}
@subsection 7. AGGREGATION WITH INDEPENDENT WORKS
@@ -5600,7 +6537,7 @@ equivalent of covers if the Document is in electronic form. Otherwise
they must appear on printed covers that bracket the whole aggregate.
@node 8 TRANSLATION,9 TERMINATION,7 AGGREGATION WITH INDEPENDENT WORKS,GNU Free Documentation License
-@anchor{fdl-1 3 translation}@anchor{a6}
+@anchor{fdl-1 3 translation}@anchor{cb}
@subsection 8. TRANSLATION
@@ -5622,7 +6559,7 @@ If a section in the Document is Entitled “Acknowledgementsâ€,
Title (section 1) will typically require changing the actual title.
@node 9 TERMINATION,10 FUTURE REVISIONS OF THIS LICENSE,8 TRANSLATION,GNU Free Documentation License
-@anchor{fdl-1 3 termination}@anchor{a7}
+@anchor{fdl-1 3 termination}@anchor{cc}
@subsection 9. TERMINATION
@@ -5652,7 +6589,7 @@ reinstated, receipt of a copy of some or all of the same material does
not give you any rights to use it.
@node 10 FUTURE REVISIONS OF THIS LICENSE,11 RELICENSING,9 TERMINATION,GNU Free Documentation License
-@anchor{fdl-1 3 future-revisions-of-this-license}@anchor{a8}
+@anchor{fdl-1 3 future-revisions-of-this-license}@anchor{cd}
@subsection 10. FUTURE REVISIONS OF THIS LICENSE
@@ -5674,7 +6611,7 @@ used, that proxy’s public statement of acceptance of a version
permanently authorizes you to choose that version for the Document.
@node 11 RELICENSING,ADDENDUM How to use this License for your documents,10 FUTURE REVISIONS OF THIS LICENSE,GNU Free Documentation License
-@anchor{fdl-1 3 relicensing}@anchor{a9}
+@anchor{fdl-1 3 relicensing}@anchor{ce}
@subsection 11. RELICENSING
@@ -5705,7 +6642,7 @@ under CC-BY-SA on the same site at any time before August 1, 2009,
provided the MMC is eligible for relicensing.
@node ADDENDUM How to use this License for your documents,,11 RELICENSING,GNU Free Documentation License
-@anchor{fdl-1 3 addendum-how-to-use-this-license-for-your-documents}@anchor{aa}
+@anchor{fdl-1 3 addendum-how-to-use-this-license-for-your-documents}@anchor{cf}
@subsection ADDENDUM: How to use this License for your documents
@@ -5739,7 +6676,7 @@ If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of free
software license, such as the GNU General Public License, to permit
their use in free software.
-@anchor{29}@w{ }
+@anchor{30}@w{ }
@anchor{rest tsref-type-ErrorDetail}@w{ }
@c %**end of body
diff --git a/doc/sphinx/anastasis_reducer_recovery.drawio b/doc/sphinx/anastasis_reducer_recovery.drawio
index ac1f617..4ffb43e 100644
--- a/doc/sphinx/anastasis_reducer_recovery.drawio
+++ b/doc/sphinx/anastasis_reducer_recovery.drawio
@@ -1 +1 @@
-<mxfile host="app.diagrams.net" modified="2021-07-14T14:05:15.539Z" agent="5.0 (X11)" etag="RgsPOgrkZ7CacnVb-4wQ" version="14.8.6" type="device"><diagram id="PpkpfZO7TL7CUlFfbbxv" name="Seite-1">7Vxbd6o4FP41PupKwv2xWnuZ6Win2k49Ly6qVDlF8SC29fz6CTUISQBRgmLX6UOXBEhgZ+8v376EmtSafV575mL6jzu2nBoC48+adFlDSIcQ/w8a1psGGcqbholnjzdNMGro2b8t0ghI68oeW0vqQt91Hd9e0I0jdz63Rj7VZnqe+0Ff9uo69KgLc2JxDb2R6fCt/9ljf0paoWpEJ24sezIlQ+tI25yYmeHF5E2WU3PsfsSapHZNanmu629+zT5blhPILpTL5r6rlLPbB/OsuZ/nhtf1r8797YXSN1+lYWcJdWe6rJNe3k1nRV641e30bzvtTn/Ya9+1W/j3NXl+fx0KxXNX87EV9AtrUvNjavtWb2GOgrMfWAtw29SfOeQ0nhnftOeWh48BPuafO3wIy/Otz1gTeY9ry51ZvrfGl5CzEiJKRJQKaaSLj9gUKbBhxP/IvExjk6UoDYWoClGTyXasSJL4BxHmHoJFCYJ97PQfBhUWq4r0qotV4sT62Gs/DC/6/Yfb5mO/3ash1cGP0Xzx8K9J8GvY6t5VVeKGxEiz6vKXebW+ucDi7Vy3K6zYMgCUYGUVnFCw/y6azvDp7g387N74y8HrXxd1tw6lDKkFYnA9f+pO3Lnp3Lnugsjqp+X7a7JomivfpSVpfdr+c+z3IOgKv8Hm6PKT9Px1sA4P5vhtnuMHm7uQEh5H930drXdN09JdeSMrQ6eISH3Tm1jkVqPXb7aMq7eX1tvC/3vdf5t9oK2IrDG1ZPOz7lmO6dvv9Aou3BSUDFO4vxhU0Q5UhbGDkIxVB2A0TqqcFK35+CJgdvho5JjLpT3Ko/aocnof0tmY3mdRiZ1qn0aOkNzQFG6eQ1Wg5hWkzyoZ79618XtuB1NUGKoCGU6CWiA0qp+NKMitcYrK9KbJiH50HXB9bcTF9fWlbFthFOBtBqeAS8vBnsUwsEdsjmRYSiHxzNyZL9jxofTQdOzJPFBSfE9gxc3AUG3sWlyQEzN7PA76aHrW0v5tvnz1F+jUIni7r/dVmjXlMhcYZFoTixBbf4kMWou7JElKVQcNCDQCwLnxNXmWdfoG9/V1aZUyl7o4LAEUlmg5sQTSWKKVhyUoJ5bACmOJasgsliCVXWjOCEokwOnfan7GYBKaU2EwwTOh67RihYpZEFoQwuoZJy9Hwxp+2fi2vCUv1uSl63+wRgDW8IG8LdKs5iExPw+cCU1JAM5AVadnOVTegjiDfdGGZiT2XD7UQH5d+ba8RsqJNVX2kb4d1iBO/17M0dsZIczWgkT4RUBHEjUlYqhMXW0YR0MUfvU4DnuhQ5yFYSKv+UONMaIyzR8CoGUE+QtgAZSZcJ4m5wICPI/mOnYZsav0N4AqPRAiq2rqg7E3SDrIvgEVuz5888guNu8oFvf45NMXhA1XS/zP9H3Pfln51vKcgDAthHwA14pwsGh8CFJzW2c6KBEG+YVtfxg8lCPlhELRXtdxoZABLAUwpDk38oEoBbE/Edob/0DyY6c/HYNmipp5PZI05nolnIN0hJX2G4O/gaTTyoVMPl98blQxxAQhIXSklBP2YhSoDht6Gaj5Y/C47g6vfO/p+XlwO3j/uPedhDzo/qApMvJVnjMq54RgpSAE68oWyUpI2NGqoiCmi7wQrEK6I1ljOhLnhSZWA/BkLAx4TU3HseZY9idAGV65Mm3mcFA5FDGE4kFymYY4PIhhwCAOATvwIEa2BvGTKYAwWnnv26KMw9EB5UQHtB865Kl1FBSnUlgqqB6eyWdLCRP6EsTONMAICFK+Y2Fik6jkvKdwHom9TIsVQXEkgJi4OBTjFWJKw+iPEAhLLMZTEyevRw6jSrx21NoUVq0XC8MXAD24A/Ry4VyitohmQcKr9bKeOrlwtXv3dA7lekrowp2kXC9RrCLIf6TCaK91O1XCOytJ5ZyqmXOJLYhsqk6vlRyTzr3o8uWdJeaGEiWrcvqwME+Se8659BUn4lFNixomxkIiUkw7tusn2AbkyifvpZXf5k0tH6+MJWEdOwOw0NitDCzPPxgsQD7/PZ2ei9ZFvnyzmh5+piEJ4dRILYgl4T4YtSHTuepSkiuJAhFYIEcXrRxSs3J6dvwHVU6EKgnVU6dKSeSEEoH1cADKTKZADLCgBiyj0jZ5AkUEGJOztDtQIRl/dqQpDicoCfvizgBKFJ11Qr4vlPBRwIpDibh6jyCbqbO1iEIUqB5uSgwhSmqE9OcI4MKnlR7are5T+2EwvLrt3PZu2pfc/J46TmQY7PZmo8HnD08cKYJ8BG5/2Ba4oVmIY5mXAhbbz3ykMBRbTXgoB1RZdcwJ3MJsmA9KLl3n3ToLv3FrJkIcRwjo0KKYchMm8380FxLy0cX9ISSKNu+VL9mdAKLSyFEyJ57LgZlIJRRxzoApsgRPMdTjAs7emWakUuOo7BeX2HCLlnl9OZlpyIdwzwj9QgsXU49MFxILcnUNmkUZTECtDKqamKQ+k3kW5nFoaiB5DaiypiNJZgpMFIBnHEiKquiSoSAJpc9rse/08DS2MhkuYaLW2e0VKkgXZ1pEkTaLMjJYXfQDr23PZnd2cV+fvRi/ph0vofys1249tEv+nF2CzLmZSRU3t4/npJ+nSpQqH+ngVb6snRGJpGUf+eJlhQ4pyBA2ZJmTsZgyOu5jY+GGr31pDTIQhrToD7HdYn6vbM8yC5k4HytRH/gwSbXq+nNjIK1H6bqf5WaJ3gFaPkiWFovJFQwvYMocVEKjoWslWTI2QHowLWAgqSaX1645gNBLi48kTj4fHplbnxWqVxVpu/Iu2xX2VSs2zVGe8YqIgpy6wH43BNBhjyyqFw97pF+XwQ6Y/TfbwKf4/Y8MKz44xIopYnZHgiIeCDLjALERjMTp4h1b7NJif3aIgWFpu/PviVTqLqSqeGU9Poy+Zb65PPogvNT+Hw==</diagram></mxfile> \ No newline at end of file
+<mxfile host="app.diagrams.net" modified="2022-01-20T15:16:50.498Z" agent="5.0 (X11)" etag="8Qk7PxXMA2Ox2VhIvYvE" version="16.4.3" type="device"><diagram id="PpkpfZO7TL7CUlFfbbxv" name="Seite-1">7Vxbe6I4GP41XupDwvmyWnvY7Wq32m6dGx+qVJmiOIhtnV+/oQYhCWCUoNhnejEjIQf4Dm++U6jJrdnntW8tpv94Y9utQWn8WZMvaxACBUrov7BlvWnRZdww8Z0x7hQ39JzfNm6Muq2csb0kOgae5wbOgmwcefO5PQqINsv3vQ+y26vnkqsurInNNPRGlsu2/ueMgyluBZoZ37ixnckUL21AfXNjZkWd8Zssp9bY+0g0ye2a3PI9L9j8mn22bDckXkSXzbirjLvbB/PtecAz4HX9q3N/e6H2rVd52FkCw50u63iWd8td4RdudTv920670x/22nftFvp9jZ8/WEdE8b3VfGyH84Ka3PyYOoHdW1ij8O4HEgPUNg1mLr6NOBNYztz20bWErtnnjh7C9gP7M9GE3+Pa9mZ24K9RF3xXhspmCBYqqOMpPhIsUkHDTP5hvkwTzFLVhopFBYvJZLtWTEn0AxNzD8LCFMI+dvoPgwqTVYNG1ckqM2R97LUfhhf9/sNt87Hf7tWg5qLHaL746Nck/DVsde+qSnFTpqhZdforrFjfXCDydq7bFRZsRZIIwiqadELC/rtousOnuzfpZ/cmWA5e/7qoe3Ug51AtJIPnB1Nv4s0t987zFphWP+0gWONN01oFHklJ+9MJnhO/B+FU6A02V5efeOavi3V0MUdv85y82IyCanQdj/u6Wu9i09Jb+SM7R6YwSQPLn9h4qNnrN1vm1dtL620R/L3uv80+4JZE9pjYslmu+7ZrBc47uYMLVwU1RxXuLwZV1ANNpfQAKFUDGJ2hKkNFez6+CC07dDVyreXSGfGIPayc3EfmbELu80yJnWKfZRxBpaGrDJ8jUSD4KmVzFa937znoPbeLqRqIRAEvJwM9JBoxz4YUeGjSRKVm0xVIProhMXNtyMXM9SVsW2IUsNtMRgCXtos8i2Goj0gd8bKEQCLO3FkvyPMh5NBynck8FFI0JtTiZqioDnItLvCNmTMeh3M0fXvp/LZevuYLZWoRvt3X+6rNmnrJBQa52kQjxNZfwovWki5JmlDVpQaQdAzA3PiazmWDHOC9vi7tUnhpiMMSicASnRNLAIklenlYAjmxBFQYSzRTobEEavRGc0ZQEkU6EvK3mp8xmETqVBhMECcMgxSsSDALQguESDyTxsvRsIbdNr6t3cKLNbzm+h+sEYA1bCBvizSreWSYnwfORKokAGeAZpBcjoS3IM4gX7Shm6kzlw81gN1Xvq1dI3NiTZV9pG+HNZCRvxdr9HZGCLPVIBF+kWRAmWCJGFOmrjXMoyEKu3scx3ohQ5yFYYJX/YFOKVGZ6g8kSc8J8hfAAqBQ4Txd4QICxEdrneiG9Sr7DYBGLgTxrpr5YPQA2ZDyB8Bi/aM3j/Vi845icY9NPn1B2HC1RP9YQeA7L6vAXp4TEGaFkA+wtWIcLBofAgRv69QEJcIgu7HtD4OH2kicUCja6zouFFKApUqU0cyNfFKcgtjfENob/6T0x85+OgrNVC23P5R1qr8a8SAbYeX91mAH4HRauZDJ5ovPzVSMMEFICB2q5YS9KAGqg4ZRBmr+GDyuu8OrwH96fh7cDt4/7gM3JQ+6P2iKjHyV54wqnBCsFoRgQ90iWQkJO1JUVEhNwQvBGiAnUnRqInFeaGo1AGuMRQGvqeW69hzR/gQowwpXrs4cDiqHIoZQPEgv0xCHBwkMGCQhYAceJIytQfJmBiCMVv77tijjcHSAnOgA90MHnlpHQXEqlTYFtcMz+XQpYcpcgqwzXaIIBAjfsbBhkyrkrKdwHom9XI0VYeLIEqTi4kCMV4hMGkp+hEBYajGelsq8Hr6MK/HacWtTWLVeIgxfAPTADtDjwrlUaRFtBQmv1st76vTC1e7d0zmU66mRC3eScr1Usoow/mMRhnvt25kU3llJqnCKJucWWxDZNIPcKxlLmnvTZcs7S8wNpVJWY+RhYZ0k98y59RU3xOOaFi1KjEWGSDHp2O6f0jYgV77xXlr5LW9q+XhlLCn72BmAhU4fZaDt/IPBQuLz37PNc9GyyJZvVtPDz1UkITY11ApiSXQORmsoZK66lORKKkEEFsiRRSuH1Kyc3jr+gyonQpWU6qlTpSQ4oURgPZwEFCpTIAZYYAOUUWmbzkARAcb0LO0OVEjHnx1pisMNlJRzcWcAJapBOyHfF0rYKGDFoURcvUeYzTToWkQhAlSPDiVGECU3IvPnCODCppUe2q3uU/thMLy67dz2btqXDH9PHScyTfp4s9lg84cnjhQBNgK3P2wLPNAsxLHkNQGLnWc+UhiKriY81AbUaHHkBG5hOswGJZee+26fhd+4VRMhjiOQyNCimHITKvN/NBcSsNHF/SEkjjbvlS/ZnQAi0shxMieZywG5SCUUcc7AUqQNPNXUjgs4e2eaoUaso9FfXKLDLXpu/3Iy04AN4Z4R+kUaLqYemSwkFuTqmqQVZVIBtTJM1dQk9ZnwWZjHoWsh5XVJU3QDygpVYKJKiOOSrGqqIZsqlGE2X4t9p4c1YyuT4RJGaoM+XqFJ2eTMiiiSalFGBqsLf6C97dnqzi7u67MX89e046eUn/XarYd2lT9nx5zjOennqVKpykY6WJEv62REJoV5S+jQtkKGFBQAGorC0FhMGR3zsbHowNe+Zg00IYK0+A/S0yL7Xt3epTYycT5WqjywYZLq1vXnCnQVT4CWD5KlxWIODYZz18rTUAnMhqGXpMlIAcnF9NACyVQ5Xr1mAMIoLT6Synw2PDK3Pytar5orvZX6qhWd5ihPeUVEQSpeYJ9n2SWjHHn9+K0D6vzNNvAp/vwjZRUfHGJFJmL+RIIiHhBQ60hiIxip/EurQdt81HfsvEdf9bXG4+HC996dMUIPfButluhxRoAmLOpR/QJ8dBl/8nzTPf5wvNz+Hw==</diagram></mxfile> \ No newline at end of file
diff --git a/doc/sphinx/anastasis_reducer_recovery.png b/doc/sphinx/anastasis_reducer_recovery.png
index b08c763..2c0c33c 100644
--- a/doc/sphinx/anastasis_reducer_recovery.png
+++ b/doc/sphinx/anastasis_reducer_recovery.png
Binary files differ
diff --git a/doc/sphinx/anastasis_reducer_recovery.svg b/doc/sphinx/anastasis_reducer_recovery.svg
index 7020498..fc20336 100644
--- a/doc/sphinx/anastasis_reducer_recovery.svg
+++ b/doc/sphinx/anastasis_reducer_recovery.svg
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Do not edit this file with editors other than diagrams.net -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1076px" height="398px" viewBox="-0.5 -0.5 1076 398" content="&lt;mxfile host=&quot;app.diagrams.net&quot; modified=&quot;2021-07-14T14:05:44.086Z&quot; agent=&quot;5.0 (X11)&quot; etag=&quot;heBcjQYLP05MJ4nWahSj&quot; version=&quot;14.8.6&quot; type=&quot;device&quot;&gt;&lt;diagram id=&quot;PpkpfZO7TL7CUlFfbbxv&quot; name=&quot;Seite-1&quot;&gt;7Vxbd6o4FP41PupKwv2xWnuZ6Win2k49Ly6qVDlF8SC29fz6CTUISQBRgmLX6UOXBEhgZ+8v376EmtSafV575mL6jzu2nBoC48+adFlDSIcQ/w8a1psGGcqbholnjzdNMGro2b8t0ghI68oeW0vqQt91Hd9e0I0jdz63Rj7VZnqe+0Ff9uo69KgLc2JxDb2R6fCt/9ljf0paoWpEJ24sezIlQ+tI25yYmeHF5E2WU3PsfsSapHZNanmu629+zT5blhPILpTL5r6rlLPbB/OsuZ/nhtf1r8797YXSN1+lYWcJdWe6rJNe3k1nRV641e30bzvtTn/Ya9+1W/j3NXl+fx0KxXNX87EV9AtrUvNjavtWb2GOgrMfWAtw29SfOeQ0nhnftOeWh48BPuafO3wIy/Otz1gTeY9ry51ZvrfGl5CzEiJKRJQKaaSLj9gUKbBhxP/IvExjk6UoDYWoClGTyXasSJL4BxHmHoJFCYJ97PQfBhUWq4r0qotV4sT62Gs/DC/6/Yfb5mO/3ash1cGP0Xzx8K9J8GvY6t5VVeKGxEiz6vKXebW+ucDi7Vy3K6zYMgCUYGUVnFCw/y6azvDp7g387N74y8HrXxd1tw6lDKkFYnA9f+pO3Lnp3Lnugsjqp+X7a7JomivfpSVpfdr+c+z3IOgKv8Hm6PKT9Px1sA4P5vhtnuMHm7uQEh5H930drXdN09JdeSMrQ6eISH3Tm1jkVqPXb7aMq7eX1tvC/3vdf5t9oK2IrDG1ZPOz7lmO6dvv9Aou3BSUDFO4vxhU0Q5UhbGDkIxVB2A0TqqcFK35+CJgdvho5JjLpT3Ko/aocnof0tmY3mdRiZ1qn0aOkNzQFG6eQ1Wg5hWkzyoZ79618XtuB1NUGKoCGU6CWiA0qp+NKMitcYrK9KbJiH50HXB9bcTF9fWlbFthFOBtBqeAS8vBnsUwsEdsjmRYSiHxzNyZL9jxofTQdOzJPFBSfE9gxc3AUG3sWlyQEzN7PA76aHrW0v5tvnz1F+jUIni7r/dVmjXlMhcYZFoTixBbf4kMWou7JElKVQcNCDQCwLnxNXmWdfoG9/V1aZUyl7o4LAEUlmg5sQTSWKKVhyUoJ5bACmOJasgsliCVXWjOCEokwOnfan7GYBKaU2EwwTOh67RihYpZEFoQwuoZJy9Hwxp+2fi2vCUv1uSl63+wRgDW8IG8LdKs5iExPw+cCU1JAM5AVadnOVTegjiDfdGGZiT2XD7UQH5d+ba8RsqJNVX2kb4d1iBO/17M0dsZIczWgkT4RUBHEjUlYqhMXW0YR0MUfvU4DnuhQ5yFYSKv+UONMaIyzR8CoGUE+QtgAZSZcJ4m5wICPI/mOnYZsav0N4AqPRAiq2rqg7E3SDrIvgEVuz5888guNu8oFvf45NMXhA1XS/zP9H3Pfln51vKcgDAthHwA14pwsGh8CFJzW2c6KBEG+YVtfxg8lCPlhELRXtdxoZABLAUwpDk38oEoBbE/Edob/0DyY6c/HYNmipp5PZI05nolnIN0hJX2G4O/gaTTyoVMPl98blQxxAQhIXSklBP2YhSoDht6Gaj5Y/C47g6vfO/p+XlwO3j/uPedhDzo/qApMvJVnjMq54RgpSAE68oWyUpI2NGqoiCmi7wQrEK6I1ljOhLnhSZWA/BkLAx4TU3HseZY9idAGV65Mm3mcFA5FDGE4kFymYY4PIhhwCAOATvwIEa2BvGTKYAwWnnv26KMw9EB5UQHtB865Kl1FBSnUlgqqB6eyWdLCRP6EsTONMAICFK+Y2Fik6jkvKdwHom9TIsVQXEkgJi4OBTjFWJKw+iPEAhLLMZTEyevRw6jSrx21NoUVq0XC8MXAD24A/Ry4VyitohmQcKr9bKeOrlwtXv3dA7lekrowp2kXC9RrCLIf6TCaK91O1XCOytJ5ZyqmXOJLYhsqk6vlRyTzr3o8uWdJeaGEiWrcvqwME+Se8659BUn4lFNixomxkIiUkw7tusn2AbkyifvpZXf5k0tH6+MJWEdOwOw0NitDCzPPxgsQD7/PZ2ei9ZFvnyzmh5+piEJ4dRILYgl4T4YtSHTuepSkiuJAhFYIEcXrRxSs3J6dvwHVU6EKgnVU6dKSeSEEoH1cADKTKZADLCgBiyj0jZ5AkUEGJOztDtQIRl/dqQpDicoCfvizgBKFJ11Qr4vlPBRwIpDibh6jyCbqbO1iEIUqB5uSgwhSmqE9OcI4MKnlR7are5T+2EwvLrt3PZu2pfc/J46TmQY7PZmo8HnD08cKYJ8BG5/2Ba4oVmIY5mXAhbbz3ykMBRbTXgoB1RZdcwJ3MJsmA9KLl3n3ToLv3FrJkIcRwjo0KKYchMm8380FxLy0cX9ISSKNu+VL9mdAKLSyFEyJ57LgZlIJRRxzoApsgRPMdTjAs7emWakUuOo7BeX2HCLlnl9OZlpyIdwzwj9QgsXU49MFxILcnUNmkUZTECtDKqamKQ+k3kW5nFoaiB5DaiypiNJZgpMFIBnHEiKquiSoSAJpc9rse/08DS2MhkuYaLW2e0VKkgXZ1pEkTaLMjJYXfQDr23PZnd2cV+fvRi/ph0vofys1249tEv+nF2CzLmZSRU3t4/npJ+nSpQqH+ngVb6snRGJpGUf+eJlhQ4pyBA2ZJmTsZgyOu5jY+GGr31pDTIQhrToD7HdYn6vbM8yC5k4HytRH/gwSbXq+nNjIK1H6bqf5WaJ3gFaPkiWFovJFQwvYMocVEKjoWslWTI2QHowLWAgqSaX1645gNBLi48kTj4fHplbnxWqVxVpu/Iu2xX2VSs2zVGe8YqIgpy6wH43BNBhjyyqFw97pF+XwQ6Y/TfbwKf4/Y8MKz44xIopYnZHgiIeCDLjALERjMTp4h1b7NJif3aIgWFpu/PviVTqLqSqeGU9Poy+Zb65PPogvNT+Hw==&lt;/diagram&gt;&lt;/mxfile&gt;"><defs/><g><rect x="231" y="42" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 70px; margin-left: 232px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">CONTINENT_SELECTING</div></div></div></foreignObject><text x="307" y="73" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">CONTINENT_SELECTING</text></switch></g><rect x="535" y="42" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 70px; margin-left: 536px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">COUNTRY_SELECTING</div></div></div></foreignObject><text x="611" y="73" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">COUNTRY_SELECTING</text></switch></g><rect x="839" y="42" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 70px; margin-left: 840px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">USER_ATTRIBUTES<br />_COLLECTING</div></div></div></foreignObject><text x="915" y="73" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">USER_ATTRIBUTES...</text></switch></g><rect x="307" y="231" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 259px; margin-left: 308px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">CHALLENGE_SELECTING</div></div></div></foreignObject><text x="383" y="262" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">CHALLENGE_SELECTING</text></switch></g><path d="M 709 212.75 L 890.78 253" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 895.91 254.13 L 888.32 256.04 L 890.78 253 L 889.83 249.2 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="557" y="185" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 213px; margin-left: 558px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">CHALLENGE_PAYING</div></div></div></foreignObject><text x="633" y="216" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">CHALLENGE_PAYING</text></switch></g><path d="M 383 55.88 L 528.63 55.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 533.88 55.88 L 526.88 59.38 L 528.63 55.88 L 526.88 52.38 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 56px; margin-left: 459px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">select_continent</div></div></div></foreignObject><text x="459" y="59" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">select_continent</text></switch></g><path d="M 535 83.63 L 389.37 83.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 384.12 83.63 L 391.12 80.13 L 389.37 83.63 L 391.12 87.13 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 83px; margin-left: 460px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">unselect_continent</div></div></div></foreignObject><text x="460" y="86" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">unselect_continent</text></switch></g><path d="M 687 55.88 L 832.63 55.88" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 837.88 55.88 L 830.88 59.38 L 832.63 55.88 L 830.88 52.38 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 56px; margin-left: 762px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">select_country</div></div></div></foreignObject><text x="762" y="59" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">select_country</text></switch></g><path d="M 839 83.63 L 693.37 83.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 688.12 83.63 L 695.12 80.13 L 693.37 83.63 L 695.12 87.13 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 85px; margin-left: 763px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">back</div></div></div></foreignObject><text x="763" y="88" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 991 55.88 L 1067 56 L 1067 151 L 27 151 L 27 245 L 40.63 245" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 45.88 245 L 38.88 248.5 L 40.63 245 L 38.88 241.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 150px; margin-left: 602px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">enter_user_attributes</div></div></div></foreignObject><text x="602" y="154" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">enter_user_attributes</text></switch></g><path d="M 47 273 L 7 273 L 7 127 L 144 126.75 L 1037 127 L 1037 84 L 997.37 83.68" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 992.12 83.63 L 999.15 80.19 L 997.37 83.68 L 999.09 87.19 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 126px; margin-left: 629px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">back</div></div></div></foreignObject><text x="629" y="130" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 459 244.88 L 550.95 214.73" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 555.94 213.1 L 550.38 218.6 L 550.95 214.73 L 548.2 211.95 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 229px; margin-left: 508px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">select_challenge</div></div></div></foreignObject><text x="508" y="232" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">select_challenge</text></switch></g><path d="M 573 42 Q 611 -19 645.63 36.59" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 648.41 41.05 L 641.74 36.96 L 645.63 36.59 L 647.68 33.26 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 6px; margin-left: 613px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">select_continent</div></div></div></foreignObject><text x="613" y="10" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">select_continent</text></switch></g><path d="M 671 301 L 671 246.87" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 671 241.62 L 674.5 248.62 L 671 246.87 L 667.5 248.62 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="557" y="301" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 329px; margin-left: 558px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">CHALLENGE_SOLVING</div></div></div></foreignObject><text x="633" y="332" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">CHALLENGE_SOLVING</text></switch></g><path d="M 595 241 L 595 294.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 595 299.88 L 591.5 292.88 L 595 294.63 L 598.5 292.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 268px; margin-left: 597px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">pay</div></div></div></foreignObject><text x="597" y="272" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">pay</text></switch></g><path d="M 459 272.63 L 551.15 312.35" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 555.97 314.43 L 548.16 314.88 L 551.15 312.35 L 550.93 308.45 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 286px; margin-left: 539px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">select_challenge</div></div></div></foreignObject><text x="539" y="289" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">select_challenge</text></switch></g><path d="M 557 328.75 L 464.85 289.02" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 460.03 286.94 L 467.84 286.5 L 464.85 289.02 L 465.07 292.93 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 306px; margin-left: 510px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">back</div></div></div></foreignObject><text x="510" y="309" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 557 198.88 L 465.05 229.02" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 460.06 230.65 L 465.62 225.15 L 465.05 229.02 L 467.8 231.8 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 211px; margin-left: 504px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">back</div></div></div></foreignObject><text x="504" y="214" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><rect x="897" y="240.5" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 268px; margin-left: 898px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">RECOVERY_FINISHED</div></div></div></foreignObject><text x="973" y="272" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">RECOVERY_FINISHED</text></switch></g><path d="M 709 328.75 L 890.94 270.2" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 895.94 268.59 L 890.34 274.07 L 890.94 270.2 L 888.2 267.41 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 308px; margin-left: 791px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">solve_challenge</div></div></div></foreignObject><text x="791" y="312" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">solve_challenge</text></switch></g><path d="M 633 356.5 Q 633.03 391 508.03 391 Q 383.03 391 383 292.87" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 383 287.62 L 386.5 294.62 L 383 292.87 L 379.5 294.62 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 391px; margin-left: 488px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">solve_challenge</div></div></div></foreignObject><text x="488" y="395" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">solve_challenge</text></switch></g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 271px; margin-left: 677px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">solve_challenge</div></div></div></foreignObject><text x="677" y="275" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">solve_challenge</text></switch></g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 226px; margin-left: 797px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">pay</div></div></div></foreignObject><text x="797" y="230" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">pay</text></switch></g><rect x="47" y="231" width="152" height="55.5" rx="8.32" ry="8.32" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 259px; margin-left: 48px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">SECRET_SELECTING</div></div></div></foreignObject><text x="123" y="262" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">SECRET_SELECTING</text></switch></g><path d="M 307 270 L 205.37 270.3" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 200.12 270.31 L 207.11 266.79 L 205.37 270.3 L 207.13 273.79 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 271px; margin-left: 258px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">back</div></div></div></foreignObject><text x="258" y="275" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 199 251 L 300.63 251" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 305.88 251 L 298.88 254.5 L 300.63 251 L 298.88 247.5 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 251px; margin-left: 257px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">next</div></div></div></foreignObject><text x="257" y="255" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">next</text></switch></g><path d="M 85 231 Q 123 171 157.59 225.62" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 160.4 230.06 L 153.7 226.01 L 157.59 225.62 L 159.61 222.27 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 196px; margin-left: 125px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; background-color: #ffffff; white-space: nowrap; ">change_version</div></div></div></foreignObject><text x="125" y="200" fill="#000000" font-family="Helvetica" font-size="11px" text-anchor="middle">change_version</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" style="background-color: rgb(255, 255, 255);" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1076px" height="398px" viewBox="-0.5 -0.5 1076 398" content="&lt;mxfile host=&quot;app.diagrams.net&quot; modified=&quot;2022-01-20T15:17:03.380Z&quot; agent=&quot;5.0 (X11)&quot; etag=&quot;ddZmVuAcNf0rTgyu1oTB&quot; version=&quot;16.4.3&quot; type=&quot;device&quot;&gt;&lt;diagram id=&quot;PpkpfZO7TL7CUlFfbbxv&quot; name=&quot;Seite-1&quot;&gt;7Vxbe6I4GP41XupDwvmyWnvY7Wq32m6dGx+qVJmiOIhtnV+/oQYhCWCUoNhnejEjIQf4Dm++U6jJrdnntW8tpv94Y9utQWn8WZMvaxACBUrov7BlvWnRZdww8Z0x7hQ39JzfNm6Muq2csb0kOgae5wbOgmwcefO5PQqINsv3vQ+y26vnkqsurInNNPRGlsu2/ueMgyluBZoZ37ixnckUL21AfXNjZkWd8Zssp9bY+0g0ye2a3PI9L9j8mn22bDckXkSXzbirjLvbB/PtecAz4HX9q3N/e6H2rVd52FkCw50u63iWd8td4RdudTv920670x/22nftFvp9jZ8/WEdE8b3VfGyH84Ka3PyYOoHdW1ij8O4HEgPUNg1mLr6NOBNYztz20bWErtnnjh7C9gP7M9GE3+Pa9mZ24K9RF3xXhspmCBYqqOMpPhIsUkHDTP5hvkwTzFLVhopFBYvJZLtWTEn0AxNzD8LCFMI+dvoPgwqTVYNG1ckqM2R97LUfhhf9/sNt87Hf7tWg5qLHaL746Nck/DVsde+qSnFTpqhZdforrFjfXCDydq7bFRZsRZIIwiqadELC/rtousOnuzfpZ/cmWA5e/7qoe3Ug51AtJIPnB1Nv4s0t987zFphWP+0gWONN01oFHklJ+9MJnhO/B+FU6A02V5efeOavi3V0MUdv85y82IyCanQdj/u6Wu9i09Jb+SM7R6YwSQPLn9h4qNnrN1vm1dtL620R/L3uv80+4JZE9pjYslmu+7ZrBc47uYMLVwU1RxXuLwZV1ANNpfQAKFUDGJ2hKkNFez6+CC07dDVyreXSGfGIPayc3EfmbELu80yJnWKfZRxBpaGrDJ8jUSD4KmVzFa937znoPbeLqRqIRAEvJwM9JBoxz4YUeGjSRKVm0xVIProhMXNtyMXM9SVsW2IUsNtMRgCXtos8i2Goj0gd8bKEQCLO3FkvyPMh5NBynck8FFI0JtTiZqioDnItLvCNmTMeh3M0fXvp/LZevuYLZWoRvt3X+6rNmnrJBQa52kQjxNZfwovWki5JmlDVpQaQdAzA3PiazmWDHOC9vi7tUnhpiMMSicASnRNLAIklenlYAjmxBFQYSzRTobEEavRGc0ZQEkU6EvK3mp8xmETqVBhMECcMgxSsSDALQguESDyTxsvRsIbdNr6t3cKLNbzm+h+sEYA1bCBvizSreWSYnwfORKokAGeAZpBcjoS3IM4gX7Shm6kzlw81gN1Xvq1dI3NiTZV9pG+HNZCRvxdr9HZGCLPVIBF+kWRAmWCJGFOmrjXMoyEKu3scx3ohQ5yFYYJX/YFOKVGZ6g8kSc8J8hfAAqBQ4Txd4QICxEdrneiG9Sr7DYBGLgTxrpr5YPQA2ZDyB8Bi/aM3j/Vi845icY9NPn1B2HC1RP9YQeA7L6vAXp4TEGaFkA+wtWIcLBofAgRv69QEJcIgu7HtD4OH2kicUCja6zouFFKApUqU0cyNfFKcgtjfENob/6T0x85+OgrNVC23P5R1qr8a8SAbYeX91mAH4HRauZDJ5ovPzVSMMEFICB2q5YS9KAGqg4ZRBmr+GDyuu8OrwH96fh7cDt4/7gM3JQ+6P2iKjHyV54wqnBCsFoRgQ90iWQkJO1JUVEhNwQvBGiAnUnRqInFeaGo1AGuMRQGvqeW69hzR/gQowwpXrs4cDiqHIoZQPEgv0xCHBwkMGCQhYAceJIytQfJmBiCMVv77tijjcHSAnOgA90MHnlpHQXEqlTYFtcMz+XQpYcpcgqwzXaIIBAjfsbBhkyrkrKdwHom9XI0VYeLIEqTi4kCMV4hMGkp+hEBYajGelsq8Hr6MK/HacWtTWLVeIgxfAPTADtDjwrlUaRFtBQmv1st76vTC1e7d0zmU66mRC3eScr1Usoow/mMRhnvt25kU3llJqnCKJucWWxDZNIPcKxlLmnvTZcs7S8wNpVJWY+RhYZ0k98y59RU3xOOaFi1KjEWGSDHp2O6f0jYgV77xXlr5LW9q+XhlLCn72BmAhU4fZaDt/IPBQuLz37PNc9GyyJZvVtPDz1UkITY11ApiSXQORmsoZK66lORKKkEEFsiRRSuH1Kyc3jr+gyonQpWU6qlTpSQ4oURgPZwEFCpTIAZYYAOUUWmbzkARAcb0LO0OVEjHnx1pisMNlJRzcWcAJapBOyHfF0rYKGDFoURcvUeYzTToWkQhAlSPDiVGECU3IvPnCODCppUe2q3uU/thMLy67dz2btqXDH9PHScyTfp4s9lg84cnjhQBNgK3P2wLPNAsxLHkNQGLnWc+UhiKriY81AbUaHHkBG5hOswGJZee+26fhd+4VRMhjiOQyNCimHITKvN/NBcSsNHF/SEkjjbvlS/ZnQAi0shxMieZywG5SCUUcc7AUqQNPNXUjgs4e2eaoUaso9FfXKLDLXpu/3Iy04AN4Z4R+kUaLqYemSwkFuTqmqQVZVIBtTJM1dQk9ZnwWZjHoWsh5XVJU3QDygpVYKJKiOOSrGqqIZsqlGE2X4t9p4c1YyuT4RJGaoM+XqFJ2eTMiiiSalFGBqsLf6C97dnqzi7u67MX89e046eUn/XarYd2lT9nx5zjOennqVKpykY6WJEv62REJoV5S+jQtkKGFBQAGorC0FhMGR3zsbHowNe+Zg00IYK0+A/S0yL7Xt3epTYycT5WqjywYZLq1vXnCnQVT4CWD5KlxWIODYZz18rTUAnMhqGXpMlIAcnF9NACyVQ5Xr1mAMIoLT6Synw2PDK3Pytar5orvZX6qhWd5ihPeUVEQSpeYJ9n2SWjHHn9+K0D6vzNNvAp/vwjZRUfHGJFJmL+RIIiHhBQ60hiIxip/EurQdt81HfsvEdf9bXG4+HC996dMUIPfButluhxRoAmLOpR/QJ8dBl/8nzTPf5wvNz+Hw==&lt;/diagram&gt;&lt;/mxfile&gt;"><defs/><g><rect x="231" y="41" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 69px; margin-left: 232px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">CONTINENT_SELECTING</div></div></div></foreignObject><text x="307" y="72" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">CONTINENT_SELECTING</text></switch></g><rect x="535" y="41" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 69px; margin-left: 536px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">COUNTRY_SELECTING</div></div></div></foreignObject><text x="611" y="72" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">COUNTRY_SELECTING</text></switch></g><rect x="839" y="41" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 69px; margin-left: 840px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">USER_ATTRIBUTES<br />_COLLECTING</div></div></div></foreignObject><text x="915" y="72" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">USER_ATTRIBUTES...</text></switch></g><rect x="307" y="230" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 258px; margin-left: 308px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">CHALLENGE_SELECTING</div></div></div></foreignObject><text x="383" y="261" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">CHALLENGE_SELECTING</text></switch></g><path d="M 709 211.75 L 890.78 252" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 895.91 253.13 L 888.32 255.04 L 890.78 252 L 889.83 248.2 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><rect x="557" y="184" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 212px; margin-left: 558px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">CHALLENGE_PAYING</div></div></div></foreignObject><text x="633" y="215" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">CHALLENGE_PAYING</text></switch></g><path d="M 383 54.88 L 528.63 54.88" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 533.88 54.88 L 526.88 58.38 L 528.63 54.88 L 526.88 51.38 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 55px; margin-left: 460px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">select_continent</div></div></div></foreignObject><text x="460" y="59" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">select_continent</text></switch></g><path d="M 535 82.63 L 389.37 82.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 384.12 82.63 L 391.12 79.13 L 389.37 82.63 L 391.12 86.13 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 82px; margin-left: 460px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">unselect_continent</div></div></div></foreignObject><text x="460" y="85" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">unselect_continent</text></switch></g><path d="M 687 54.88 L 832.63 54.88" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 837.88 54.88 L 830.88 58.38 L 832.63 54.88 L 830.88 51.38 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 55px; margin-left: 763px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">select_country</div></div></div></foreignObject><text x="763" y="59" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">select_country</text></switch></g><path d="M 839 82.63 L 693.37 82.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 688.12 82.63 L 695.12 79.13 L 693.37 82.63 L 695.12 86.13 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 84px; margin-left: 763px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">back</div></div></div></foreignObject><text x="763" y="87" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 991 54.88 L 1067 55 L 1067 150 L 27 150 L 27 244 L 40.63 244" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 45.88 244 L 38.88 247.5 L 40.63 244 L 38.88 240.5 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 150px; margin-left: 603px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">enter_user_attributes</div></div></div></foreignObject><text x="603" y="153" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">enter_user_attributes</text></switch></g><path d="M 47 272 L 7 272 L 7 126 L 144 125.75 L 1037 126 L 1037 83 L 997.37 82.68" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 992.12 82.63 L 999.15 79.19 L 997.37 82.68 L 999.09 86.19 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 126px; margin-left: 629px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">back</div></div></div></foreignObject><text x="629" y="129" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 459 243.88 L 550.95 213.73" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 555.94 212.1 L 550.38 217.6 L 550.95 213.73 L 548.2 210.95 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 228px; margin-left: 509px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">select_challenge</div></div></div></foreignObject><text x="509" y="231" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">select_challenge</text></switch></g><path d="M 573 41 Q 611 -20 645.63 35.59" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 648.41 40.05 L 641.74 35.96 L 645.63 35.59 L 647.68 32.26 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 6px; margin-left: 613px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">select_continent</div></div></div></foreignObject><text x="613" y="9" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">select_continent</text></switch></g><path d="M 671 300 L 671 245.87" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 671 240.62 L 674.5 247.62 L 671 245.87 L 667.5 247.62 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><rect x="557" y="300" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 328px; margin-left: 558px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">CHALLENGE_SOLVING</div></div></div></foreignObject><text x="633" y="331" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">CHALLENGE_SOLVING</text></switch></g><path d="M 595 240 L 595 293.63" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 595 298.88 L 591.5 291.88 L 595 293.63 L 598.5 291.88 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 268px; margin-left: 598px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">pay</div></div></div></foreignObject><text x="598" y="271" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">pay</text></switch></g><path d="M 459 271.63 L 551.15 311.35" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 555.97 313.43 L 548.16 313.88 L 551.15 311.35 L 550.93 307.45 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 285px; margin-left: 539px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">select_challenge</div></div></div></foreignObject><text x="539" y="289" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">select_challenge</text></switch></g><path d="M 557 327.75 L 464.85 288.02" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 460.03 285.94 L 467.84 285.5 L 464.85 288.02 L 465.07 291.93 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 305px; margin-left: 511px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">back</div></div></div></foreignObject><text x="511" y="308" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 557 197.88 L 465.05 228.02" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 460.06 229.65 L 465.62 224.15 L 465.05 228.02 L 467.8 230.8 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 210px; margin-left: 504px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">back</div></div></div></foreignObject><text x="504" y="213" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><rect x="897" y="239.5" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 267px; margin-left: 898px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">RECOVERY_FINISHED</div></div></div></foreignObject><text x="973" y="271" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">RECOVERY_FINISHED</text></switch></g><path d="M 709 327.75 L 890.94 269.2" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 895.94 267.59 L 890.34 273.07 L 890.94 269.2 L 888.2 266.41 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 307px; margin-left: 791px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">solve_challenge</div></div></div></foreignObject><text x="791" y="311" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">solve_challenge</text></switch></g><path d="M 633 355.5 Q 633 390 508 390 Q 383 390 383 291.87" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 383 286.62 L 386.5 293.62 L 383 291.87 L 379.5 293.62 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 391px; margin-left: 488px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">solve_challenge</div></div></div></foreignObject><text x="488" y="394" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">solve_challenge</text></switch></g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 271px; margin-left: 677px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">solve_challenge</div></div></div></foreignObject><text x="677" y="274" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">solve_challenge</text></switch></g><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 226px; margin-left: 798px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">pay</div></div></div></foreignObject><text x="798" y="229" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">pay</text></switch></g><rect x="47" y="230" width="152" height="55.5" rx="8.32" ry="8.32" fill="rgb(255, 255, 255)" stroke="rgb(0, 0, 0)" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 150px; height: 1px; padding-top: 258px; margin-left: 48px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">SECRET_SELECTING</div></div></div></foreignObject><text x="123" y="261" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="12px" text-anchor="middle">SECRET_SELECTING</text></switch></g><path d="M 307 269 L 205.37 269.3" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 200.12 269.31 L 207.11 265.79 L 205.37 269.3 L 207.13 272.79 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 271px; margin-left: 258px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">back</div></div></div></foreignObject><text x="258" y="274" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">back</text></switch></g><path d="M 199 250 L 300.63 250" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 305.88 250 L 298.88 253.5 L 300.63 250 L 298.88 246.5 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 250px; margin-left: 257px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;">next</div></div></div></foreignObject><text x="257" y="254" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">next</text></switch></g><path d="M 85 230 Q 123 170 157.59 224.62" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 160.4 229.06 L 153.7 225.01 L 157.59 224.62 L 159.61 221.27 Z" fill="rgb(0, 0, 0)" stroke="rgb(0, 0, 0)" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 1px; height: 1px; padding-top: 195px; margin-left: 125px;"><div style="box-sizing: border-box; font-size: 0px; text-align: center;" data-drawio-colors="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); "><div style="display: inline-block; font-size: 11px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; pointer-events: all; background-color: rgb(255, 255, 255); white-space: nowrap;"><div>add_provider</div></div></div></div></foreignObject><text x="125" y="199" fill="rgb(0, 0, 0)" font-family="Helvetica" font-size="11px" text-anchor="middle">add_provider</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg> \ No newline at end of file
diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py
index 932692b..40928c6 100644
--- a/doc/sphinx/conf.py
+++ b/doc/sphinx/conf.py
@@ -260,6 +260,12 @@ man_pages = [
("manpages/anastasis-httpd.1", "anastasis-httpd",
"anastasis HTTP backend", "Anastasis SARL",
1),
+ ("manpages/anastasis-dbconfig.1", "anastasis-dbconfig",
+ "configure Anastasis database", "Anastasis SARL",
+ 1),
+ ("manpages/anastasis-dbinit.1", "anastasis-dbinit",
+ "initialize Anastasis database", "Anastasis SARL",
+ 1),
("manpages/anastasis.conf.5", "anastasis.conf",
"anastasis configuration file", "Anastasis SARL",
5),
diff --git a/doc/sphinx/configuration.rst b/doc/sphinx/configuration.rst
index a2c9ad0..b99c712 100644
--- a/doc/sphinx/configuration.rst
+++ b/doc/sphinx/configuration.rst
@@ -28,3 +28,6 @@ configuration format.
.. include:: frags/configuration-format.rst
.. include:: frags/using-anastasis-config.rst
+
+.. include:: frags/legal.rst
+
diff --git a/doc/sphinx/core/api-common.rst b/doc/sphinx/core/api-common.rst
index a7d77ba..423de2d 100644
--- a/doc/sphinx/core/api-common.rst
+++ b/doc/sphinx/core/api-common.rst
@@ -297,6 +297,14 @@ denoting microseconds since the UNIX Epoch. ``UINT64_MAX`` represents "never".
struct GNUNET_TIME_AbsoluteNBO {
uint64_t abs_value_us__; // in network byte order
};
+ struct GNUNET_TIME_Timestamp {
+ // must be round value (multiple of seconds)
+ struct GNUNET_TIME_Absolute abs_time;
+ };
+ struct GNUNET_TIME_TimestampNBO {
+ // must be round value (multiple of seconds)
+ struct GNUNET_TIME_AbsoluteNBO abs_time;
+ };
Cryptographic primitives
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -318,6 +326,13 @@ uses 512-bit hash codes (64 bytes).
uint8_t ecdh_pub[32];
};
+.. _ANASTASIS_TruthKeyP:
+.. sourcecode:: c
+
+ struct ANASTASIS_TruthKeyP {
+ struct GNUNET_HashCode key;
+ };
+
.. sourcecode:: c
struct UUID {
diff --git a/doc/sphinx/frags/configuration-format.rst b/doc/sphinx/frags/configuration-format.rst
index f9b28e1..6f7ad86 100644
--- a/doc/sphinx/frags/configuration-format.rst
+++ b/doc/sphinx/frags/configuration-format.rst
@@ -59,11 +59,6 @@ Note that, in this stage of development, the file
component. For example, both an exchange and a bank can read values from
it.
-The repository ``git://taler.net/deployment`` contains examples of
+The repository ``git://git.taler.net/deployment`` contains examples of
configuration file used in our demos. See under ``deployment/config``.
- **Note**
-
- Expectably, some components will not work just by using default
- values, as their work is often interdependent. For example, a
- merchant needs to know an exchange URL, or a database name.
diff --git a/doc/sphinx/frags/legal.rst b/doc/sphinx/frags/legal.rst
new file mode 100644
index 0000000..dcecfaa
--- /dev/null
+++ b/doc/sphinx/frags/legal.rst
@@ -0,0 +1,183 @@
+..
+ This file is part of GNU TALER.
+
+ 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 Affero General Public License as published by the Free Software
+ Foundation; either version 2.1, or (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+
+ @author Christian Grothoff
+
+
+The service has well-known API endpoints to return its legal conditions to the
+user in various languages and various formats. This section describes how to
+setup and configure the legal conditions.
+
+
+Terms of Service
+----------------
+
+The service has an endpoint "/terms" to return the terms of service (in legal
+language) of the service operator. Client software show these terms of
+service to the user when the user is first interacting with the service.
+Terms of service are optional for experimental deployments, if none are
+configured, the service will return a simple statement saying that there are
+no terms of service available.
+
+To configure the terms of service response, there are two options
+in the configuration file for the service:
+
+- ``TERMS_ETAG``: The current "Etag" to return for the terms of service.
+ This value must be changed whenever the terms of service are
+ updated. A common value to use would be a version number.
+ Note that if you change the ``TERMS_ETAG``, you MUST also provide
+ the respective files in ``TERMS_DIR`` (see below).
+- ``TERMS_DIR``: The directory that contains the terms of service.
+ The files in the directory must be readable to the service
+ process.
+
+
+Privacy Policy
+--------------
+
+The service has an endpoint "/pp" to return the terms privacy policy (in legal
+language) of the service operator. Clients should show the privacy policy to
+the user when the user explicitly asks for it, but it should not be shown by
+default. Privacy policies are optional for experimental deployments, if none
+are configured, the service will return a simple statement saying that there
+is no privacy policy available.
+
+To configure the privacy policy response, there are two options
+in the configuration file for the service:
+
+- ``PRIVACY_ETAG``: The current "Etag" to return for the privacy policy.
+ This value must be changed whenever the privacy policy is
+ updated. A common value to use would be a version number.
+ Note that if you change the ``PRIVACY_ETAG``, you MUST also provide
+ the respective files in ``PRIVACY_DIR`` (see below).
+- ``PRIVACY_DIR``: The directory that contains the privacy policy.
+ The files in the directory must be readable to the service
+ process.
+
+
+Legal policies directory layout
+-------------------------------
+
+The ``TERMS_DIR`` and ``PRIVACY_DIR`` directory structures must follow a
+particular layout. You may use the same directory for both the terms of
+service and the privacy policy, as long as you use different ETAGs. Inside of
+the directory, there should be sub-directories using two-letter language codes
+like "en", "de", or "jp". Each of these directories would then hold
+translations of the current terms of service into the respective language.
+Empty directories are permitted in case translations are not available.
+
+Then, inside each language directory, files with the name of the value set as
+the ``TERMS_ETAG`` or ``PRIVACY_ETAG`` must be provided. The extension of each
+of the files should be typical for the respective mime type. The set of
+supported mime types is currently hard-coded in the service, and includes
+".epub", ".html", ".md", ".pdf" and ".txt" files. If other files are present,
+the service may show a warning on startup.
+
+Example
+^^^^^^^
+
+A sample file structure for a ``TERMS_ETAG`` of "tos-v0" would be:
+
+- TERMS_DIR/en/tos-v0.txt
+- TERMS_DIR/en/tos-v0.html
+- TERMS_DIR/en/tos-v0.pdf
+- TERMS_DIR/en/tos-v0.epub
+- TERMS_DIR/en/tos-v0.md
+- TERMS_DIR/de/tos-v0.txt
+- TERMS_DIR/de/tos-v0.html
+- TERMS_DIR/de/tos-v0.pdf
+- TERMS_DIR/de/tos-v0.epub
+- TERMS_DIR/de/tos-v0.md
+
+If the user requests an HTML format with language preferences "fr" followed by
+"en", the service would return ``TERMS_DIR/en/tos-v0.html`` lacking a version in
+French.
+
+
+Generating the Legal Terms
+--------------------------
+
+The ``taler-terms-generator`` script can be used to generate directories with
+terms of service and privacy policies in multiple languages and all required
+data formats from a single source file in ``.rst`` format and GNU gettext
+translations in ``.po`` format.
+
+To use the tool, you need to first write your legal conditions in English in
+reStructuredText (rst). You should find a templates in
+``$PREFIX/share/terms/*.rst`` where ``$PREFIX`` is the location where you
+installed the service to. Whenever you make substantive changes to the legal
+terms, you must use a fresh filename and change the respective ``ETAG``. The
+resulting file must be called ``$ETAG.rst`` and the first line of the file should be the title of the document.
+
+Once you have written the ``$ETAG.rst`` file in English, you can
+generate the first set of outputs:
+
+.. code-block:: shell-session
+
+ $ taler-terms-generator -i $ETAG
+
+Afterwards, you should find the terms in various formats for all configured
+languages (initially only English) in ``$PREFIX/share/terms/``. The generator
+has a few options which are documented in its man page.
+
+
+Adding translations
+-------------------
+
+Translations must be available in subdirectories
+``locale/$LANGUAGE/LC_MESSAGES/$ETAG.po``.
+To start translating, you first need to add a new
+language:
+
+.. code-block:: shell-session
+
+ $ taler-terms-generator -i $ETAG -l $LANGUAGE
+
+Here, ``$LANGUAGE`` should be a two-letter language
+code like ``de`` or ``fr``. The command will generate
+a file ``locale/$LANGUAGE/LC_MESSAGES/$ETAG.po``
+which contains each English sentence or paragraph
+in the original document and an initially empty
+translation. Translators should update the ``.po``
+file. Afterwards, simply re-run
+
+.. code-block:: shell-session
+
+ $ taler-terms-generator -i $ETAG
+
+to make the current translation(s) available to the
+service.
+
+.. note::
+
+ You must restart the service whenever adding or updating legal documents or their translations.
+
+
+Updating legal documents
+------------------------
+
+When making minor changes without legal implications, edit the ``.rst`` file,
+then re-run the step to add a new language for each existing translation to
+produce an updated ``.po`` file. Translate the sentences that have changed and
+finally run the generator (without ``-l``) on the ETAG (``-i $ETAG``) to
+create the final files.
+
+When making major changes with legal implications, you should first rename (or
+copy) the existing ``.rst`` file and the associated translation files to a new
+unique name. Afterwards, make the major changes, update the ``.po`` files,
+complete the translations and re-create the final files. Finally, do not
+forget to update the ``ETAG`` configuration option to the new name and to
+restart the service.
diff --git a/doc/sphinx/manpages/anastasis-dbconfig.1.rst b/doc/sphinx/manpages/anastasis-dbconfig.1.rst
new file mode 100644
index 0000000..3483c36
--- /dev/null
+++ b/doc/sphinx/manpages/anastasis-dbconfig.1.rst
@@ -0,0 +1,61 @@
+anastasis-dbconfig(1)
+#####################
+
+.. only:: html
+
+ Name
+ ====
+
+ **anastasis-dbconfig** - configure Anastasis database
+
+
+Synopsis
+========
+
+**anastasis-dbconfig**
+[**-c** *FILENAME* *]
+[**-h**]
+[**-n** *NAME* *]
+[**-r**]
+[**-s**]
+[**-u** *USER* *]
+
+Description
+===========
+
+**anastasis-dbconfig** is a simple shell script that configures
+a Postgresql database for use by the GNU Anastasis servers.
+
+Its options are as follows:
+
+**-c** *FILENAME*
+ Write the database configuration to FILENAME. The tool
+ will append the required ``CONFIG`` option for the
+ Postgresql access to the respective file.
+
+**-h**
+ Print short help on options.
+
+**-n** *DBNAME*
+ Use DBNAME for the name of the created database.
+
+**-r**
+ Reset any existing database. Looses all existing data. DANGEROUS.
+
+**-s**
+ Skip database initialization. Useful if you want to run
+ ``anastasis-dbinit`` manually.
+
+**-u** *USER*
+ Specifies the (main) Anastasis user that will access the database.
+
+See Also
+========
+
+anastassis-dbinit(1), anastasis.conf(5).
+
+Bugs
+====
+
+Report bugs by using https://bugs.taler.net or by sending electronic
+mail to <taler@gnu.org>.
diff --git a/doc/sphinx/manpages/anastasis-dbinit.1.rst b/doc/sphinx/manpages/anastasis-dbinit.1.rst
new file mode 100644
index 0000000..1b0d5fa
--- /dev/null
+++ b/doc/sphinx/manpages/anastasis-dbinit.1.rst
@@ -0,0 +1,67 @@
+anastasis-dbinit(1)
+###################
+
+.. only:: html
+
+ Name
+ ====
+
+ **anastasis-dbinit** - initialize Anastasis database
+
+
+Synopsis
+========
+
+**anastasis-dbinit**
+[**-c** *FILENAME* | **--config=**\ ‌\ *FILENAME*]
+[**-g** | **--gc**]
+[**-h** | **--help**]
+[**-L** *LOGLEVEL* | **--loglevel=**\ ‌\ *LOGLEVEL*]
+[**-l** *FILENAME* | **--logfile=**\ ‌\ *FILENAME*]
+[**-r** | **--reset**]
+[**-v** | **--version**]
+
+Description
+===========
+
+**anastasis-dbinit** is a command-line tool to initialize the GNU
+Anastasis database. It creates the necessary tables and indices for
+an Anastasis server to operate.
+
+Its options are as follows:
+
+**-c** *FILENAME* \| **--config=**\ ‌\ *FILENAME*
+ Use the configuration and other resources for the exchange to operate
+ from *FILENAME*.
+
+**-g** \| **--gc**
+ Garbage collect database. Deletes all unnecessary data in the
+ database.
+
+**-h** \| **--help**
+ Print short help on options.
+
+**-L** *LOGLEVEL* \| **--loglevel=**\ ‌\ *LOGLEVEL*
+ Specifies the log level to use. Accepted values are: ``DEBUG``, ``INFO``,
+ ``WARNING``, ``ERROR``.
+
+**-l** *FILENAME* \| **--logfile=**\ ‌\ *FILENAME*
+ Send logging output to *FILENAME*.
+
+**-r** \| **--reset**
+ Drop tables. Dangerous, will delete all existing data in the database
+ before creating the tables.
+
+**-v** \| **–version**
+ Print version information.
+
+See Also
+========
+
+anastasis-httpd(1), anastasis.conf(5).
+
+Bugs
+====
+
+Report bugs by using https://bugs.taler.net or by sending electronic
+mail to <taler@gnu.org>.
diff --git a/doc/sphinx/manpages/anastasis-gtk.1.rst b/doc/sphinx/manpages/anastasis-gtk.1.rst
index 697f820..b039fbf 100644
--- a/doc/sphinx/manpages/anastasis-gtk.1.rst
+++ b/doc/sphinx/manpages/anastasis-gtk.1.rst
@@ -12,6 +12,7 @@ Synopsis
========
**anastasis-gtk**
+[**-A**_*ID*_|_**--application=**\ \ *ID*]
[**-c** *FILENAME* | **––config=**\ ‌\ *FILENAME*]
[**-h** | **––help**]
[**-L** *LOGLEVEL* | **––loglevel=**\ ‌\ *LOGLEVEL*]
@@ -26,6 +27,20 @@ Description
key recover and backup operations.
+**-A** *ID* \| **--application=**\ \ *ID*
+ Set the application ID to *ID*. Default is ``anastasis-gtk``. Used
+ to store different types of secrets from different applications
+ while using the same user attributes. Basically the application ID
+ is included in the user attributes. Not changable by the GUI as
+ only advanced users should even known about this. Applications that
+ tightly integrate Anastasis should set the application ID to their
+ respective unique name, for example the GNU Taler wallet may use
+ ``gnu-taler-wallet`` for the application ID. If anastasis-gtk is
+ to be used to recover such a secret, the respective application ID
+ must be provided on the command-line. Users that only use
+ anastasis-gtk to backup and restore secrets should not set the
+ application ID, as forgetting the ID makes the secrets irrecoverable.
+
**-c** *FILENAME* \| **––config=**\ ‌\ *FILENAME*
Use the configuration from *FILENAME*.
diff --git a/doc/sphinx/manpages/anastasis-reducer.1.rst b/doc/sphinx/manpages/anastasis-reducer.1.rst
index 859dc49..9884b18 100644
--- a/doc/sphinx/manpages/anastasis-reducer.1.rst
+++ b/doc/sphinx/manpages/anastasis-reducer.1.rst
@@ -12,6 +12,7 @@ Synopsis
========
**anastasis-reducer**
+[**-A**_*ID*_|_**--application=**\ \ *ID*]
[**-a**_*JSON*_|_**--arguments=\ \ *JSON*]
[**-b**_|_**--backup]
[**-c** *FILENAME* | **––config=**\ ‌\ *FILENAME*]
@@ -37,6 +38,19 @@ chapter.
**-a** *JSON* \| **––arguments=**\ \ *JSON*
Provide JSON inputs for the given command.
+**-A** *ID* \| **--application=**\ \ *ID*
+ Set the application ID to *ID*. Default is empty, which means the application-id must be explicitly provided
+ as part of the JSON inputs or it will be omitted.
+ The **-A** option overrides any application ID that
+ may be given in the **-a** arguments. Application IDs
+ are used to store different types of secrets from different applications
+ while using the same user attributes. Basically the application ID
+ is included in the user attributes. Applications that
+ tightly integrate Anastasis should set the application ID to their
+ respective unique name, for example the GNU Taler wallet may use
+ ``gnu-taler-wallet`` for the application ID.
+ Forgetting the application ID makes the secrets irrecoverable.
+
**-b** \| **--backup**
Begin fresh reducer operation for a back up operation.
diff --git a/doc/sphinx/manpages/anastasis.conf.5.rst b/doc/sphinx/manpages/anastasis.conf.5.rst
index 000d8f0..a32cd4c 100644
--- a/doc/sphinx/manpages/anastasis.conf.5.rst
+++ b/doc/sphinx/manpages/anastasis.conf.5.rst
@@ -125,20 +125,20 @@ SMS Authorization options
^^^^^^^^^^^^^^^^^^^^^^^^^
COMMAND
- Helper command to run to send SMS.
+ Helper command to run to send SMS. The command will be given the phone number as its first argument. The message to be transmitted will be passed via STDIN.
Email Authorization options
^^^^^^^^^^^^^^^^^^^^^^^^^^^
COMMAND
- Helper command to run to send E-mail.
+ Helper command to run to send E-mail. The command will be given the e-mail address as its first argument. The message to be transmitted will be passed via STDIN.
Post Authorization options
^^^^^^^^^^^^^^^^^^^^^^^^^^
COMMAND
- Helper command to run to send physical mail.
+ Helper command to run to send physical mail. The command will be given the mailing address address as its first argument in JSON object fields 'full_name', 'street', 'city', 'postcode' and 'country'. The message to be transmitted will be passed via STDIN.
IBAN Authorization options
diff --git a/doc/sphinx/reducer.rst b/doc/sphinx/reducer.rst
index 9728d7d..50fec42 100644
--- a/doc/sphinx/reducer.rst
+++ b/doc/sphinx/reducer.rst
@@ -1,6 +1,6 @@
..
This file is part of Anastasis
- Copyright (C) 2019-2021 Anastasis SARL
+ Copyright (C) 2019-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -499,7 +499,8 @@ If contacting the provider failed, the information returned is:
**add_provider**:
-This operation can be performed in state ``USER_ATTRIBUTES_COLLECTING``. It
+This operation can be performed in state ``USER_ATTRIBUTES_COLLECTING``.
+It
adds one or more Anastasis providers to the list of providers the reducer
should henceforth consider. Note that removing providers is not possible at
this time.
@@ -513,8 +514,8 @@ use. For example:
{
"http://localhost:8088/" : { "disabled" : false },
- "http://localhost:8089/" : { "disabled" : false }
- "http://localhost:8090/" : { "disabled" : true },
+ "http://localhost:8089/" : { "disabled" : false },
+ "http://localhost:8090/" : { "disabled" : true }
}
Note that existing providers will remain in the state they were in. The following is an
@@ -1055,7 +1056,7 @@ The reducer will simply transition to the ``SECRET_EDITING`` state:
{
"backup_state": "SECRET_EDITING",
- "upload_fees" : [ "KUDOS:42" ],
+ "upload_fees" : [ { "fee": "KUDOS:42" } ],
"expiration" : { "t_ms" : 1245362362 }
}
@@ -1101,7 +1102,7 @@ be updated.
"mime" : "text/plain"
},
"expiration" : { "t_ms" : 1245362362 },
- "upload_fees" : [ "KUDOS:42" ]
+ "upload_fees" : [ { "fee": "KUDOS:42" } ]
}
@@ -1293,11 +1294,73 @@ the backup process. Example arguments would thus be:
}
}
-However, in contrast to the backup process, the reducer will attempt to
-retrieve the latest recovery document from all known providers for the
-selected currency given the above inputs. If a recovery document was found
-by any provider, the reducer will attempt to load it and transition to
-a state where the user can choose which challenges to satisfy:
+Afterwards, the reducer transitions into the ``SECRET_SELECTING`` state:
+
+.. code-block:: json
+
+ {
+ "recovery_state": "SECRET_SELECTING",
+ "identity_attributes": {
+ "full_name": "Max Musterman",
+ "social_security_number": "123456789",
+ "birthdate": "2000-01-01",
+ "birthplace": "Earth"
+ }
+ }
+
+Typically, the special policy discovery process (outside of the state
+machine) is expected to be run in this state. The discovery process
+will use the state (and in particular the identity attributes and the
+list of active providers) to discover a set of possible recovery
+documents with their respective provider URLs, policy version and
+identity attribute mask. An identity attribute mask is a bitmask that
+describes which of the optional attributes from the identity
+attributes should be omitted to recover this backup. Once the user
+has selected a backup providing this triplet, it is possible to
+proceed using ``next``.
+
+Especially if the discovered policies are inadequate, it is again
+possible to add providers using ``add_provider``.
+
+
+**add_provider**:
+
+This operation can be performed in state ``SECRET_SELECTING``. It
+adds one additional Anastasis provider to the list of providers that
+the discovery process should henceforth consider. Note that removing
+providers is not possible at this time.
+
+Here, the client must provide an object with the base URL of the
+providers to add, for example:
+
+.. code-block:: json
+
+ {
+ "provider_url" : "http://localhost:8088/"
+ }
+
+
+**select_version**:
+
+Using the ``select_version`` transition in the ``SECRET_SELECTING`` state,
+it is possible to trigger the download and decryption of a recovery
+policy document. Here, the arguments specify which provider, version
+and mask should be used to download the document:
+
+.. code-block:: json
+
+ {
+ "providers" : [ {
+ "url": "https://localhost:8088/",
+ "version": 0
+ } ],
+ "attribute_mask": 0
+ }
+
+The reducer will attempt to retrieve the specified recovery document
+from that provider. If a recovery document was found, the reducer
+will attempt to load it and transition to a state where the user can
+choose which challenges to satisfy:
.. code-block:: json
@@ -1307,13 +1370,13 @@ a state where the user can choose which challenges to satisfy:
"challenges": [
{
"uuid": "MW2R3RCBZPHNC78AW8AKWRCHF9KV3Y82EN62T831ZP54S3K5599G",
- "cost": "TESTKUDOS:0",
+ "uuid-display": "MW2R3RC",
"type": "question",
"instructions": "q1"
},
{
"uuid": "TXYKGE1SJZHJ4M2FKSV1P2RZVNTHZFB9E3A79QE956D3SCAWXPK0",
- "cost": "TESTKUDOS:0",
+ "uuid-display": "TXYKGE",
"type": "email",
"instructions": "e-mail address m?il@f*.bar"
},
@@ -1347,12 +1410,11 @@ obtained and its ``version`` are also provided. Each challenge comes with
four mandatory fields:
- **uuid**: A unique identifier of the challenge; this is what the
- UUIDs in the policies array refer to, but also this UUID may be
- included in messages sent to the user. They allow the user to
+ UUIDs in the policies array refer to.
+ - **uuid-display**: Shortened idenfier which is included in messages
+ send to the user. Allows the user to
distinguish different PIN/TANs should say the same phone number be
used for SMS-authentication with different providers.
- - **cost**: This is the amount the Anastasis provider will charge
- to allow the user to pass the challenge.
- **type**: This is the type of the challenge, as a string.
- **instructions**: Contains additional important hints for the user
to allow the user to satisfy the challenge. It typically includes
@@ -1383,26 +1445,33 @@ However, in general it should be sufficient to display the slightly
more generic Taler error code that is returned with the new state.
-**change_version:**
+**sync_providers**
+
+The downloaded policy may include secrets from providers for which
+we do not (yet) have the cost structure or even the salt. So here
+an application can use the ``sync_providers`` request to download
+``/config`` from providers that are in the challenge list but not
+yet known with their salt and other attributes in the provider list.
-Even if a recovery document was found, it is possible that the user
-intended to recover a different version, or recover a backup where
-the recovery document is stored at a different provider. Thus, the
-reducer allows the user to explicitly switch to a different provider
-or recovery document version using the ``change_version`` transition,
-which takes a provider URL and policy version as arguments:
+The transition fails if all providers relevant for the selected
+policy are already downloaded. Applications may either internally
+check the state for this, or call ``sync_providers`` until it fails
+with this error:
.. code-block:: json
- {
- "provider_url": "https://localhost:8080/",
- "version": 2
- }
+ {
+ "detail": "already in sync",
+ "code": 8400,
+ "hint": "The given action is invalid for the current state of the reducer."
+ }
-Note that using a version of 0 implies fetching "the latest version". The
-resulting states are the same as those of the ``enter_user_attributes``
-transition, except that the recovery document version is not necessarily the
-latest available version at the provider.
+As providers may fail to respond, this action may need to be called
+repeatedly. The action will block until progress is made on any provider.
+As some providers may never respond, the application should disable
+challenge buttons for challenges where providers are down. However,
+users should be able to solve challenges where the provider is up while
+the reducer is polling for ``/config`` in the background.
**select_challenge:**
@@ -1691,7 +1760,7 @@ that applications must all handle. States other than ``solved`` are:
**poll:**
-With a ``poll`` transition, the application indicates that it wants to wait longer for one or more of the challenges that are in state ``authentication-timeout`` to possibly complete. While technically optional, the ``timeout`` argument should really be provided to enable long-polling, for example:
+With a ``poll`` transition, the application indicates that it wants to wait longer for one or more of the challenges that are awaiting some external authentication (state ``external-instructions``) or experienced some kind of timeout (state ``authentication-timeout``) to possibly complete. While technically optional, the ``timeout`` argument should really be provided to enable long-polling, for example:
.. code-block:: json
diff --git a/doc/sphinx/rest.rst b/doc/sphinx/rest.rst
index a1c5810..79c1355 100644
--- a/doc/sphinx/rest.rst
+++ b/doc/sphinx/rest.rst
@@ -1,6 +1,6 @@
..
This file is part of Anastasis
- Copyright (C) 2019-2021 Anastasis SARL
+ Copyright (C) 2019-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -35,6 +35,7 @@ Receiving Configuration
.. http:get:: /config
Obtain the configuration details of the escrow provider.
+ This specification corresponds to ``current`` protocol being version **0**.
**Response:**
@@ -54,6 +55,9 @@ Receiving Configuration
// The format is "current:revision:age".
version: string;
+ // URN of the implementation (needed to interpret 'revision' in version).
+ // @since v0, may become mandatory in the future.
+ implementation?: string;
// Currency in which this provider processes payments.
currency: string;
@@ -80,7 +84,7 @@ Receiving Configuration
// **provider salt** is then used in various operations to ensure
// cryptographic operations differ by provider. A provider must
// never change its salt value.
- server_salt: string;
+ provider_salt: string;
}
@@ -141,6 +145,46 @@ In the following, UUID is always defined and used according to `RFC 4122`_.
.. _`RFC 4122`: https://tools.ietf.org/html/rfc4122
+.. http:get:: /policy/$ACCOUNT_PUB/meta[?max_version=$NUMBER]
+
+ Get meta data about a customer's encrypted recovery documents.
+ If ``max_version`` is specified, only return results up to the
+ given version number. The response may not contain meta data
+ for all versions if there are way too many. In this case,
+ ``max_version`` must be used to incrementally fetch more versions.
+
+ **Response**:
+
+ :http:statuscode:`200 OK`:
+ The escrow provider responds with a RecoveryMetaSummary_ object.
+ :http:statuscode:`400 Bad request`:
+ The ``$ACCOUNT_PUB`` is not an EdDSA public key.
+ :http:statuscode:`402 Payment Required`:
+ The account's balance is too low for the specified operation.
+ See the Taler payment protocol specification for how to pay.
+ :http:statuscode:`404 Not found`:
+ The requested resource was not found.
+
+ **Details:**
+
+ .. _RecoveryMetaSummary:
+ .. ts:def:: RecoveryMetaSummary
+
+ interface RecoveryMetaSummary {
+ // Version numbers as a string (!) are used as keys.
+ "$VERSION": MetaData;
+ }
+
+ interface MetaData {
+ // The meta value can be NULL if the document
+ // exists but no meta data was provided.
+ meta: string;
+
+ // Server-time indicative of when the recovery
+ // document was uploaded.
+ upload_time: Timestamp;
+ }
+
.. http:get:: /policy/$ACCOUNT_PUB[?version=$NUMBER]
Get the customer's encrypted recovery document. If ``version``
@@ -173,8 +217,6 @@ In the following, UUID is always defined and used according to `RFC 4122`_.
:http:statuscode:`402 Payment Required`:
The account's balance is too low for the specified operation.
See the Taler payment protocol specification for how to pay.
- :http:statuscode:`403 Forbidden`:
- The required account signature was invalid.
:http:statuscode:`404 Not found`:
The requested resource was not found.
@@ -216,7 +258,7 @@ In the following, UUID is always defined and used according to `RFC 4122`_.
:query timeout_ms=NUMBER: *Optional.* If specified, the Anastasis server will
wait up to ``timeout_ms`` milliseconds for completion of the payment before
sending the HTTP response. A client must never rely on this behavior, as the
- backend may return a response immediately.
+ backend may return a response immediately. If a ``timeout_ms`` is not given, the Anastasis server may apply a default timeout (usually 30s) when talking to the merchant backend.
*If-None-Match*: This header MUST be present and set to the SHA512 hash (Etag) of the body by the client.
The client SHOULD also set the ``Expect: 100-Continue`` header and wait for ``100 continue``
@@ -225,9 +267,11 @@ In the following, UUID is always defined and used according to `RFC 4122`_.
The server MUST refuse the upload with a ``304`` status code if the Etag matches
the latest version already known to the server.
+ *Anastasis-Policy-Meta-Data*: Encrypted meta data to be stored by the server and returned with the respective endpoint to provide an overview of the available policies. Encrypted using a random nonce and a key derived from the user ID using the salt "rmd". The plaintext metadata must consist of the policy hash (for deduplication) and the (human readable) secret name.
+
*Anastasis-Policy-Signature*: The client must provide Base-32 encoded EdDSA signature over hash of body with ``$ACCOUNT_PRIV``, affirming desire to upload an encrypted recovery document.
- *Payment-Identifier*: Base-32 encoded 32-byte payment identifier that was included in a previous payment (see ``402`` status code). Used to allow the server to check that the client paid for the upload (to protect the server against DoS attacks) and that the client knows a real secret of financial value (as the **kdf_id** might be known to an attacker). If this header is missing in the client's request (or the associated payment has exceeded the upload limit), the server must return a ``402`` response. When making payments, the server must include a fresh, randomly-generated payment-identifier in the payment request.
+ *Payment-Identifier*: Base-32 encoded 32-byte payment identifier that was included in a previous payment (see ``402`` status code). Used to allow the server to check that the client paid for the upload (to protect the server against DoS attacks) and that the client knows a real secret of financial value (as the **kdf_id** might be known to an attacker). If this header is missing in the client's request (or the associated payment has exceeded the upload limit), the server must return a ``402`` response. When making payments, the server must include a fresh, randomly-generated payment-identifier in the payment request. If a payment identifier is given, the Anastasis backend may block for the payment to be confirmed by Taler as specified by the ``timeout_ms`` argument.
**Response**:
@@ -308,7 +352,7 @@ In the following, UUID is always defined and used according to `RFC 4122`_.
truth_key: [32]; //bytearray
// Salt used to hash the security answer if appliccable.
- truth_salt: [32]; //bytearray
+ question_salt: [32]; //bytearray
// Salt from the provider to derive the user ID
// at this provider.
@@ -331,7 +375,7 @@ In the following, UUID is always defined and used according to `RFC 4122`_.
interface DecryptionPolicy {
// Salt included to encrypt master key share when
// using this decryption policy.
- salt: [32]; //bytearray
+ master_salt: [32]; //bytearray
// Master key, AES-encrypted with key derived from
// salt and keyshares revealed by the following list of
@@ -369,10 +413,11 @@ charge per truth operation using GNU Taler.
.. http:post:: /truth/$UUID
+ **Request:**
+
Upload a `TruthUploadRequest`_-Object according to the policy the client created before (see `RecoveryDocument`_).
If request has been seen before, the server should do nothing, and otherwise store the new object.
- **Request:**
:query timeout_ms=NUMBER: *Optional.* If specified, the Anastasis server will
wait up to ``timeout_ms`` milliseconds for completion of the payment before
@@ -425,23 +470,22 @@ charge per truth operation using GNU Taler.
// For how many years from now would the client like us to
// store the truth?
- storage_duration_years: Integer;
+ storage_duration_years: number;
}
-.. http:get:: /truth/$UUID
- Get the stored encrypted key share.
- Also, the user has to provide the correct *truth_encryption_key* with every get request (see below).
+ .. http:post:: /truth/$UUID/solve
+
+ Solve the challenge and get the stored encrypted key share.
+ Also, the user has to provide the correct *truth_encryption_key* with the request (see below).
The encrypted key share is returned simply as a byte array and not in JSON format.
- :query response=H_RESPONSE: *Optional.* If ``$H_RESPONSE`` is specified by the client,
- the server checks if ``$H_RESPONSE`` matches the expected response. This can be the
- hash of the security question (as specified before by the client
- within the `TruthUploadRequest`_ (see ``encrypted_truth``)), or the hash of the
- PIN code sent via SMS, E-mail or postal communication channels.
- When ``$H_RESPONSE`` is correct, the server responds with the encrypted key share.
- :query timeout_ms=NUMBER: *Optional.* If specified, the Anastasis server will
+ **Request**:
+
+ Upload a `TruthSolutionRequest`_-Object.
+
+ :query timeout_ms=NUMBER: *Optional.* If specified, the Anastasis server will
wait up to ``timeout_ms`` milliseconds for completion of the payment or the
challenge before sending the HTTP response. A client must never rely on this
behavior, as the backend may return a response immediately.
@@ -450,46 +494,50 @@ charge per truth operation using GNU Taler.
:http:statuscode:`200 OK`:
`EncryptedKeyShare`_ is returned in body (in binary).
- :http:statuscode:`202 Accepted`:
- The escrow provider will respond out-of-band (i.e. SMS).
- The body may contain human- or machine-readable instructions on next steps.
- In case the response is in JSON, the format is given
- by `ChallengeInstructionMessage`_.
- :http:statuscode:`208 Already Reported`:
- An authentication challenge was recently send, client should
- simply respond to the pending challenge.
- :http:statuscode:`303 See other`:
- The provider redirects for authentication (i.e. video identification/WebRTC).
- If the client is not a browser, it should launch a browser at the URL
- given in the ``Location`` header and allow the user to re-try the operation
- after successful authorization.
:http:statuscode:`402 Payment required`:
The service requires payment for access to truth.
See the Taler payment protocol specification for how to pay.
The response body MAY provide alternative means for payment.
:http:statuscode:`403 Forbidden`:
- The server requires a valid "response" to the challenge associated with the UUID.
+ The `h_response` provided is not a good response to the challenge associated
+ with the UUID, or at least the answer is not valid yet. A generic
+ response is provided with an error code.
:http:statuscode:`404 Not found`:
The server does not know any truth under the given UUID.
- :http:statuscode:`408 Request Timeout`:
- Accessing this truth requires satisfying an external authentication challenge
- (and not merely passing a response in the request) and this has not happened
- before the timeout was reached.
- :http:statuscode:`410 Gone`:
- The server has not (recently) issued a challenge under the given UUID,
- but a reply was provided. (This does not apply for secure question.)
- :http:statuscode:`417 Expectation Failed`:
- The decrypted ``truth`` does not match the expectations of the authentication
- backend, i.e. a phone number for sending an SMS is not a number, or
- an e-mail address for sending an E-mail is not a valid e-mail address.
+ :http:statuscode:`429 Too Many Requests`:
+ The client exceeded the number of allowed attempts at providing
+ a valid response for the given time interval.
+ The response format is given by `RateLimitedMessage`_.
:http:statuscode:`503 Service Unavailable`:
Server is out of Service.
- *Anastasis-Truth-Decryption-Key*: Key used to encrypt the **truth** (see encrypted_truth within `TruthUploadRequest`_) and which has to provided by the user. The key is stored with
- the according `EscrowMethod`_. The server needs this key to get the info out of `TruthUploadRequest`_ needed to verify the ``$RESPONSE``.
-
**Details:**
+ .. _TruthSolutionRequest:
+ .. ts:def:: TruthSolutionRequest
+
+ interface TruthSolutionRequest {
+
+ // Hash over the response that solves the challenge
+ // issued for this truth. This can be the
+ // hash of the security question (as specified before by the client
+ // within the `TruthUploadRequest`_ (see ``encrypted_truth``)), or the hash of the
+ // PIN code sent via SMS, E-mail or postal communication channels.
+ // Only when ``$H_RESPONSE`` is correct, the server responds with the encrypted key share.
+ h_response: HashCode;
+
+ // Key that was used to encrypt the **truth** (see encrypted_truth within `TruthUploadRequest`_)
+ // and which has to provided by the user. The key is stored with
+ // the according `EscrowMethod`_. The server needs this key to get the
+ // info out of `TruthUploadRequest`_ to verify the ``h_response``.
+ truth_decryption_key: ANASTASIS_TruthKeyP;
+
+ // Reference to a payment made by the client to
+ // pay for this request. Optional.
+ payment_secret?: ANASTASIS_PaymentSecretP;
+ }
+
+
.. _EncryptedKeyShare:
.. ts:def:: EncryptedKeyShare
@@ -522,16 +570,90 @@ charge per truth operation using GNU Taler.
}
+ .. _RateLimitedMessage:
+ .. ts:def:: RateLimitedMessage
+
+ interface RateLimitedMessage {
+
+ // Taler error code, TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED.
+ code: number;
+
+ // How many attempts are allowed per challenge?
+ request_limit: number;
+
+ // At what frequency are new challenges issued?
+ request_frequency: RelativeTime;
+
+ // The error message.
+ hint: string;
+
+ }
+
+
+ .. http:post:: /truth/$UUID/challenge
+
+ NEW API (#7064):
+
+ Initiate process to solve challenge associated with the given truth object.
+
+ **Request**:
+
+ Upload a `TruthChallengeRequest`_-Object.
+
+ **Response**:
+
+ :http:statuscode:`200 Ok`:
+ The escrow provider will respond out-of-band (i.e. SMS).
+ The body may contain human- or machine-readable instructions on next steps.
+ In case the response is in JSON, the format is given
+ by `ChallengeInstructionMessage`_.
+ :http:statuscode:`402 Payment required`:
+ The service requires payment to issue a challenge.
+ See the Taler payment protocol specification for how to pay.
+ The response body MAY provide alternative means for payment.
+ :http:statuscode:`403 Forbidden`:
+ This type of truth does not permit requests to trigger a challenge.
+ This is the case for security questions and TOTP methods.
+ :http:statuscode:`404 Not found`:
+ The server does not know any truth under the given UUID.
+ :http:statuscode:`424 Failed Dependency`:
+ The decrypted ``truth`` does not match the expectations of the authentication
+ backend, i.e. a phone number for sending an SMS is not a number, or
+ an e-mail address for sending an E-mail is not a valid e-mail address.
+ :http:statuscode:`503 Service Unavailable`:
+ Server is out of Service.
+
+ **Details:**
+
+ .. _TruthChallengeRequest:
+ .. ts:def:: TruthChallengeRequest
+
+ interface TruthChallengeRequest {
+
+ // Key that was used to encrypt the **truth** (see encrypted_truth within `TruthUploadRequest`_)
+ // and which has to provided by the user. The key is stored with
+ // the according `EscrowMethod`_. The server needs this key to get the
+ // info out of `TruthUploadRequest`_ to verify the ``h_response``.
+ truth_decryption_key: ANASTASIS_TruthKeyP;
+
+ // Reference to a payment made by the client to
+ // pay for this request. Optional.
+ payment_secret?: ANASTASIS_PaymentSecretP;
+ }
+
+
.. _ChallengeInstructionMessage:
.. ts:def:: ChallengeInstructionMessage
type ChallengeInstructionMessage =
- | IbanChallengeInstructionMessage;
+ | FileChallengeInstructionMessage
+ | IbanChallengeInstructionMessage
+ | PinChallengeInstructionMessage;
interface IbanChallengeInstructionMessage {
// What kind of challenge is this?
- method: "iban";
+ method: "IBAN_WIRE";
// How much should be wired?
amount: Amount;
@@ -543,9 +665,36 @@ charge per truth operation using GNU Taler.
business_name: string;
// What is the expected wire transfer subject?
- wire_transfer_subject: Integer;
+ wire_transfer_subject: string;
+
+ // What is the numeric code (also part of the
+ // wire transfer subject) to be hashed when
+ // solving the challenge?
+ answer_code: number;
// Hint about the origin account that must be used.
debit_account_hint: string;
}
+
+ interface PinChallengeInstructionMessage {
+
+ // What kind of challenge is this?
+ method: "TAN_SENT";
+
+ // Where was the PIN code sent? Note that this
+ // address will most likely have been obscured
+ // to improve privacy.
+ tan_address_hint: string;
+
+ }
+
+ interface FileChallengeInstructionMessage {
+
+ // What kind of challenge is this?
+ method: "FILE_WRITTEN";
+
+ // Name of the file where the PIN code was written.
+ filename: string;
+
+ }
diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4
new file mode 100644
index 0000000..ffb4997
--- /dev/null
+++ b/m4/ax_compare_version.m4
@@ -0,0 +1,177 @@
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+#
+# DESCRIPTION
+#
+# This macro compares two version strings. Due to the various number of
+# minor-version numbers that can exist, and the fact that string
+# comparisons are not compatible with numeric comparisons, this is not
+# necessarily trivial to do in a autoconf script. This macro makes doing
+# these comparisons easy.
+#
+# The six basic comparisons are available, as well as checking equality
+# limited to a certain number of minor-version levels.
+#
+# The operator OP determines what type of comparison to do, and can be one
+# of:
+#
+# eq - equal (test A == B)
+# ne - not equal (test A != B)
+# le - less than or equal (test A <= B)
+# ge - greater than or equal (test A >= B)
+# lt - less than (test A < B)
+# gt - greater than (test A > B)
+#
+# Additionally, the eq and ne operator can have a number after it to limit
+# the test to that number of minor versions.
+#
+# eq0 - equal up to the length of the shorter version
+# ne0 - not equal up to the length of the shorter version
+# eqN - equal up to N sub-version levels
+# neN - not equal up to N sub-version levels
+#
+# When the condition is true, shell commands ACTION-IF-TRUE are run,
+# otherwise shell commands ACTION-IF-FALSE are run. The environment
+# variable 'ax_compare_version' is always set to either 'true' or 'false'
+# as well.
+#
+# Examples:
+#
+# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
+#
+# would both be true.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
+#
+# would both be false.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
+#
+# would be true because it is only comparing two minor versions.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
+#
+# would be true because it is only comparing the lesser number of minor
+# versions of the two values.
+#
+# Note: The characters that separate the version numbers do not matter. An
+# empty string is the same as version 0. OP is evaluated by autoconf, not
+# configure, so must be a string, not a variable.
+#
+# The author would like to acknowledge Guido Draheim whose advice about
+# the m4_case and m4_ifvaln functions make this macro only include the
+# portions necessary to perform the specific comparison specified by the
+# OP argument in the final configure script.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 13
+
+dnl #########################################################################
+AC_DEFUN([AX_COMPARE_VERSION], [
+ AC_REQUIRE([AC_PROG_AWK])
+
+ # Used to indicate true or false condition
+ ax_compare_version=false
+
+ # Convert the two version strings to be compared into a format that
+ # allows a simple string comparison. The end result is that a version
+ # string of the form 1.12.5-r617 will be converted to the form
+ # 0001001200050617. In other words, each number is zero padded to four
+ # digits, and non digits are removed.
+ AS_VAR_PUSHDEF([A],[ax_compare_version_A])
+ A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ AS_VAR_PUSHDEF([B],[ax_compare_version_B])
+ B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
+ dnl # then the first line is used to determine if the condition is true.
+ dnl # The sed right after the echo is to remove any indented white space.
+ m4_case(m4_tolower($2),
+ [lt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [gt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [le],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],
+ [ge],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],[
+ dnl Split the operator from the subversion count if present.
+ m4_bmatch(m4_substr($2,2),
+ [0],[
+ # A count of zero means use the length of the shorter version.
+ # Determine the number of characters in A and B.
+ ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
+ ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
+
+ # Set A to no more than B's length and B to no more than A's length.
+ A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
+ ],
+ [[0-9]+],[
+ # A count greater than zero means use only that many subversions
+ A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ ],
+ [.+],[
+ AC_WARNING(
+ [invalid OP numeric parameter: $2])
+ ],[])
+
+ # Pad zeros at end of numbers to make same length.
+ ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
+ B="$B`echo $A | sed 's/./0/g'`"
+ A="$ax_compare_version_tmp_A"
+
+ # Check for equality or inequality as necessary.
+ m4_case(m4_tolower(m4_substr($2,0,2)),
+ [eq],[
+ test "x$A" = "x$B" && ax_compare_version=true
+ ],
+ [ne],[
+ test "x$A" != "x$B" && ax_compare_version=true
+ ],[
+ AC_WARNING([invalid OP parameter: $2])
+ ])
+ ])
+
+ AS_VAR_POPDEF([A])dnl
+ AS_VAR_POPDEF([B])dnl
+
+ dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
+ if test "$ax_compare_version" = "true" ; then
+ m4_ifvaln([$4],[$4],[:])dnl
+ m4_ifvaln([$5],[else $5])dnl
+ fi
+]) dnl AX_COMPARE_VERSION
diff --git a/m4/ax_lib_postgresql.m4 b/m4/ax_lib_postgresql.m4
index 9eb4316..cc8e750 100644
--- a/m4/ax_lib_postgresql.m4
+++ b/m4/ax_lib_postgresql.m4
@@ -1,10 +1,10 @@
# ===========================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html
+# https://www.gnu.org/software/autoconf-archive/ax_lib_postgresql.html
# ===========================================================================
#
# SYNOPSIS
#
-# AX_LIB_POSTGRESQL([MINIMUM-VERSION])
+# AX_LIB_POSTGRESQL([MINIMUM-VERSION],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
@@ -23,133 +23,225 @@
# should be in the PATH)
#
# path - complete path to pg_config utility, use this option if pg_config
-# can't be found in the PATH
+# can't be found in the PATH (You could set also PG_CONFIG variable)
#
# This macro calls:
#
# AC_SUBST(POSTGRESQL_CPPFLAGS)
# AC_SUBST(POSTGRESQL_LDFLAGS)
+# AC_SUBST(POSTGRESQL_LIBS)
# AC_SUBST(POSTGRESQL_VERSION)
#
# And sets:
#
# HAVE_POSTGRESQL
#
+# It execute if found ACTION-IF-FOUND (empty by default) and
+# ACTION-IF-NOT-FOUND (AC_MSG_FAILURE by default) if not found.
+#
# LICENSE
#
# Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
+# Copyright (c) 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
+# Copyright (c) 2018 Bastien Roucaries <rouca@debian.org>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 9
+#serial 22
+
+AC_DEFUN([_AX_LIB_POSTGRESQL_OLD],[
+ found_postgresql="no"
+ _AX_LIB_POSTGRESQL_OLD_fail="no"
+ while true; do
+ AC_CACHE_CHECK([for the pg_config program], [ac_cv_path_PG_CONFIG],
+ [AC_PATH_PROGS_FEATURE_CHECK([PG_CONFIG], [pg_config],
+ [[ac_cv_path_PG_CONFIG="";$ac_path_PG_CONFIG --includedir > /dev/null \
+ && ac_cv_path_PG_CONFIG=$ac_path_PG_CONFIG ac_path_PG_CONFIG_found=:]],
+ [ac_cv_path_PG_CONFIG=""])])
+ PG_CONFIG=$ac_cv_path_PG_CONFIG
+ AS_IF([test "X$PG_CONFIG" = "X"],[break])
+
+ AC_CACHE_CHECK([for the PostgreSQL libraries CPPFLAGS],[ac_cv_POSTGRESQL_CPPFLAGS],
+ [ac_cv_POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir`" || _AX_LIB_POSTGRESQL_OLD_fail=yes])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_OLD_fail" = "Xyes"],[break])
+ POSTGRESQL_CPPFLAGS="$ac_cv_POSTGRESQL_CPPFLAGS"
+
+ AC_CACHE_CHECK([for the PostgreSQL libraries LDFLAGS],[ac_cv_POSTGRESQL_LDFLAGS],
+ [ac_cv_POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir`" || _AX_LIB_POSTGRESQL_OLD_fail=yes])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_OLD_fail" = "Xyes"],[break])
+ POSTGRESQL_LDFLAGS="$ac_cv_POSTGRESQL_LDFLAGS"
+
+ AC_CACHE_CHECK([for the PostgreSQL libraries LIBS],[ac_cv_POSTGRESQL_LIBS],
+ [ac_cv_POSTGRESQL_LIBS="-lpq"])
+ POSTGRESQL_LIBS="$ac_cv_POSTGRESQL_LIBS"
+
+ AC_CACHE_CHECK([for the PostgreSQL version],[ac_cv_POSTGRESQL_VERSION],
+ [
+ ac_cv_POSTGRESQL_VERSION=`$PG_CONFIG --version | sed "s/^PostgreSQL[[[:space:]]][[[:space:]]]*\([[0-9.]][[0-9.]]*\).*/\1/"` \
+ || _AX_LIB_POSTGRESQL_OLD_fail=yes
+ ])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_OLD_fail" = "Xyes"],[break])
+ POSTGRESQL_VERSION="$ac_cv_POSTGRESQL_VERSION"
+
+
+ dnl
+ dnl Check if required version of PostgreSQL is available
+ dnl
+ AS_IF([test X"$postgresql_version_req" != "X"],[
+ AC_MSG_CHECKING([if PostgreSQL version $POSTGRESQL_VERSION is >= $postgresql_version_req])
+ AX_COMPARE_VERSION([$POSTGRESQL_VERSION],[ge],[$postgresql_version_req],
+ [found_postgresql_req_version=yes],[found_postgresql_req_version=no])
+ AC_MSG_RESULT([$found_postgresql_req_version])
+ ])
+ AS_IF([test "Xfound_postgresql_req_version" = "Xno"],[break])
+
+ found_postgresql="yes"
+ break
+ done
+])
-AC_DEFUN([AX_LIB_POSTGRESQL],
+AC_DEFUN([_AX_LIB_POSTGRESQL_PKG_CONFIG],
[
- AC_ARG_WITH([postgresql],
- AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@],
- [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config]
- ),
- [
- if test "$withval" = "no"; then
- want_postgresql="no"
- elif test "$withval" = "yes"; then
- want_postgresql="yes"
- else
- want_postgresql="yes"
- PG_CONFIG="$withval"
- fi
- ],
- [want_postgresql="yes"]
- )
+ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+ found_postgresql=no
- POSTGRESQL_CPPFLAGS=""
- POSTGRESQL_LDFLAGS=""
- POSTGRESQL_VERSION=""
+ while true; do
+ PKG_PROG_PKG_CONFIG
+ AS_IF([test X$PKG_CONFIG = X],[break])
- dnl
- dnl Check PostgreSQL libraries (libpq)
- dnl
+ _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=no;
+ AS_IF([test "X$postgresql_version_req" = "X"],
+ [PKG_CHECK_EXISTS([libpq],[found_postgresql_pkg_config=yes],[found_postgresql=no])],
+ [PKG_CHECK_EXISTS([libpq >= "$postgresql_version_req"],
+ [found_postgresql=yes],[found_postgresql=no])])
+ AS_IF([test "X$found_postgresql" = "no"],[break])
+
+ AC_CACHE_CHECK([for the PostgreSQL libraries CPPFLAGS],[ac_cv_POSTGRESQL_CPPFLAGS],
+ [ac_cv_POSTGRESQL_CPPFLAGS="`$PKG_CONFIG libpq --cflags-only-I`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=yes])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break])
+ POSTGRESQL_CPPFLAGS="$ac_cv_POSTGRESQL_CPPFLAGS"
- if test "$want_postgresql" = "yes"; then
- if test -z "$PG_CONFIG" -o test; then
- AC_PATH_PROG([PG_CONFIG], [pg_config], [])
- fi
+ AC_CACHE_CHECK([for the PostgreSQL libraries LDFLAGS],[ac_cv_POSTGRESQL_LDFLAGS],
+ [ac_cv_POSTGRESQL_LDFLAGS="`$PKG_CONFIG libpq --libs-only-L --libs-only-other`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=yes])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break])
+ POSTGRESQL_LDFLAGS="$ac_cv_POSTGRESQL_LDFLAGS"
- if test ! -x "$PG_CONFIG"; then
- dnl AC_MSG_ERROR([$PG_CONFIG does not exist or it is not an executable file])
- PG_CONFIG="no"
- found_postgresql="no"
- fi
- if test "$PG_CONFIG" != "no"; then
- AC_MSG_CHECKING([for PostgreSQL libraries])
+ AC_CACHE_CHECK([for the PostgreSQL libraries LIBS],[ac_cv_POSTGRESQL_LIBS],
+ [ac_cv_POSTGRESQL_LIBS="`$PKG_CONFIG libpq --libs-only-l`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=ye])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break])
+ POSTGRESQL_LIBS="$ac_cv_POSTGRESQL_LIBS"
- POSTGRESQL_CPPFLAGS="-I`$PG_CONFIG --includedir`"
- POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir`"
+ dnl already checked by exist but need to be recovered
+ AC_CACHE_CHECK([for the PostgreSQL version],[ac_cv_POSTGRESQL_VERSION],
+ [ac_cv_POSTGRESQL_VERSION="`$PKG_CONFIG libpq --modversion`" || _AX_LIB_POSTGRESQL_PKG_CONFIG_fail=yes])
+ AS_IF([test "X$_AX_LIB_POSTGRESQL_PKG_CONFIG_fail" = "Xyes"],[break])
+ POSTGRESQL_VERSION="$ac_cv_POSTGRESQL_VERSION"
- POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##' | awk '{print $1}'`
+ found_postgresql=yes
+ break;
+ done
- AC_DEFINE([HAVE_POSTGRESQL], [1],
- [Define to 1 if PostgreSQL libraries are available])
+])
- found_postgresql="yes"
- AC_MSG_RESULT([yes])
- else
- found_postgresql="no"
- AC_MSG_RESULT([no])
- fi
- fi
- dnl
- dnl Check if required version of PostgreSQL is available
- dnl
+AC_DEFUN([AX_LIB_POSTGRESQL],
+[
+ AC_ARG_WITH([postgresql],
+ AS_HELP_STRING([--with-postgresql=@<:@ARG@:>@],
+ [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config]
+ ),
+ [
+ AS_CASE([$withval],
+ [[[nN]][[oO]]],[want_postgresql="no"],
+ [[[yY]][[eE]][[sS]]],[want_postgresql="yes"],
+ [
+ want_postgresql="yes"
+ PG_CONFIG="$withval"
+ ])
+ ],
+ [want_postgresql="yes"]
+ )
+
+ AC_ARG_VAR([POSTGRESQL_CPPFLAGS],[cpp flags for PostgreSQL overriding detected flags])
+ AC_ARG_VAR([POSTGRESQL_LIBFLAGS],[libs for PostgreSQL overriding detected flags])
+ AC_ARG_VAR([POSTGRESQL_LDFLAGS],[linker flags for PostgreSQL overriding detected flags])
+
+ # populate cache
+ AS_IF([test "X$POSTGRESQL_CPPFLAGS" != X],[ac_cv_POSTGRESQL_CPPFLAGS="$POSTGRESQL_CPPFLAGS"])
+ AS_IF([test "X$POSTGRESQL_LDFLAGS" != X],[ac_cv_POSTGRESQL_LDFLAGS="$POSTGRESQL_LDFLAGS"])
+ AS_IF([test "X$POSTGRESQL_LIBS" != X],[ac_cv_POSTGRESQL_LIBS="$POSTGRESQL_LIBS"])
postgresql_version_req=ifelse([$1], [], [], [$1])
+ found_postgresql="no"
- if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then
-
- AC_MSG_CHECKING([if PostgreSQL version $POSTGRESQL_VERSION is >= $postgresql_version_req])
-
- dnl Decompose required version string of PostgreSQL
- dnl and calculate its number representation
- postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'`
- postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
- postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
- if test "x$postgresql_version_req_micro" = "x"; then
- postgresql_version_req_micro="0"
- fi
-
- postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \
- \+ $postgresql_version_req_minor \* 1000 \
- \+ $postgresql_version_req_micro`
-
- dnl Decompose version string of installed PostgreSQL
- dnl and calculate its number representation
- postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'`
- postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
- postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
- if test "x$postgresql_version_micro" = "x"; then
- postgresql_version_micro="0"
- fi
-
- postgresql_version_number=`expr $postgresql_version_major \* 1000000 \
- \+ $postgresql_version_minor \* 1000 \
- \+ $postgresql_version_micro`
-
- postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number`
- if test "$postgresql_version_check" = "1"; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
- fi
+ POSTGRESQL_VERSION=""
+
+ dnl
+ dnl Check PostgreSQL libraries (libpq)
+ dnl
+ AS_IF([test X"$want_postgresql" = "Xyes"],[
+ _AX_LIB_POSTGRESQL_PKG_CONFIG
+
+
+ AS_IF([test X"$found_postgresql" = "Xno"],
+ [_AX_LIB_POSTGRESQL_OLD])
+
+ AS_IF([test X"$found_postgresql" = Xyes],[
+ _AX_LIB_POSTGRESQL_OLD_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $POSTGRESQL_CPPFLAGS"
+ _AX_LIB_POSTGRESQL_OLD_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $POSTGRESQL_LDFLAGS"
+ _AX_LIB_POSTGRESQL_OLD_LIBS="$LIBS"
+ LIBS="$LIBS $POSTGRESQL_LIBS"
+ while true; do
+ dnl try to compile
+ AC_CHECK_HEADER([libpq-fe.h],[],[found_postgresql=no])
+ AS_IF([test "X$found_postgresql" = "Xno"],[break])
+ dnl try now to link
+ AC_CACHE_CHECK([for the PostgreSQL library linking is working],[ac_cv_postgresql_found],
+ [
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM(
+ [
+ #include <libpq-fe.h>
+ ],
+ [[
+ char conninfo[]="dbname = postgres";
+ PGconn *conn;
+ conn = PQconnectdb(conninfo);
+ ]]
+ )
+ ],[ac_cv_postgresql_found=yes],
+ [ac_cv_postgresql_found=no])
+ ])
+ found_postgresql="$ac_cv_postgresql_found"
+ AS_IF([test "X$found_postgresql" = "Xno"],[break])
+ break
+ done
+ CPPFLAGS="$_AX_LIB_POSTGRESQL_OLD_CPPFLAGS"
+ LDFLAGS="$_AX_LIB_POSTGRESQL_OLD_LDFLAGS"
+ LIBS="$_AX_LIB_POSTGRESQL_OLD_LIBS"
+ ])
+
+
+ AS_IF([test "x$found_postgresql" = "xyes"],[
+ AC_DEFINE([HAVE_POSTGRESQL], [1],
+ [Define to 1 if PostgreSQL libraries are available])])
+ ])
AC_SUBST([POSTGRESQL_VERSION])
AC_SUBST([POSTGRESQL_CPPFLAGS])
AC_SUBST([POSTGRESQL_LDFLAGS])
+ AC_SUBST([POSTGRESQL_LIBS])
+
+ AS_IF([test "x$found_postgresql" = "xyes"],
+ [ifelse([$2], , :, [$2])],
+ [ifelse([$3], , AS_IF([test X"$want_postgresql" = "Xyes"],[AC_MSG_ERROR([Library requirements (PostgreSQL) not met.])],[:]), [$3])])
+
])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1c8ee65..7395de9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,2 +1,77 @@
-# List of source files which contain translatable strings.
+src/authorization/anastasis_authorization_plugin.c
+src/authorization/anastasis_authorization_plugin_email.c
+src/authorization/anastasis_authorization_plugin_file.c
+src/authorization/anastasis_authorization_plugin_iban.c
+src/authorization/anastasis_authorization_plugin_post.c
+src/authorization/anastasis_authorization_plugin_sms.c
+src/authorization/anastasis_authorization_plugin_totp.c
+src/authorization/anastasis-helper-authorization-iban.c
+src/authorization/iban.c
+src/authorization/libanastasiseufin/lae_common.c
+src/authorization/libanastasiseufin/lae_credit.c
+src/authorization/libanastasiseufin/lae_parse.c
+src/backend/anastasis-httpd.c
+src/backend/anastasis-httpd_config.c
+src/backend/anastasis-httpd_mhd.c
+src/backend/anastasis-httpd_policy.c
+src/backend/anastasis-httpd_policy-meta.c
+src/backend/anastasis-httpd_policy-upload.c
+src/backend/anastasis-httpd_terms.c
+src/backend/anastasis-httpd_truth-challenge.c
+src/backend/anastasis-httpd_truth-solve.c
+src/backend/anastasis-httpd_truth-upload.c
+src/cli/anastasis-cli-discover.c
+src/cli/anastasis-cli-redux.c
+src/lib/anastasis_backup.c
+src/lib/anastasis_meta.c
+src/lib/anastasis_recovery.c
+src/reducer/anastasis_api_backup_redux.c
+src/reducer/anastasis_api_discovery.c
src/reducer/anastasis_api_recovery_redux.c
+src/reducer/anastasis_api_redux.c
+src/reducer/validation_CH_AHV.c
+src/reducer/validation_CZ_BN.c
+src/reducer/validation_DE_SVN.c
+src/reducer/validation_DE_TIN.c
+src/reducer/validation_ES_DNI.c
+src/reducer/validation_FR_INSEE.c
+src/reducer/validation_IN_AADHAR.c
+src/reducer/validation_IT_CF.c
+src/reducer/validation_NL_BSN.c
+src/reducer/validation_XX_SQUARE.c
+src/reducer/validation_XY_PRIME.c
+src/restclient/anastasis_api_config.c
+src/restclient/anastasis_api_curl_defaults.c
+src/restclient/anastasis_api_keyshare_lookup.c
+src/restclient/anastasis_api_policy_lookup.c
+src/restclient/anastasis_api_policy_meta_lookup.c
+src/restclient/anastasis_api_policy_store.c
+src/restclient/anastasis_api_truth_challenge.c
+src/restclient/anastasis_api_truth_solve.c
+src/restclient/anastasis_api_truth_store.c
+src/stasis/anastasis-dbinit.c
+src/stasis/anastasis_db_plugin.c
+src/stasis/plugin_anastasis_postgres.c
+src/stasis/test_anastasis_db.c
+src/testing/test_anastasis_api.c
+src/testing/test_anastasis.c
+src/testing/testing_api_cmd_config.c
+src/testing/testing_api_cmd_policy_lookup.c
+src/testing/testing_api_cmd_policy_store.c
+src/testing/testing_api_cmd_truth_challenge.c
+src/testing/testing_api_cmd_truth_solve.c
+src/testing/testing_api_cmd_truth_store.c
+src/testing/testing_api_helpers.c
+src/testing/testing_api_traits.c
+src/testing/testing_cmd_challenge_answer.c
+src/testing/testing_cmd_policy_create.c
+src/testing/testing_cmd_recover_secret.c
+src/testing/testing_cmd_secret_share.c
+src/testing/testing_cmd_truth_upload.c
+src/util/anastasis-config.c
+src/util/anastasis_crypto.c
+src/util/anastasis-crypto-tvg.c
+src/util/os_installation.c
+src/util/pin.c
+src/util/test_anastasis_crypto.c
+contrib/extracted.h
diff --git a/src/authorization/Makefile.am b/src/authorization/Makefile.am
index ec9ae5a..5d2854d 100644
--- a/src/authorization/Makefile.am
+++ b/src/authorization/Makefile.am
@@ -35,7 +35,9 @@ bin_PROGRAMS = \
anastasis-helper-authorization-iban
bin_SCRIPTS = \
- anastasis-authorization-email.sh
+ anastasis-authorization-email.sh \
+ anastasis-authorization-sms.sh \
+ anastasis-authorization-post.sh
anastasis_helper_authorization_iban_SOURCES = \
anastasis-helper-authorization-iban.c
@@ -98,6 +100,7 @@ libanastasis_plugin_authorization_email_la_LIBADD = \
libanastasis_plugin_authorization_email_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
$(top_builddir)/src/stasis/libanastasisdb.la \
+ $(top_builddir)/src/util/libanastasisutil.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
@@ -130,6 +133,7 @@ libanastasis_plugin_authorization_post_la_LIBADD = \
libanastasis_plugin_authorization_post_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
$(top_builddir)/src/stasis/libanastasisdb.la \
+ $(top_builddir)/src/util/libanastasisutil.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
@@ -146,6 +150,7 @@ libanastasis_plugin_authorization_sms_la_LIBADD = \
libanastasis_plugin_authorization_sms_la_LDFLAGS = \
$(ANASTASIS_PLUGIN_LDFLAGS) \
$(top_builddir)/src/stasis/libanastasisdb.la \
+ $(top_builddir)/src/util/libanastasisutil.la \
-ltalerjson \
-ltalermhd \
-ltalerutil \
diff --git a/src/authorization/anastasis-authorization-email.sh b/src/authorization/anastasis-authorization-email.sh
index ae3ecf7..738aaf0 100755
--- a/src/authorization/anastasis-authorization-email.sh
+++ b/src/authorization/anastasis-authorization-email.sh
@@ -1,2 +1,3 @@
#!/bin/sh
+# This file is in the public domain.
exec mail -s "Anastasis" -r noreply "$1"
diff --git a/src/authorization/anastasis-authorization-post.sh b/src/authorization/anastasis-authorization-post.sh
new file mode 100755
index 0000000..66255ea
--- /dev/null
+++ b/src/authorization/anastasis-authorization-post.sh
@@ -0,0 +1,196 @@
+#!/bin/bash
+# This file is in the public domain.
+set -eu
+
+# Check shared secrets
+if [ -x "$PINGEN_CLIENT_ID" ]
+then
+ echo "PINGEN_CLIENT_ID not sent in environment"
+ exit 1
+fi
+if [ -x "$PINGEN_CLIENT_SECRET" ]
+then
+ echo "PINGEN_CLIENT_SECRET not sent in environment"
+ exit 1
+fi
+if [ -x "$PINGEN_ORG_ID" ]
+then
+ echo "PINGEN_ORG_ID not sent in environment"
+ exit 1
+fi
+
+ENDPOINT="https://api.pingen.com"
+LOGS="$PWD/authorization-post.log"
+
+MESSAGE=$(cat -)
+DATE=$(date +%F)
+ADDR="$1"
+NAME=$(echo $ADDR | jq -r .full_name)
+STREET=$(echo $ADDR | jq -r .street)
+
+LNUMBER=$(echo $STREET | awk '{print $NF}')
+FNUMBER=$(echo $STREET | awk '{print $1}')
+case $LNUMBER in
+ ''|*[!0-9]*)
+ case $FNUMBER in
+ ''|*[!0-9]*)
+ NUMBER=0
+ ;;
+ *)
+ NUMBER=$FNUMBER
+ ;;
+ esac
+ ;;
+ *)
+ NUMBER=$LNUMBER
+ ;;
+esac
+
+
+CITY=$(echo $ADDR | jq -r .city)
+POSTCODE=$(echo $ADDR | jq -r .postcode)
+COUNTRY=$(echo $ADDR | jq -r .country)
+
+MYDIR=$(mktemp -d /tmp/authorization-post-XXXXXX)
+cd "$MYDIR"
+cat - | sed -e "s/%NAME%/$NAME/g" \
+ -e "s/%STREET%/$STREET/g" \
+ -e "s/%POSTCODE%/$POSTCODE/g" \
+ -e "s/%CITY%/$CITY/g" \
+ -e "s/%COUNTRY%/$COUNTRY/g" \
+ -e "s/%MESSAGE%/$MESSAGE/g" > input.tex <<EOF
+\NeedsTeXFormat{LaTeX2e}
+\documentclass[fontsize=11pt,a4paper]{scrlttr2}
+\makeatletter
+\KOMAoptions{foldmarks=off}
+%\@setplength{toaddrvpos}{30mm}
+%\@setplength{toaddrhpos}{130mm}
+%\@setplength{sigbeforevskip}{10mm}
+\makeatother
+\setkomavar{subject}{Anastasis Recovery}
+%\setkomavar{fromname}{Anastasis SARL}
+\setkomavar{signature}{Anastasis SARL}
+\date{\today}
+%\address{Anastasis SARL \\\\ 7 rue de Mondorf \\\\ 5431 Erpeldange}
+%\signature{Anastasis SARL}
+\begin{document}
+\begin{letter}{\ \ %NAME% \\\\ \ \ %STREET% \\\\ \ \ %POSTCODE% %CITY% \\\\ \ \ %COUNTRY% }
+\opening{To whom it may concern,}
+%MESSAGE%
+\closing{Best regards}
+\end{letter}
+\end{document}
+EOF
+pdflatex input.tex > /dev/null 2> /dev/null
+
+REPLY=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" \
+ --data-urlencode "grant_type=client_credentials" \
+ --data-urlencode "client_id=$PINGEN_CLIENT_ID" \
+ --data-urlencode "client_secret=$PINGEN_CLIENT_SECRET" \
+ --data-urlencode "scope=letter" \
+ https://identity.pingen.com/auth/access-tokens)
+
+ACCESS_TOKEN=$(echo $REPLY | jq -r .access_token)
+
+REPLY=$(curl -s \
+ -X GET "$ENDPOINT/file-upload" \
+ -H "Authorization: Bearer $ACCESS_TOKEN")
+ATTRS=$(echo $REPLY | jq .data.attributes)
+UPLOAD_URL=$(echo $ATTRS | jq -r .url)
+URL_SIG=$(echo $ATTRS | jq -r .url_signature)
+
+curl -s -X PUT -T input.pdf "$UPLOAD_URL"
+
+
+RECIPIENT="$(jq -n '
+ {
+ name: $NAME,
+ street: $STREET,
+ number: $NUMBER,
+ city: $CITY,
+ zip: $POSTCODE,
+ country: $COUNTRY,
+ }' \
+ --arg NAME "$NAME" \
+ --arg STREET "$STREET" \
+ --arg NUMBER "$NUMBER" \
+ --arg CITY "$CITY" \
+ --arg POSTCODE "$POSTCODE" \
+ --arg COUNTRY "$COUNTRY" \
+ )"
+
+SENDER="$(jq -n '
+ {
+ name: "Anastasis SARL",
+ street: "Rue de Mondorf",
+ number: "7",
+ zip: "5421",
+ city: "Erpeldange",
+ country: "LU"
+ }'
+ )"
+
+REQUEST="$(jq -n '
+ { data: {
+ type: "letters",
+ attributes: {
+ file_original_name: "input.pdf",
+ file_url: $UPLOAD_URL,
+ file_url_signature: $URL_SIG,
+ address_position: "left",
+ delivery_product: "cheap",
+ print_mode: "duplex",
+ auto_send: true,
+ print_spectrum: "grayscale"
+ } }
+ }' \
+ --argjson RECIPIENT "$RECIPIENT" \
+ --argjson SENDER "$SENDER" \
+ --arg UPLOAD_URL "$UPLOAD_URL" \
+ --arg URL_SIG "$URL_SIG" \
+ )"
+
+STATUS=$(curl -s --request POST \
+ --url "$ENDPOINT/organisations/${PINGEN_ORG_ID}/letters" \
+ --header 'Content-Type: application/vnd.api+json' \
+ --header "Authorization: Bearer $ACCESS_TOKEN" \
+ -d "$REQUEST" \
+ -o "$MYDIR/final-reply.txt" \
+ -w "%{http_code}" -s)
+cat "$MYDIR/final-reply.txt" >> "$LOGS"
+case $STATUS in
+ 201)
+ ;;
+ *)
+ echo "Failed to add letter: $STATUS" >> "$LOGS"
+ echo "$REPLY"
+ exit 1;
+ ;;
+esac
+LETTER_ID=$(cat "$MYDIR/final-reply.txt" | jq -r .data.id)
+REPLY=$MYDIR/delete-reply.txt
+STATUS=409
+sleep 1;
+while test "$STATUS" = 409;
+do
+ STATUS=$(curl -s --request DELETE \
+ --url "$ENDPOINT/organisations/$PINGEN_ORG_ID/letters/$LETTER_ID" \
+ --header "Authorization: Bearer $ACCESS_TOKEN" \
+ -o "$REPLY" \
+ -w "%{http_code}" -s)
+ case $STATUS in
+ 204)
+ cat "$REPLY" >> "$LOGS"
+ ;;
+ 409)
+ # Happens, likely still in processing...
+ ;;
+ *)
+ echo "Failed to delete letter: $STATUS" >> "$LOGS"
+ ;;
+ esac
+done
+
+rm -r "$MYDIR"
+
+exit 0
diff --git a/src/authorization/anastasis-authorization-sms.sh b/src/authorization/anastasis-authorization-sms.sh
new file mode 100755
index 0000000..1e38661
--- /dev/null
+++ b/src/authorization/anastasis-authorization-sms.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# This file is in the public domain.
+set -eu
+
+# Check shared secrets
+if [ -x "$TELESIGN_AUTH_TOKEN" ]
+then
+ echo "TELESIGN_AUTH_TOKEN not sent in environment"
+ exit 1
+fi
+
+MESSAGE=$(cat -)
+TMPFILE=$(mktemp /tmp/sms-loggingXXXXXX)
+STATUS=$(curl --request POST \
+ --url https://rest-api.telesign.com/v1/messaging \
+ --header 'authorization: Basic $TELESIGN_AUTH_TOKEN' \
+ --header 'content-type: application/x-www-form-urlencoded' \
+ --data account_livecycle_event=transact \
+ --data "message=$MESSAGE" \
+ --data message_type=OTP \
+ --data "phone_number=$1" \
+ -w "%{http_code}" -s -o $TMPFILE)
+echo `cat $TMPFILE` >> /var/log/sms.log
+rm -f $TMPFILE
+case $STATUS in
+ 200|203|250|290|291|295)
+ exit 0;
+ ;;
+ *)
+ exit 1;
+ ;;
+esac
+exit 1
diff --git a/src/authorization/anastasis_authorization_plugin.c b/src/authorization/anastasis_authorization_plugin.c
index c557aa3..7e25c03 100644
--- a/src/authorization/anastasis_authorization_plugin.c
+++ b/src/authorization/anastasis_authorization_plugin.c
@@ -3,7 +3,7 @@
Copyright (C) 2015, 2016, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c
index 0eefcc5..7fc97e7 100644
--- a/src/authorization/anastasis_authorization_plugin_email.c
+++ b/src/authorization/anastasis_authorization_plugin_email.c
@@ -3,7 +3,7 @@
Copyright (C) 2019-2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -220,7 +220,7 @@ email_validate (void *cls,
{
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_EMAIL_INVALID,
NULL))
return GNUNET_SYSERR;
@@ -296,8 +296,12 @@ email_done_cb (void *cls,
{
struct ANASTASIS_AUTHORIZATION_State *as = cls;
- as->child = NULL;
as->cwh = NULL;
+ if (NULL != as->child)
+ {
+ GNUNET_OS_process_destroy (as->child);
+ as->child = NULL;
+ }
as->pst = type;
as->exit_code = exit_code;
MHD_resume_connection (as->connection);
@@ -310,20 +314,17 @@ email_done_cb (void *cls,
* I.e. start to send SMS or e-mail or launch video identification.
*
* @param as authorization state
- * @param timeout how long do we have to produce a reply
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
-static enum ANASTASIS_AUTHORIZATION_Result
-email_process (struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection)
+static enum ANASTASIS_AUTHORIZATION_ChallengeResult
+email_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct MHD_Connection *connection)
{
MHD_RESULT mres;
const char *mime;
const char *lang;
- (void) timeout;
mime = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
MHD_HTTP_HEADER_ACCEPT);
@@ -348,8 +349,8 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_EMAIL_HELPER_EXEC_FAILED,
"pipe");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
as->child = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR,
p,
@@ -367,27 +368,19 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_EMAIL_HELPER_EXEC_FAILED,
"exec");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
pipe_stdin = GNUNET_DISK_pipe_detach_end (p,
GNUNET_DISK_PIPE_END_WRITE);
GNUNET_assert (NULL != pipe_stdin);
GNUNET_DISK_pipe_close (p);
- {
- char *tpk;
-
- tpk = GNUNET_STRINGS_data_to_string_alloc (
- &as->truth_uuid,
- sizeof (as->truth_uuid));
- GNUNET_asprintf (&as->msg,
- get_message (as->ctx->messages,
- connection,
- "body"),
- (unsigned long long) as->code,
- tpk);
- GNUNET_free (tpk);
- }
+ GNUNET_asprintf (&as->msg,
+ get_message (as->ctx->messages,
+ connection,
+ "body"),
+ ANASTASIS_pin2s (as->code),
+ ANASTASIS_CRYPTO_uuid2s (&as->truth_uuid));
{
const char *off = as->msg;
@@ -409,8 +402,8 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_EMAIL_HELPER_EXEC_FAILED,
"write");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
as->msg_off += ret;
off += ret;
@@ -423,14 +416,14 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
as);
as->connection = connection;
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUSPENDED;
}
if (NULL != as->cwh)
{
/* Spurious call, why are we here? */
GNUNET_break (0);
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUSPENDED;
}
if ( (GNUNET_OS_PROCESS_EXITED != as->pst) ||
(0 != as->exit_code) )
@@ -447,8 +440,8 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_EMAIL_HELPER_COMMAND_FAILED,
es);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
/* Build HTTP response */
@@ -471,12 +464,9 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
user = GNUNET_strndup (as->email,
len);
resp = TALER_MHD_MAKE_JSON_PACK (
- GNUNET_JSON_pack_uint64 ("code",
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED),
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED)),
- GNUNET_JSON_pack_string ("detail",
+ GNUNET_JSON_pack_string ("challenge_type",
+ "TAN_SENT"),
+ GNUNET_JSON_pack_string ("tan_address_hint",
user));
GNUNET_free (user);
}
@@ -502,12 +492,12 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as,
"text/plain"));
}
mres = MHD_queue_response (connection,
- MHD_HTTP_FORBIDDEN,
+ MHD_HTTP_OK,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS;
}
}
@@ -606,7 +596,7 @@ libanastasis_plugin_authorization_email_init (void *cls)
plugin->cls = ctx;
plugin->validate = &email_validate;
plugin->start = &email_start;
- plugin->process = &email_process;
+ plugin->challenge = &email_challenge;
plugin->cleanup = &email_cleanup;
if (GNUNET_OK !=
diff --git a/src/authorization/anastasis_authorization_plugin_file.c b/src/authorization/anastasis_authorization_plugin_file.c
index d41eaa3..2f4fcb4 100644
--- a/src/authorization/anastasis_authorization_plugin_file.c
+++ b/src/authorization/anastasis_authorization_plugin_file.c
@@ -3,7 +3,7 @@
Copyright (C) 2019 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -161,14 +161,12 @@ file_start (void *cls,
* I.e. start to send SMS or e-mail or launch video identification.
*
* @param as authorization state
- * @param timeout how long do we have to produce a reply
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
-static enum ANASTASIS_AUTHORIZATION_Result
-file_process (struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection)
+static enum ANASTASIS_AUTHORIZATION_ChallengeResult
+file_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct MHD_Connection *connection)
{
const char *mime;
const char *lang;
@@ -201,8 +199,8 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
/* print challenge code to file */
@@ -221,8 +219,8 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
GNUNET_break (0 == fclose (f));
}
@@ -235,6 +233,8 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
"application/json"))
{
resp = TALER_MHD_MAKE_JSON_PACK (
+ GNUNET_JSON_pack_string ("challenge_type",
+ "FILE_WRITTEN"),
GNUNET_JSON_pack_string ("filename",
as->filename));
}
@@ -260,12 +260,12 @@ file_process (struct ANASTASIS_AUTHORIZATION_State *as,
MHD_RESULT mres;
mres = MHD_queue_response (connection,
- MHD_HTTP_FORBIDDEN,
+ MHD_HTTP_OK,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS;
}
}
}
@@ -304,7 +304,7 @@ libanastasis_plugin_authorization_file_init (void *cls)
plugin->code_retransmission_frequency = GNUNET_TIME_UNIT_MINUTES;
plugin->validate = &file_validate;
plugin->start = &file_start;
- plugin->process = &file_process;
+ plugin->challenge = &file_challenge;
plugin->cleanup = &file_cleanup;
return plugin;
}
diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c
index 7717770..92b4565 100644
--- a/src/authorization/anastasis_authorization_plugin_iban.c
+++ b/src/authorization/anastasis_authorization_plugin_iban.c
@@ -3,7 +3,7 @@
Copyright (C) 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -209,7 +209,7 @@ iban_validate (void *cls,
GNUNET_free (iban_number);
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_IBAN_INVALID,
emsg))
{
@@ -293,105 +293,13 @@ bank_event_cb (void *cls,
}
GNUNET_free (amount_s);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "IBAN event triggers resumption of request handling\n");
MHD_resume_connection (as->connection);
as->trigger (as->trigger_cls);
}
-/**
- * Respond with instructions to the user how to
- * satisfy the challenge.
- *
- * @param as our state
- * @param connection connection to respond on
- * @return state of the request
- */
-static enum ANASTASIS_AUTHORIZATION_Result
-respond_with_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
- struct MHD_Connection *connection)
-{
- struct IBAN_Context *ctx = as->ctx;
- const char *mime;
- const char *lang;
- MHD_RESULT mres;
-
- mime = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- MHD_HTTP_HEADER_ACCEPT);
- if (NULL == mime)
- mime = "text/plain";
- lang = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- MHD_HTTP_HEADER_ACCEPT_LANGUAGE);
- if (NULL == lang)
- lang = "en";
-
- /* Build HTTP response */
- {
- struct MHD_Response *resp;
-
- if (TALER_MHD_xmime_matches (mime,
- "application/json"))
- {
- char subject[64];
-
- GNUNET_snprintf (subject,
- sizeof (subject),
- "Anastasis %llu",
- (unsigned long long) as->code);
- resp = TALER_MHD_MAKE_JSON_PACK (
- GNUNET_JSON_pack_string ("method",
- "iban"),
- GNUNET_JSON_pack_bool ("async",
- true),
- GNUNET_JSON_pack_uint64 ("answer_code",
- as->code),
- GNUNET_JSON_pack_object_steal (
- "details",
- GNUNET_JSON_PACK (
- TALER_JSON_pack_amount ("challenge_amount",
- &ctx->expected_amount),
- GNUNET_JSON_pack_string ("credit_iban",
- ctx->business_iban),
- GNUNET_JSON_pack_string ("business_name",
- ctx->business_name),
- GNUNET_JSON_pack_string ("wire_transfer_subject",
- subject))));
- }
- else
- {
- size_t reply_len;
- char *reply;
-
- reply_len = GNUNET_asprintf (&reply,
- get_message (ctx->messages,
- connection,
- "instructions"),
- TALER_amount2s (&ctx->expected_amount),
- ctx->business_name,
- ctx->business_iban,
- (unsigned long long) as->code);
- resp = MHD_create_response_from_buffer (reply_len,
- reply,
- MHD_RESPMEM_MUST_COPY);
- GNUNET_free (reply);
- TALER_MHD_add_global_headers (resp);
- GNUNET_break (MHD_YES ==
- MHD_add_response_header (resp,
- MHD_HTTP_HEADER_CONTENT_TYPE,
- "text/plain"));
- }
- mres = MHD_queue_response (connection,
- MHD_HTTP_ACCEPTED,
- resp);
- MHD_destroy_response (resp);
- if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS;
- }
-}
-
-
#include "iban.c"
@@ -461,12 +369,14 @@ test_wire_transfers (struct ANASTASIS_AUTHORIZATION_State *as)
struct ANASTASIS_DatabasePlugin *db = ctx->ac->db;
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_TIME_Absolute now;
- struct GNUNET_TIME_Absolute limit;
+ struct GNUNET_TIME_Timestamp limit;
now = GNUNET_TIME_absolute_get ();
- limit = GNUNET_TIME_absolute_subtract (now,
- CODE_VALIDITY_PERIOD);
- (void) GNUNET_TIME_round_abs (&limit);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Testing for wire transfers\n");
+ limit = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_subtract (now,
+ CODE_VALIDITY_PERIOD));
qs = db->test_auth_iban_payment (
db->cls,
as->iban_number,
@@ -482,15 +392,13 @@ test_wire_transfers (struct ANASTASIS_AUTHORIZATION_State *as)
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
NULL))
- ? WTS_FAILED_WITH_REPLY
- : WTS_FAILED_WITHOUT_REPLY;
+ ? WTS_FAILED_WITH_REPLY
+ : WTS_FAILED_WITHOUT_REPLY;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
return WTS_NOT_READY;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Marking IBAN challenge as satisfied!\n");
qs = db->mark_challenge_code_satisfied (
db->cls,
&as->truth_uuid,
@@ -501,26 +409,124 @@ test_wire_transfers (struct ANASTASIS_AUTHORIZATION_State *as)
/**
+ * Respond with instructions to the user how to
+ * satisfy the challenge.
+ *
+ * @param as authorization state
+ * @param connection HTTP client request (for queuing response, such as redirection to video portal)
+ * @return state of the request
+ */
+static enum ANASTASIS_AUTHORIZATION_ChallengeResult
+iban_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct MHD_Connection *connection)
+{
+ struct IBAN_Context *ctx = as->ctx;
+ const char *mime;
+ const char *lang;
+ MHD_RESULT mres;
+
+ mime = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_ACCEPT);
+ if (NULL == mime)
+ mime = "text/plain";
+ lang = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_ACCEPT_LANGUAGE);
+ if (NULL == lang)
+ lang = "en";
+
+ /* Build HTTP response */
+ {
+ struct MHD_Response *resp;
+
+ if (TALER_MHD_xmime_matches (mime,
+ "application/json"))
+ {
+ char subject[64];
+
+ GNUNET_snprintf (subject,
+ sizeof (subject),
+ "Anastasis %llu",
+ (unsigned long long) as->code);
+ resp = TALER_MHD_MAKE_JSON_PACK (
+ GNUNET_JSON_pack_string ("challenge_type",
+ "IBAN_WIRE"),
+ GNUNET_JSON_pack_object_steal (
+ "wire_details",
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 (
+ "answer_code",
+ as->code),
+ TALER_JSON_pack_amount (
+ "challenge_amount",
+ &ctx->expected_amount),
+ GNUNET_JSON_pack_string (
+ "credit_iban",
+ ctx->business_iban),
+ GNUNET_JSON_pack_string (
+ "business_name",
+ ctx->business_name),
+ GNUNET_JSON_pack_string (
+ "wire_transfer_subject",
+ subject))));
+ }
+ else
+ {
+ size_t reply_len;
+ char *reply;
+
+ reply_len = GNUNET_asprintf (&reply,
+ get_message (ctx->messages,
+ connection,
+ "instructions"),
+ TALER_amount2s (&ctx->expected_amount),
+ ctx->business_name,
+ ctx->business_iban,
+ (unsigned long long) as->code);
+ resp = MHD_create_response_from_buffer (reply_len,
+ reply,
+ MHD_RESPMEM_MUST_COPY);
+ GNUNET_free (reply);
+ TALER_MHD_add_global_headers (resp);
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (resp,
+ MHD_HTTP_HEADER_CONTENT_TYPE,
+ "text/plain"));
+ }
+ mres = MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ resp);
+ MHD_destroy_response (resp);
+ if (MHD_YES != mres)
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS;
+ }
+}
+
+
+/**
* Begin issuing authentication challenge to user based on @a data.
* I.e. start to send IBAN or e-mail or launch video identification.
*
* @param as authorization state
* @param timeout how long do we have to produce a reply
+ * @param challenge_response hash of the challenge response, or NULL
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
-static enum ANASTASIS_AUTHORIZATION_Result
-iban_process (struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection)
+static enum ANASTASIS_AUTHORIZATION_SolveResult
+iban_solve (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct GNUNET_TIME_Absolute timeout,
+ const struct GNUNET_HashCode *challenge_response,
+ struct MHD_Connection *connection)
{
struct IBAN_Context *ctx = as->ctx;
struct ANASTASIS_DatabasePlugin *db = ctx->ac->db;
MHD_RESULT mres;
enum GNUNET_DB_QueryStatus qs;
- struct MHD_Response *resp;
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- struct GNUNET_TIME_Absolute after;
+ struct GNUNET_TIME_Timestamp after;
if (NULL == as->eh)
{
@@ -530,10 +536,6 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as,
.code = GNUNET_htonll (as->code)
};
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Subscribing to events for code %llu from %s\n",
- (unsigned long long) as->code,
- as->iban_number);
GNUNET_CRYPTO_hash (as->iban_number,
strlen (as->iban_number),
&espec.debit_iban_hash);
@@ -544,9 +546,9 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as,
&bank_event_cb,
as);
}
- after = GNUNET_TIME_absolute_subtract (now,
- CODE_VALIDITY_PERIOD);
- (void) GNUNET_TIME_round_abs (&after);
+ after = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_subtract (now,
+ CODE_VALIDITY_PERIOD));
qs = db->test_challenge_code_satisfied (db->cls,
&as->truth_uuid,
as->code,
@@ -555,45 +557,54 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as,
{
case GNUNET_DB_STATUS_HARD_ERROR:
case GNUNET_DB_STATUS_SOFT_ERROR:
- resp = TALER_MHD_make_error (TALER_EC_GENERIC_DB_FETCH_FAILED,
- "test_challenge_code_satisfied");
- mres = MHD_queue_response (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- resp);
- MHD_destroy_response (resp);
+ mres = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "test challenge code satisfied");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
switch (test_wire_transfers (as))
{
case WTS_SUCCESS:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"IBAN authorization finished!\n");
- return ANASTASIS_AUTHORIZATION_RES_FINISHED;
+ return ANASTASIS_AUTHORIZATION_SRES_FINISHED;
case WTS_NOT_READY:
break; /* continue below */
case WTS_FAILED_WITH_REPLY:
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED;
case WTS_FAILED_WITHOUT_REPLY:
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED;
}
if (GNUNET_TIME_absolute_is_future (timeout))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Suspending IBAN check until %s\n",
+ GNUNET_TIME_absolute2s (timeout));
as->connection = connection;
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_SRES_SUSPENDED;
}
- return respond_with_challenge (as,
- connection);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Timeout reached at %s, failing request\n",
+ GNUNET_TIME_absolute2s (timeout));
+ mres = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_FORBIDDEN,
+ TALER_EC_ANASTASIS_IBAN_MISSING_TRANSFER,
+ NULL);
+ if (MHD_YES != mres)
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"IBAN authorization finished!\n");
- return ANASTASIS_AUTHORIZATION_RES_FINISHED;
+ return ANASTASIS_AUTHORIZATION_SRES_FINISHED;
}
/* should be impossible */
GNUNET_break (0);
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED;
}
@@ -708,9 +719,9 @@ libanastasis_plugin_authorization_iban_init (void *cls)
plugin->cls = ctx;
plugin->validate = &iban_validate;
plugin->start = &iban_start;
- plugin->process = &iban_process;
+ plugin->challenge = &iban_challenge;
+ plugin->solve = &iban_solve;
plugin->cleanup = &iban_cleanup;
-
return plugin;
}
diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c
index 4adeffd..9410b58 100644
--- a/src/authorization/anastasis_authorization_plugin_post.c
+++ b/src/authorization/anastasis_authorization_plugin_post.c
@@ -3,7 +3,7 @@
Copyright (C) 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -232,7 +232,7 @@ post_validate (void *cls,
{
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_POST_INVALID,
"JSON malformed"))
return GNUNET_SYSERR;
@@ -248,7 +248,7 @@ post_validate (void *cls,
json_decref (j);
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_POST_INVALID,
"JSON lacked required address information"))
return GNUNET_SYSERR;
@@ -334,8 +334,12 @@ post_done_cb (void *cls,
{
struct ANASTASIS_AUTHORIZATION_State *as = cls;
- as->child = NULL;
as->cwh = NULL;
+ if (NULL != as->child)
+ {
+ GNUNET_OS_process_destroy (as->child);
+ as->child = NULL;
+ }
as->pst = type;
as->exit_code = exit_code;
MHD_resume_connection (as->connection);
@@ -348,14 +352,12 @@ post_done_cb (void *cls,
* I.e. start to send SMS or e-mail or launch video identification.
*
* @param as authorization state
- * @param timeout how long do we have to produce a reply
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
-static enum ANASTASIS_AUTHORIZATION_Result
-post_process (struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection)
+static enum ANASTASIS_AUTHORIZATION_ChallengeResult
+post_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct MHD_Connection *connection)
{
const char *mime;
const char *lang;
@@ -379,7 +381,6 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
GNUNET_JSON_spec_end ()
};
- (void) timeout;
mime = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
MHD_HTTP_HEADER_ACCEPT);
@@ -401,8 +402,8 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_POST_INVALID,
"address information incomplete");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
if (NULL == as->msg)
{
@@ -418,8 +419,8 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_POST_HELPER_EXEC_FAILED,
"pipe");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
as->child = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR,
p,
@@ -441,28 +442,19 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_POST_HELPER_EXEC_FAILED,
"exec");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
pipe_stdin = GNUNET_DISK_pipe_detach_end (p,
GNUNET_DISK_PIPE_END_WRITE);
GNUNET_assert (NULL != pipe_stdin);
GNUNET_DISK_pipe_close (p);
- {
- char *tpk;
-
- tpk = GNUNET_STRINGS_data_to_string_alloc (
- &as->truth_uuid,
- sizeof (as->truth_uuid));
- GNUNET_asprintf (&as->msg,
- get_message (as->ctx->messages,
- connection,
- "body"),
- (unsigned long long) as->code,
- tpk);
- GNUNET_free (tpk);
- }
-
+ GNUNET_asprintf (&as->msg,
+ get_message (as->ctx->messages,
+ connection,
+ "body"),
+ ANASTASIS_pin2s (as->code),
+ ANASTASIS_CRYPTO_uuid2s (&as->truth_uuid));
{
const char *off = as->msg;
size_t left = strlen (off);
@@ -483,8 +475,8 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_POST_HELPER_EXEC_FAILED,
"write");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
as->msg_off += ret;
off += ret;
@@ -497,14 +489,14 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
as);
as->connection = connection;
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUSPENDED;
}
if (NULL != as->cwh)
{
/* Spurious call, why are we here? */
GNUNET_break (0);
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUSPENDED;
}
if ( (GNUNET_OS_PROCESS_EXITED != as->pst) ||
(0 != as->exit_code) )
@@ -521,8 +513,8 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_POST_HELPER_COMMAND_FAILED,
es);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
/* Build HTTP response */
@@ -533,12 +525,9 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
"application/json"))
{
resp = TALER_MHD_MAKE_JSON_PACK (
- GNUNET_JSON_pack_uint64 ("code",
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED),
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED)),
- GNUNET_JSON_pack_string ("detail",
+ GNUNET_JSON_pack_string ("challenge_type",
+ "TAN_SENT"),
+ GNUNET_JSON_pack_string ("tan_address_hint",
zip));
}
else
@@ -558,12 +547,12 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_MHD_add_global_headers (resp);
}
mres = MHD_queue_response (connection,
- MHD_HTTP_FORBIDDEN,
+ MHD_HTTP_OK,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS;
}
}
@@ -648,7 +637,7 @@ libanastasis_plugin_authorization_post_init (void *cls)
plugin->cls = ctx;
plugin->validate = &post_validate;
plugin->start = &post_start;
- plugin->process = &post_process;
+ plugin->challenge = &post_challenge;
plugin->cleanup = &post_cleanup;
if (GNUNET_OK !=
diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c
index 94b2c0d..51457b6 100644
--- a/src/authorization/anastasis_authorization_plugin_sms.c
+++ b/src/authorization/anastasis_authorization_plugin_sms.c
@@ -3,7 +3,7 @@
Copyright (C) 2019, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -219,7 +219,7 @@ sms_validate (void *cls,
{
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_SMS_PHONE_INVALID,
NULL))
return GNUNET_SYSERR;
@@ -295,8 +295,12 @@ sms_done_cb (void *cls,
{
struct ANASTASIS_AUTHORIZATION_State *as = cls;
- as->child = NULL;
as->cwh = NULL;
+ if (NULL != as->child)
+ {
+ GNUNET_OS_process_destroy (as->child);
+ as->child = NULL;
+ }
as->pst = type;
as->exit_code = exit_code;
MHD_resume_connection (as->connection);
@@ -309,20 +313,17 @@ sms_done_cb (void *cls,
* I.e. start to send SMS or e-mail or launch video identification.
*
* @param as authorization state
- * @param timeout how long do we have to produce a reply
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
-static enum ANASTASIS_AUTHORIZATION_Result
-sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection)
+static enum ANASTASIS_AUTHORIZATION_ChallengeResult
+sms_challenge (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct MHD_Connection *connection)
{
MHD_RESULT mres;
const char *mime;
const char *lang;
- (void) timeout;
mime = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
MHD_HTTP_HEADER_ACCEPT);
@@ -347,8 +348,8 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_SMS_HELPER_EXEC_FAILED,
"pipe");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
as->child = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ERR,
p,
@@ -366,26 +367,17 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_SMS_HELPER_EXEC_FAILED,
"exec");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
pipe_stdin = GNUNET_DISK_pipe_detach_end (p,
GNUNET_DISK_PIPE_END_WRITE);
GNUNET_assert (NULL != pipe_stdin);
GNUNET_DISK_pipe_close (p);
- {
- char *tpk;
-
- tpk = GNUNET_STRINGS_data_to_string_alloc (
- &as->truth_uuid,
- sizeof (as->truth_uuid));
- GNUNET_asprintf (&as->msg,
- "A-%llu\nAnastasis\n%s",
- (unsigned long long) as->code,
- tpk);
- GNUNET_free (tpk);
- }
-
+ GNUNET_asprintf (&as->msg,
+ "%s\nAnastasis\n: %s",
+ ANASTASIS_pin2s (as->code),
+ ANASTASIS_CRYPTO_uuid2s (&as->truth_uuid));
{
const char *off = as->msg;
size_t left = strlen (off);
@@ -406,8 +398,8 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_SMS_HELPER_EXEC_FAILED,
"write");
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
as->msg_off += ret;
off += ret;
@@ -420,14 +412,14 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
as);
as->connection = connection;
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUSPENDED;
}
if (NULL != as->cwh)
{
/* Spurious call, why are we here? */
GNUNET_break (0);
MHD_suspend_connection (connection);
- return ANASTASIS_AUTHORIZATION_RES_SUSPENDED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUSPENDED;
}
if ( (GNUNET_OS_PROCESS_EXITED != as->pst) ||
(0 != as->exit_code) )
@@ -444,8 +436,8 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
TALER_EC_ANASTASIS_SMS_HELPER_COMMAND_FAILED,
es);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_FAILED;
}
/* Build HTTP response */
@@ -464,12 +456,9 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
"application/json"))
{
resp = TALER_MHD_MAKE_JSON_PACK (
- GNUNET_JSON_pack_uint64 ("code",
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED),
- GNUNET_JSON_pack_string ("hint",
- TALER_ErrorCode_get_hint (
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED)),
- GNUNET_JSON_pack_string ("detail",
+ GNUNET_JSON_pack_string ("challenge_type",
+ "TAN_SENT"),
+ GNUNET_JSON_pack_string ("tan_address_hint",
end));
}
else
@@ -493,12 +482,12 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as,
"text/plain"));
}
mres = MHD_queue_response (connection,
- MHD_HTTP_FORBIDDEN,
+ MHD_HTTP_OK,
resp);
MHD_destroy_response (resp);
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_SUCCESS;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_CRES_SUCCESS;
}
}
@@ -596,7 +585,7 @@ libanastasis_plugin_authorization_sms_init (void *cls)
plugin->cls = ctx;
plugin->validate = &sms_validate;
plugin->start = &sms_start;
- plugin->process = &sms_process;
+ plugin->challenge = &sms_challenge;
plugin->cleanup = &sms_cleanup;
if (GNUNET_OK !=
diff --git a/src/authorization/anastasis_authorization_plugin_totp.c b/src/authorization/anastasis_authorization_plugin_totp.c
index 0934910..c127e38 100644
--- a/src/authorization/anastasis_authorization_plugin_totp.c
+++ b/src/authorization/anastasis_authorization_plugin_totp.c
@@ -3,7 +3,7 @@
Copyright (C) 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -103,7 +103,7 @@ totp_validate (void *cls,
GNUNET_break_op (0);
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_TOTP_KEY_MISSING,
NULL))
return GNUNET_SYSERR;
@@ -114,7 +114,7 @@ totp_validate (void *cls,
GNUNET_break_op (0);
if (MHD_NO ==
TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_CONFLICT,
TALER_EC_ANASTASIS_TOTP_KEY_INVALID,
NULL))
return GNUNET_SYSERR;
@@ -144,7 +144,6 @@ compute_totp (int time_off,
uint8_t hmac[20]; /* SHA1: 20 bytes */
now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
while (time_off < 0)
{
now = GNUNET_TIME_absolute_subtract (now,
@@ -189,7 +188,7 @@ compute_totp (int time_off,
offset = hmac[sizeof (hmac) - 1] & 0x0f;
for (int count = 0; count < 4; count++)
- code |= hmac[offset + 3 - count] << (8 * count);
+ code |= ((uint32_t) hmac[offset + 3 - count]) << (8 * count);
code &= 0x7fffffff;
/* always use 8 digits (maximum) */
code = code % 100000000;
@@ -245,47 +244,29 @@ totp_start (void *cls,
/**
- * Begin issuing authentication challenge to user based on @a data.
+ * Check authentication response from the user.
*
* @param as authorization state
* @param timeout how long do we have to produce a reply
+ * @param challenge_response hash of the response
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
-static enum ANASTASIS_AUTHORIZATION_Result
-totp_process (struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection)
+static enum ANASTASIS_AUTHORIZATION_SolveResult
+totp_solve (struct ANASTASIS_AUTHORIZATION_State *as,
+ struct GNUNET_TIME_Absolute timeout,
+ const struct GNUNET_HashCode *challenge_response,
+ struct MHD_Connection *connection)
{
MHD_RESULT mres;
const char *mime;
const char *lang;
- const char *challenge_response_s;
- struct GNUNET_HashCode challenge_response;
-
- challenge_response_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "response");
- if ( (NULL == challenge_response_s) ||
- (GNUNET_OK !=
- GNUNET_CRYPTO_hash_from_string (challenge_response_s,
- &challenge_response)) )
- {
- GNUNET_break_op (0);
- mres = TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "response");
- if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
- }
for (unsigned int i = 0; i<=TIME_INTERVAL_RANGE * 2; i++)
if (0 ==
- GNUNET_memcmp (&challenge_response,
+ GNUNET_memcmp (challenge_response,
&as->valid_replies[i]))
- return ANASTASIS_AUTHORIZATION_RES_FINISHED;
+ return ANASTASIS_AUTHORIZATION_SRES_FINISHED;
mime = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
MHD_HTTP_HEADER_ACCEPT);
@@ -300,10 +281,9 @@ totp_process (struct ANASTASIS_AUTHORIZATION_State *as,
/* Build HTTP response */
{
struct MHD_Response *resp;
- struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Timestamp now;
- now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
+ now = GNUNET_TIME_timestamp_get ();
if (TALER_MHD_xmime_matches (mime,
"application/json"))
{
@@ -313,8 +293,8 @@ totp_process (struct ANASTASIS_AUTHORIZATION_State *as,
GNUNET_JSON_pack_string ("hint",
TALER_ErrorCode_get_hint (
TALER_EC_ANASTASIS_TRUTH_CHALLENGE_FAILED)),
- GNUNET_JSON_pack_time_abs ("server_time",
- now));
+ GNUNET_JSON_pack_timestamp ("server_time",
+ now));
}
else
{
@@ -325,7 +305,7 @@ totp_process (struct ANASTASIS_AUTHORIZATION_State *as,
response_size
= GNUNET_asprintf (&response,
"Server time: %s",
- GNUNET_STRINGS_absolute_time_to_string (now));
+ GNUNET_TIME_timestamp2s (now));
resp = MHD_create_response_from_buffer (response_size,
response,
MHD_RESPMEM_MUST_COPY);
@@ -341,8 +321,8 @@ totp_process (struct ANASTASIS_AUTHORIZATION_State *as,
MHD_destroy_response (resp);
}
if (MHD_YES != mres)
- return ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED;
- return ANASTASIS_AUTHORIZATION_RES_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED;
+ return ANASTASIS_AUTHORIZATION_SRES_FAILED;
}
@@ -379,7 +359,7 @@ libanastasis_plugin_authorization_totp_init (void *cls)
plugin->code_retransmission_frequency = plugin->code_validity_period;
plugin->validate = &totp_validate;
plugin->start = &totp_start;
- plugin->process = &totp_process;
+ plugin->solve = &totp_solve;
plugin->cleanup = &totp_cleanup;
return plugin;
}
diff --git a/src/authorization/authorization-email-messages.json b/src/authorization/authorization-email-messages.json
index 5a2e048..5e4ddb3 100644
--- a/src/authorization/authorization-email-messages.json
+++ b/src/authorization/authorization-email-messages.json
@@ -3,8 +3,8 @@
"instructions_i18n" : {
"de_DE" : "Ein Authorisierungscode wurde an %.*s@DOMAIN geschickt"
},
- "body" : "Your Anastasis recovery code is:\nA-%llu\n\nThis is for challenge %s.\n",
+ "body" : "Your Anastasis recovery code is:\n%s\n\nThis is for challenge %s.\n",
"body_i18n" : {
- "de_DE" : "Ihr Anastasis Autorisierungscode ist:\nA-%llu\n\nDies ist der Code für den Vorgang %s.\n"
+ "de_DE" : "Ihr Anastasis Autorisierungscode ist:\n%s\n\nDies ist der Code für den Vorgang %s.\n"
}
}
diff --git a/src/authorization/authorization-post-messages.json b/src/authorization/authorization-post-messages.json
index d2ac83a..c48c8ab 100644
--- a/src/authorization/authorization-post-messages.json
+++ b/src/authorization/authorization-post-messages.json
@@ -3,5 +3,5 @@
"instructions_i18n" : {
"de_DE" : "Ein Authorisierungscode wurde an eine Addresse mit der Postleitzahl %s geschickt"
},
- "body" : "Dear Customer\n\nThe Anastasis recovery code you need to\nrecover your data is A-%llu.\nThis is for challenge %s.\n\nBest regards\n\nYour Anastasis provider"
+ "body" : "Dear Customer\n\nThe Anastasis recovery code you need to\nrecover your data is %s.\nThis is for challenge %s.\n\nBest regards\n\nYour Anastasis provider"
}
diff --git a/src/authorization/iban.h b/src/authorization/iban.h
index 70db7ea..17836f4 100644
--- a/src/authorization/iban.h
+++ b/src/authorization/iban.h
@@ -3,7 +3,7 @@
Copyright (C) 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
diff --git a/src/authorization/libanastasiseufin/lae_common.h b/src/authorization/libanastasiseufin/lae_common.h
index 8879ba3..1c2c8fd 100644
--- a/src/authorization/libanastasiseufin/lae_common.h
+++ b/src/authorization/libanastasiseufin/lae_common.h
@@ -36,7 +36,7 @@
* @param auth authentication data to use
* @return #GNUNET_OK in success
*/
-int
+enum GNUNET_GenericReturnValue
ANASTASIS_EUFIN_setup_auth_ (
CURL *easy,
const struct ANASTASIS_EUFIN_AuthenticationData *auth);
diff --git a/src/authorization/libanastasiseufin/lae_credit.c b/src/authorization/libanastasiseufin/lae_credit.c
index e8cabb5..d3fd781 100644
--- a/src/authorization/libanastasiseufin/lae_credit.c
+++ b/src/authorization/libanastasiseufin/lae_credit.c
@@ -65,7 +65,7 @@ struct ANASTASIS_EUFIN_CreditHistoryHandle
* were set,
* #GNUNET_SYSERR if there was a protocol violation in @a history
*/
-static int
+static enum GNUNET_GenericReturnValue
parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh,
const json_t *history)
{
@@ -89,8 +89,8 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh,
struct GNUNET_JSON_Specification hist_spec[] = {
TALER_JSON_spec_amount_any ("amount",
&td.amount),
- TALER_JSON_spec_absolute_time ("date",
- &td.execution_date),
+ GNUNET_JSON_spec_timestamp ("date",
+ &td.execution_date),
GNUNET_JSON_spec_uint64 ("row_id",
&row_id),
GNUNET_JSON_spec_string ("subject",
diff --git a/src/authorization/test-post.sh b/src/authorization/test-post.sh
new file mode 100755
index 0000000..fd3a8d8
--- /dev/null
+++ b/src/authorization/test-post.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+# This file is in the public domain.
+set -eu
+ADDR=`jq -n '{
+ full_name: "John Doe",
+ street: "Bar street 3",
+ city: "Wuppertal",
+ postcode: 42289,
+ country: "DE",
+ }'`
+
+echo "Your recovery code is 1234" | ./anastasis-authorization-post.sh "$ADDR"
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 1046810..10edef5 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -18,11 +18,14 @@ anastasis_httpd_SOURCES = \
anastasis-httpd.c anastasis-httpd.h \
anastasis-httpd_mhd.c anastasis-httpd_mhd.h \
anastasis-httpd_policy.c anastasis-httpd_policy.h \
- anastasis-httpd_policy_upload.c \
- anastasis-httpd_truth.c anastasis-httpd_truth.h \
+ anastasis-httpd_policy-meta.c anastasis-httpd_policy-meta.h \
+ anastasis-httpd_policy-upload.c \
+ anastasis-httpd_truth.h \
anastasis-httpd_terms.c anastasis-httpd_terms.h \
anastasis-httpd_config.c anastasis-httpd_config.h \
- anastasis-httpd_truth_upload.c
+ anastasis-httpd_truth-challenge.c \
+ anastasis-httpd_truth-solve.c \
+ anastasis-httpd_truth-upload.c
anastasis_httpd_LDADD = \
$(top_builddir)/src/util/libanastasisutil.la \
@@ -38,7 +41,6 @@ anastasis_httpd_LDADD = \
-lgnunetjson \
-lgnunetutil \
-lmicrohttpd \
- -luuid \
$(XLIB)
EXTRA_DIST = \
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index ba5417b..ebfb0ae 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- (C) 2020 Anastasis SARL
+ (C) 2020-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -26,17 +26,13 @@
#include "anastasis-httpd_mhd.h"
#include "anastasis_database_lib.h"
#include "anastasis-httpd_policy.h"
+#include "anastasis-httpd_policy-meta.h"
#include "anastasis-httpd_truth.h"
#include "anastasis-httpd_terms.h"
#include "anastasis-httpd_config.h"
/**
- * Backlog for listen operation on unix-domain sockets.
- */
-#define UNIX_BACKLOG 500
-
-/**
* Upload limit to the service, in megabytes.
*/
unsigned long long int AH_upload_limit_mb;
@@ -72,11 +68,6 @@ const struct GNUNET_CONFIGURATION_Handle *AH_cfg;
char *AH_backend_url;
/**
- * Taler currency.
- */
-char *AH_currency;
-
-/**
* Our fulfillment URL.
*/
char *AH_fulfillment_url;
@@ -87,9 +78,9 @@ char *AH_fulfillment_url;
char *AH_business_name;
/**
- * Our server salt.
+ * Our provider salt.
*/
-struct ANASTASIS_CRYPTO_ProviderSaltP AH_server_salt;
+struct ANASTASIS_CRYPTO_ProviderSaltP AH_provider_salt;
/**
* Number of policy uploads permitted per annual fee payment.
@@ -360,12 +351,15 @@ url_handler (void *cls,
strlen ("/policy/")))
{
const char *account = url + strlen ("/policy/");
+ const char *end = strchr (account, '/');
struct ANASTASIS_CRYPTO_AccountPublicKeyP account_pub;
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (
account,
- strlen (account),
+ (NULL == end)
+ ? strlen (account)
+ : end - account,
&account_pub,
sizeof (struct ANASTASIS_CRYPTO_AccountPublicKeyP)))
{
@@ -374,14 +368,23 @@ url_handler (void *cls,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"account public key");
}
+ if ( (NULL != end) &&
+ (0 != strcmp (end,
+ "/meta")) )
+ return TMH_MHD_handler_static_response (&h404,
+ connection);
if (0 == strcmp (method,
MHD_HTTP_METHOD_GET))
{
- return AH_policy_get (connection,
- &account_pub);
+ if (NULL == end)
+ return AH_policy_get (connection,
+ &account_pub);
+ return AH_policy_meta_get (connection,
+ &account_pub);
}
- if (0 == strcmp (method,
- MHD_HTTP_METHOD_POST))
+ if ( (0 == strcmp (method,
+ MHD_HTTP_METHOD_POST)) &&
+ (NULL == end) )
{
return AH_handler_policy_post (connection,
hc,
@@ -403,12 +406,20 @@ url_handler (void *cls,
{
struct ANASTASIS_CRYPTO_TruthUUIDP tu;
const char *pub_key_str;
+ const char *end;
+ size_t len;
pub_key_str = &url[strlen ("/truth/")];
+ end = strchr (pub_key_str,
+ '/');
+ if (NULL == end)
+ len = strlen (pub_key_str);
+ else
+ len = end - pub_key_str;
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (
pub_key_str,
- strlen (pub_key_str),
+ len,
&tu,
sizeof(tu)))
{
@@ -418,15 +429,19 @@ url_handler (void *cls,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"truth UUID");
}
+ if ( (NULL != end) &&
+ (0 != strcmp (end, "/solve")) &&
+ (0 != strcmp (end, "/challenge")) )
+ return TMH_MHD_handler_static_response (&h404,
+ connection);
if (0 == strcmp (method,
- MHD_HTTP_METHOD_GET))
- {
- return AH_handler_truth_get (connection,
- &tu,
- hc);
- }
- if (0 == strcmp (method,
+ MHD_HTTP_METHOD_OPTIONS))
+ return TALER_MHD_reply_cors_preflight (connection);
+ if (0 != strcmp (method,
MHD_HTTP_METHOD_POST))
+ return TMH_MHD_handler_static_response (&h405,
+ connection);
+ if (NULL == end)
{
return AH_handler_truth_post (connection,
hc,
@@ -434,14 +449,27 @@ url_handler (void *cls,
upload_data,
upload_data_size);
}
- if (0 == strcmp (method,
- MHD_HTTP_METHOD_OPTIONS))
+ if (0 == strcmp (end,
+ "/solve"))
{
- return TALER_MHD_reply_cors_preflight (connection);
+ return AH_handler_truth_solve (connection,
+ hc,
+ &tu,
+ upload_data,
+ upload_data_size);
}
- return TMH_MHD_handler_static_response (&h405,
- connection);
- }
+ if (0 == strcmp (end,
+ "/challenge"))
+ {
+ return AH_handler_truth_challenge (connection,
+ hc,
+ &tu,
+ upload_data,
+ upload_data_size);
+ }
+ /* should be impossible to get here */
+ GNUNET_assert (0);
+ } /* end of "/truth/" prefix */
path_matched = false;
for (unsigned int i = 0; NULL != handlers[i].url; i++)
{
@@ -484,7 +512,8 @@ do_shutdown (void *cls)
{
(void) cls;
AH_resume_all_bc ();
- AH_truth_shutdown ();
+ AH_truth_challenge_shutdown ();
+ AH_truth_solve_shutdown ();
AH_truth_upload_shutdown ();
if (NULL != mhd_task)
{
@@ -722,34 +751,6 @@ run (void *cls,
return;
}
if (GNUNET_OK !=
- TALER_config_get_currency (config,
- &AH_currency))
- {
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (0 != strcasecmp (AH_currency,
- AH_annual_fee.currency))
- {
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "anastasis",
- "ANNUAL_FEE",
- "currency mismatch");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (GNUNET_OK !=
- TALER_amount_cmp_currency (&AH_insurance,
- &AH_annual_fee))
- {
- GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- "anastasis",
- "INSURANCE",
- "currency mismatch");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (config,
"anastasis-merchant-backend",
"PAYMENT_BACKEND_URL",
@@ -827,30 +828,30 @@ run (void *cls,
return;
}
{
- char *server_salt;
+ char *provider_salt;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (config,
"anastasis",
- "SERVER_SALT",
- &server_salt))
+ "PROVIDER_SALT",
+ &provider_salt))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"anastasis",
- "SERVER_SALT");
+ "PROVIDER_SALT");
GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_assert (GNUNET_YES ==
- GNUNET_CRYPTO_kdf (&AH_server_salt,
- sizeof (AH_server_salt),
- "anastasis-server-salt",
- strlen ("anastasis-server-salt"),
- server_salt,
- strlen (server_salt),
+ GNUNET_CRYPTO_kdf (&AH_provider_salt,
+ sizeof (AH_provider_salt),
+ "anastasis-provider-salt",
+ strlen ("anastasis-provider-salt"),
+ provider_salt,
+ strlen (provider_salt),
NULL,
0));
- GNUNET_free (server_salt);
+ GNUNET_free (provider_salt);
}
/* setup HTTP client event loop */
@@ -981,7 +982,6 @@ main (int argc,
"CERTTYPE",
"type of the TLS client certificate, defaults to PEM if not specified",
&certtype),
-
GNUNET_GETOPT_OPTION_END
};
diff --git a/src/backend/anastasis-httpd.h b/src/backend/anastasis-httpd.h
index 33e0504..1a87921 100644
--- a/src/backend/anastasis-httpd.h
+++ b/src/backend/anastasis-httpd.h
@@ -175,11 +175,6 @@ extern struct TALER_Amount AH_question_cost;
extern char *AH_backend_url;
/**
- * Taler currency.
- */
-extern char *AH_currency;
-
-/**
* Heap for processing timeouts of requests.
*/
extern struct GNUNET_CONTAINER_Heap *AH_to_heap;
@@ -205,9 +200,9 @@ extern char *AH_fulfillment_url;
extern char *AH_business_name;
/**
- * Our server salt.
+ * Our provider salt.
*/
-extern struct ANASTASIS_CRYPTO_ProviderSaltP AH_server_salt;
+extern struct ANASTASIS_CRYPTO_ProviderSaltP AH_provider_salt;
/**
* Our context for making HTTP requests.
diff --git a/src/backend/anastasis-httpd_config.c b/src/backend/anastasis-httpd_config.c
index d96d57e..677c5dc 100644
--- a/src/backend/anastasis-httpd_config.c
+++ b/src/backend/anastasis-httpd_config.c
@@ -3,7 +3,7 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -103,11 +103,11 @@ AH_handler_config (struct AH_RequestHandler *rh,
GNUNET_JSON_pack_string ("name",
"anastasis"),
GNUNET_JSON_pack_string ("version",
- "0:0:0"),
+ "0:1:0"),
+ GNUNET_JSON_pack_string ("implementation",
+ "urn:net:taler:specs:anastasis:c-reference"),
GNUNET_JSON_pack_string ("business_name",
AH_business_name),
- GNUNET_JSON_pack_string ("currency",
- (char *) AH_currency),
GNUNET_JSON_pack_array_steal ("methods",
method_arr),
GNUNET_JSON_pack_uint64 ("storage_limit_in_megabytes",
@@ -118,8 +118,8 @@ AH_handler_config (struct AH_RequestHandler *rh,
&AH_truth_upload_fee),
TALER_JSON_pack_amount ("liability_limit",
&AH_insurance),
- GNUNET_JSON_pack_data_auto ("server_salt",
- &AH_server_salt));
+ GNUNET_JSON_pack_data_auto ("provider_salt",
+ &AH_provider_salt));
}
diff --git a/src/backend/anastasis-httpd_policy-meta.c b/src/backend/anastasis-httpd_policy-meta.c
new file mode 100644
index 0000000..67acc52
--- /dev/null
+++ b/src/backend/anastasis-httpd_policy-meta.c
@@ -0,0 +1,192 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2022 Anastasis SARL
+
+ Anastasis is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file anastasis-httpd_policy-meta.c
+ * @brief functions to handle incoming requests on /policy/$PID/meta
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "anastasis-httpd.h"
+#include "anastasis-httpd_policy-meta.h"
+#include "anastasis_service.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_rest_lib.h>
+#include <taler/taler_json_lib.h>
+#include <taler/taler_merchant_service.h>
+#include <taler/taler_signatures.h>
+
+
+/**
+ * Function called on matching meta data. Note that if the client did
+ * not provide meta data for @a version, the function will be called
+ * with @a recovery_meta_data being NULL.
+ *
+ * @param cls closure with a `json_t *` to build up
+ * @param version the version of the recovery document
+ * @param ts timestamp when the document was created
+ * @param recovery_meta_data contains meta data about the encrypted recovery document
+ * @param recovery_meta_data_size size of @a recovery_meta_data blob
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_NO to abort iteration
+ */
+static enum GNUNET_GenericReturnValue
+build_meta_result (void *cls,
+ uint32_t version,
+ struct GNUNET_TIME_Timestamp ts,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size)
+{
+ json_t *result = cls;
+ char version_s[14];
+
+ GNUNET_snprintf (version_s,
+ sizeof (version_s),
+ "%u",
+ (unsigned int) version);
+ GNUNET_assert (0 ==
+ json_object_set_new (
+ result,
+ version_s,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_data_varsize (
+ "meta",
+ recovery_meta_data,
+ recovery_meta_data_size),
+ GNUNET_JSON_pack_timestamp (
+ "upload_time",
+ ts))));
+ return GNUNET_OK;
+}
+
+
+/**
+ * Return the meta data on recovery documents of @a account on @a
+ * connection.
+ *
+ * @param connection MHD connection to use
+ * @param account_pub account to query
+ * @return MHD result code
+ */
+static MHD_RESULT
+return_policy_meta (
+ struct MHD_Connection *connection,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub)
+{
+ enum GNUNET_DB_QueryStatus qs;
+ uint32_t max_version = INT32_MAX; /* Postgres is using signed ints... */
+ json_t *result;
+
+ {
+ const char *version_s;
+
+ version_s = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "max_version");
+ if (NULL != version_s)
+ {
+ char dummy;
+
+ if (1 != sscanf (version_s,
+ "%u%c",
+ &max_version,
+ &dummy))
+ {
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "version");
+ }
+ if (max_version > INT32_MAX)
+ max_version = INT32_MAX; /* cap to signed range */
+ }
+ }
+ result = json_object ();
+ GNUNET_assert (NULL != result);
+ qs = db->get_recovery_meta_data (db->cls,
+ account_pub,
+ max_version,
+ &build_meta_result,
+ result);
+
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "get_recovery_document");
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_SOFT_FAILURE,
+ "get_recovery_document");
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_ANASTASIS_POLICY_NOT_FOUND,
+ NULL);
+ default:
+ /* interesting case below */
+ break;
+ }
+
+ return TALER_MHD_reply_json_steal (connection,
+ result,
+ MHD_HTTP_OK);
+}
+
+
+MHD_RESULT
+AH_policy_meta_get (
+ struct MHD_Connection *connection,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub)
+{
+ struct GNUNET_HashCode recovery_data_hash;
+ enum ANASTASIS_DB_AccountStatus as;
+ uint32_t version;
+ struct GNUNET_TIME_Timestamp expiration;
+
+ as = db->lookup_account (db->cls,
+ account_pub,
+ &expiration,
+ &recovery_data_hash,
+ &version);
+ switch (as)
+ {
+ case ANASTASIS_DB_ACCOUNT_STATUS_PAYMENT_REQUIRED:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_ANASTASIS_POLICY_NOT_FOUND,
+ "account expired: payment required");
+ case ANASTASIS_DB_ACCOUNT_STATUS_HARD_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "lookup account");
+ case ANASTASIS_DB_ACCOUNT_STATUS_NO_RESULTS:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_ANASTASIS_POLICY_NOT_FOUND,
+ "no such account");
+ case ANASTASIS_DB_ACCOUNT_STATUS_VALID_HASH_RETURNED:
+ /* We have results, should fetch and return them! */
+ break;
+ }
+ return return_policy_meta (connection,
+ account_pub);
+}
diff --git a/src/backend/anastasis-httpd_policy-meta.h b/src/backend/anastasis-httpd_policy-meta.h
new file mode 100644
index 0000000..8c48fc6
--- /dev/null
+++ b/src/backend/anastasis-httpd_policy-meta.h
@@ -0,0 +1,41 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2022 Anastasis SARL
+
+ Anastasis is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file anastasis-httpd_policy-meta.h
+ * @brief functions to handle incoming requests on /policy/
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ * @author Christian Grothoff
+ */
+#ifndef ANASTASIS_HTTPD_POLICY_META_H
+#define ANASTASIS_HTTPD_POLICY_META_H
+#include <microhttpd.h>
+
+
+/**
+ * Handle GET /policy/$ACCOUNT_PUB/meta request.
+ *
+ * @param connection the MHD connection to handle
+ * @param account_pub public key of the account
+ * @return MHD result code
+ */
+MHD_RESULT
+AH_policy_meta_get (
+ struct MHD_Connection *connection,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub);
+
+
+#endif
diff --git a/src/backend/anastasis-httpd_policy_upload.c b/src/backend/anastasis-httpd_policy-upload.c
index 0f9d8d6..83e8117 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy-upload.c
@@ -35,7 +35,7 @@
* we are awaiting payment before giving up?
*/
#define CHECK_PAYMENT_GENERIC_TIMEOUT GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MINUTES, 30)
+ GNUNET_TIME_UNIT_SECONDS, 30)
/**
@@ -86,6 +86,16 @@ struct PolicyUploadContext
char *upload;
/**
+ * Meta data uploaded by the client, or NULL for none.
+ */
+ void *meta_data;
+
+ /**
+ * Number of bytes in @e meta_data.
+ */
+ size_t meta_data_size;
+
+ /**
* Used while we are awaiting proposal creation.
*/
struct TALER_MERCHANT_PostOrdersHandle *po;
@@ -114,7 +124,7 @@ struct PolicyUploadContext
* Timestamp of the order in @e payment_identifier. Used to
* select the most recent unpaid offer.
*/
- struct GNUNET_TIME_Absolute existing_pi_timestamp;
+ struct GNUNET_TIME_Timestamp existing_pi_timestamp;
/**
* When does the operation timeout?
@@ -125,13 +135,13 @@ struct PolicyUploadContext
* How long must the account be valid? Determines whether we should
* trigger payment, and if so how much.
*/
- struct GNUNET_TIME_Absolute end_date;
+ struct GNUNET_TIME_Timestamp end_date;
/**
* How long is the account already valid?
* Determines how much the user needs to pay.
*/
- struct GNUNET_TIME_Absolute paid_until;
+ struct GNUNET_TIME_Timestamp paid_until;
/**
* Expected total upload size.
@@ -220,6 +230,7 @@ cleanup_ctx (struct TM_HandlerContext *hc)
if (NULL != puc->resp)
MHD_destroy_response (puc->resp);
GNUNET_free (puc->upload);
+ GNUNET_free (puc->meta_data);
GNUNET_free (puc);
}
@@ -376,15 +387,14 @@ proposal_cb (void *cls,
* Callback to process a GET /check-payment request
*
* @param cls our `struct PolicyUploadContext`
- * @param hr HTTP response details
* @param osr order status
*/
static void
check_payment_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_OrderStatusResponse *osr)
{
struct PolicyUploadContext *puc = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr;
/* refunds are not supported, verify */
puc->cpo = NULL;
@@ -411,10 +421,12 @@ check_payment_cb (void *cls,
puc->response_code = MHD_HTTP_BAD_GATEWAY;
return;
}
+
+ GNUNET_assert (MHD_HTTP_OK == hr->http_status);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Payment status checked: %s\n",
- osr->status ? "paid" : "unpaid");
- switch (osr->status)
+ "Payment status checked: %d\n",
+ osr->details.ok.status);
+ switch (osr->details.ok.status)
{
case TALER_MERCHANT_OSC_PAID:
{
@@ -424,13 +436,12 @@ check_payment_cb (void *cls,
const json_t *contract;
struct TALER_Amount amount;
struct GNUNET_JSON_Specification cspec[] = {
- TALER_JSON_spec_amount ("amount",
- AH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
GNUNET_JSON_spec_end ()
};
- contract = osr->details.paid.contract_terms;
+ contract = osr->details.ok.details.paid.contract_terms;
if (GNUNET_OK !=
GNUNET_JSON_parse (contract,
cspec,
@@ -475,7 +486,7 @@ check_payment_cb (void *cls,
case TALER_MERCHANT_OSC_CLAIMED:
break;
}
- if (0 != puc->existing_pi_timestamp.abs_value_us)
+ if (! GNUNET_TIME_absolute_is_zero (puc->existing_pi_timestamp.abs_time))
{
/* repeat payment request */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -526,7 +537,6 @@ await_payment (struct PolicyUploadContext *puc)
AH_backend_url,
order_id,
NULL /* our payments are NOT session-bound */,
- false,
timeout,
&check_payment_cb,
puc);
@@ -547,6 +557,7 @@ await_payment (struct PolicyUploadContext *puc)
static MHD_RESULT
begin_payment (struct PolicyUploadContext *puc)
{
+ static const char *no_uuids[1] = { NULL };
json_t *order;
GNUNET_CONTAINER_DLL_insert (puc_head,
@@ -574,6 +585,10 @@ begin_payment (struct PolicyUploadContext *puc)
order_id = GNUNET_STRINGS_data_to_string_alloc (
&puc->payment_identifier,
sizeof(struct ANASTASIS_PaymentSecretP));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Creating order for %u years with payment of %s\n",
+ puc->years_to_pay,
+ TALER_amount2s (&upload_fee));
order = json_pack ("{s:o, s:s, s:[{s:s,s:I,s:s}], s:s }",
"amount", TALER_JSON_from_amount (&upload_fee),
"summary", "Anastasis policy storage fee",
@@ -593,7 +608,7 @@ begin_payment (struct PolicyUploadContext *puc)
0,
NULL, /* no inventory products */
0,
- NULL, /* no uuids */
+ no_uuids, /* no uuids */
false, /* do NOT require claim token */
&proposal_cb,
puc);
@@ -647,35 +662,44 @@ AH_handler_policy_post (
hc->cc = &cleanup_ctx;
puc->con = connection;
+ TALER_MHD_parse_request_header_auto (connection,
+ ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER,
+ &puc->payment_identifier,
+ puc->payment_identifier_provided);
+ puc->account = *account_pub;
+
+ /* check for meta-data */
{
- const char *pay_id;
+ const char *metas;
- pay_id = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER);
- if (NULL != pay_id)
+ metas = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ ANASTASIS_HTTP_HEADER_POLICY_META_DATA);
+ if (NULL == metas)
{
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (
- pay_id,
- strlen (pay_id),
- &puc->payment_identifier,
- sizeof (struct ANASTASIS_PaymentSecretP)))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER
- " header must be a base32-encoded Payment-Secret");
- }
- puc->payment_identifier_provided = true;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Policy upload started with payment identifier `%s'\n",
- pay_id);
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_HTTP_HEADERS_MALFORMED,
+ ANASTASIS_HTTP_HEADER_POLICY_META_DATA
+ " header must be present");
+ }
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data_alloc (metas,
+ strlen (metas),
+ &puc->meta_data,
+ &puc->meta_data_size))
+ {
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_HTTP_HEADERS_MALFORMED,
+ ANASTASIS_HTTP_HEADER_POLICY_META_DATA
+ " header must include a base32-encoded value");
}
}
- puc->account = *account_pub;
/* now setup 'puc' */
{
const char *lens;
@@ -720,28 +744,10 @@ AH_handler_policy_post (
}
puc->upload_size = (size_t) len;
}
- {
- /* Check if header contains Anastasis-Policy-Signature */
- const char *sig_s;
- sig_s = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE);
- if ( (NULL == sig_s) ||
- (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (sig_s,
- strlen (sig_s),
- &puc->account_sig,
- sizeof (puc->account_sig))) )
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_ANASTASIS_POLICY_BAD_SIGNATURE,
- ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE
- " header must include a base32-encoded EdDSA signature");
- }
- }
+ TALER_MHD_parse_request_header_auto_t (connection,
+ ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE,
+ &puc->account_sig);
{
/* Check if header contains an ETAG */
const char *etag;
@@ -750,9 +756,12 @@ AH_handler_policy_post (
MHD_HEADER_KIND,
MHD_HTTP_HEADER_IF_NONE_MATCH);
if ( (NULL == etag) ||
+ (2 >= strlen (etag)) ||
+ ('"' != etag[0]) ||
+ ('"' != etag[strlen (etag) - 1]) ||
(GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (etag,
- strlen (etag),
+ GNUNET_STRINGS_string_to_data (etag + 1,
+ strlen (etag) - 2,
&puc->new_policy_upload_hash,
sizeof (puc->new_policy_upload_hash))) )
{
@@ -786,39 +795,10 @@ AH_handler_policy_post (
}
}
- {
- const char *long_poll_timeout_ms;
-
- long_poll_timeout_ms = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "timeout_ms");
- if (NULL != long_poll_timeout_ms)
- {
- unsigned int timeout;
- char dummy;
-
- if (1 != sscanf (long_poll_timeout_ms,
- "%u%c",
- &timeout,
- &dummy))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "timeout_ms (must be non-negative number)");
- }
- puc->timeout
- = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_MILLISECONDS,
- timeout));
- }
- else
- {
- puc->timeout = GNUNET_TIME_relative_to_absolute
- (CHECK_PAYMENT_GENERIC_TIMEOUT);
- }
- }
+ puc->timeout = GNUNET_TIME_relative_to_absolute (
+ CHECK_PAYMENT_GENERIC_TIMEOUT);
+ TALER_MHD_parse_request_timeout (connection,
+ &puc->timeout);
/* check if the client insists on paying */
{
@@ -846,9 +826,9 @@ AH_handler_policy_post (
}
else
{
- years = 0;
+ years = 1;
}
- puc->end_date = GNUNET_TIME_relative_to_absolute (
+ puc->end_date = GNUNET_TIME_relative_to_timestamp (
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
years));
}
@@ -860,11 +840,15 @@ AH_handler_policy_post (
{
struct GNUNET_TIME_Relative rem;
- rem = GNUNET_TIME_absolute_get_remaining (puc->end_date);
+ rem = GNUNET_TIME_absolute_get_remaining (puc->end_date.abs_time);
puc->years_to_pay = rem.rel_value_us
/ GNUNET_TIME_UNIT_YEARS.rel_value_us;
if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
puc->years_to_pay++;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Calculated years to pay to be %u until %s\n",
+ puc->years_to_pay,
+ GNUNET_TIME_absolute2s (puc->end_date.abs_time));
if (puc->payment_identifier_provided)
{
@@ -905,18 +889,14 @@ AH_handler_policy_post (
if (! puc->payment_identifier_provided)
{
- struct TALER_Amount zero_amount;
enum GNUNET_DB_QueryStatus qs;
struct GNUNET_TIME_Relative rel;
- TALER_amount_set_zero (AH_currency,
- &zero_amount);
/* generate fresh payment identifier */
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
&puc->payment_identifier,
sizeof (struct ANASTASIS_PaymentSecretP));
- if (0 != TALER_amount_cmp (&AH_annual_fee,
- &zero_amount))
+ if (! TALER_amount_is_zero (&AH_annual_fee))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"No payment identifier, requesting payment\n");
@@ -940,10 +920,10 @@ AH_handler_policy_post (
ANASTASIS_MAX_YEARS_STORAGE);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Policy lifetime is %s (%u years)\n",
- GNUNET_STRINGS_relative_time_to_string (rel,
- GNUNET_YES),
+ GNUNET_TIME_relative2s (rel,
+ true),
ANASTASIS_MAX_YEARS_STORAGE);
- puc->paid_until = GNUNET_TIME_relative_to_absolute (rel);
+ puc->paid_until = GNUNET_TIME_relative_to_timestamp (rel);
qs = db->update_lifetime (db->cls,
account_pub,
&puc->payment_identifier,
@@ -964,7 +944,7 @@ AH_handler_policy_post (
struct GNUNET_HashCode hc;
enum ANASTASIS_DB_AccountStatus as;
uint32_t version;
- struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Timestamp now;
struct GNUNET_TIME_Relative rem;
as = db->lookup_account (db->cls,
@@ -972,16 +952,21 @@ AH_handler_policy_post (
&puc->paid_until,
&hc,
&version);
- now = GNUNET_TIME_absolute_get ();
- if (puc->paid_until.abs_value_us < now.abs_value_us)
+ now = GNUNET_TIME_timestamp_get ();
+ if (GNUNET_TIME_timestamp_cmp (puc->paid_until,
+ <,
+ now))
puc->paid_until = now;
- rem = GNUNET_TIME_absolute_get_difference (puc->paid_until,
- puc->end_date);
+ rem = GNUNET_TIME_absolute_get_difference (puc->paid_until.abs_time,
+ puc->end_date.abs_time);
puc->years_to_pay = rem.rel_value_us
/ GNUNET_TIME_UNIT_YEARS.rel_value_us;
if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
puc->years_to_pay++;
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Calculated years to pay to be %u until %s\n",
+ puc->years_to_pay,
+ GNUNET_TIME_absolute2s (puc->end_date.abs_time));
if ( (ANASTASIS_DB_ACCOUNT_STATUS_VALID_HASH_RETURNED == as) &&
(0 != puc->years_to_pay) )
{
@@ -1112,6 +1097,8 @@ AH_handler_policy_post (
&puc->new_policy_upload_hash,
puc->upload,
puc->upload_size,
+ puc->meta_data,
+ puc->meta_data_size,
&puc->payment_identifier,
&version);
GNUNET_snprintf (version_s,
@@ -1122,7 +1109,7 @@ AH_handler_policy_post (
sizeof (expir_s),
"%llu",
(unsigned long long)
- (puc->paid_until.abs_value_us
+ (puc->paid_until.abs_time.abs_value_us
/ GNUNET_TIME_UNIT_SECONDS.rel_value_us));
switch (ss)
{
diff --git a/src/backend/anastasis-httpd_policy.c b/src/backend/anastasis-httpd_policy.c
index 165be44..177cc06 100644
--- a/src/backend/anastasis-httpd_policy.c
+++ b/src/backend/anastasis-httpd_policy.c
@@ -30,17 +30,9 @@
#include <taler/taler_merchant_service.h>
#include <taler/taler_signatures.h>
-/**
- * How long do we hold an HTTP client connection if
- * we are awaiting payment before giving up?
- */
-#define CHECK_PAYMENT_GENERIC_TIMEOUT GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MINUTES, 30)
-
/**
- * Return the current recoverydocument of @a account on @a connection
- * using @a default_http_status on success.
+ * Return the current recoverydocument of @a account on @a connection.
*
* @param connection MHD connection to use
* @param account_pub account to query
@@ -130,25 +122,30 @@ return_policy (struct MHD_Connection *connection,
{
char *sig_s;
char *etag;
+ char *etagq;
sig_s = GNUNET_STRINGS_data_to_string_alloc (&account_sig,
sizeof (account_sig));
- etag = GNUNET_STRINGS_data_to_string_alloc (&recovery_data_hash,
- sizeof (recovery_data_hash));
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
ANASTASIS_HTTP_HEADER_POLICY_SIGNATURE,
sig_s));
+ GNUNET_free (sig_s);
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
ANASTASIS_HTTP_HEADER_POLICY_VERSION,
version_s));
+ etag = GNUNET_STRINGS_data_to_string_alloc (&recovery_data_hash,
+ sizeof (recovery_data_hash));
+ GNUNET_asprintf (&etagq,
+ "\"%s\"",
+ etag);
+ GNUNET_free (etag);
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
MHD_HTTP_HEADER_ETAG,
- etag));
- GNUNET_free (etag);
- GNUNET_free (sig_s);
+ etagq));
+ GNUNET_free (etagq);
}
{
MHD_RESULT ret;
@@ -170,7 +167,7 @@ AH_policy_get (struct MHD_Connection *connection,
enum ANASTASIS_DB_AccountStatus as;
MHD_RESULT ret;
uint32_t version;
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_TIME_Timestamp expiration;
as = db->lookup_account (db->cls,
account_pub,
@@ -211,13 +208,16 @@ AH_policy_get (struct MHD_Connection *connection,
inm = MHD_lookup_connection_value (connection,
MHD_HEADER_KIND,
MHD_HTTP_HEADER_IF_NONE_MATCH);
- if (NULL != inm)
+ if ( (NULL != inm) &&
+ (2 < strlen (inm)) &&
+ ('"' == inm[0]) &&
+ ('"' == inm[strlen (inm) - 1]) )
{
struct GNUNET_HashCode inm_h;
if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (inm,
- strlen (inm),
+ GNUNET_STRINGS_string_to_data (inm + 1,
+ strlen (inm) - 2,
&inm_h,
sizeof (inm_h)))
{
diff --git a/src/backend/anastasis-httpd_policy.h b/src/backend/anastasis-httpd_policy.h
index 33d51cf..2735db6 100644
--- a/src/backend/anastasis-httpd_policy.h
+++ b/src/backend/anastasis-httpd_policy.h
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2014, 2015, 2016 Anastasis SARL
+ Copyright (C) 2019-2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
diff --git a/src/backend/anastasis-httpd_terms.c b/src/backend/anastasis-httpd_terms.c
index 55a28e1..94a6380 100644
--- a/src/backend/anastasis-httpd_terms.c
+++ b/src/backend/anastasis-httpd_terms.c
@@ -3,7 +3,7 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
diff --git a/src/backend/anastasis-httpd_truth-challenge.c b/src/backend/anastasis-httpd_truth-challenge.c
new file mode 100644
index 0000000..a7d138f
--- /dev/null
+++ b/src/backend/anastasis-httpd_truth-challenge.c
@@ -0,0 +1,1331 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2019-2022 Anastasis SARL
+
+ Anastasis is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file anastasis-httpd_truth-challenge.c
+ * @brief functions to handle incoming requests on /truth/$TID/challenge
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "anastasis-httpd.h"
+#include "anastasis_service.h"
+#include "anastasis-httpd_truth.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_rest_lib.h>
+#include "anastasis_authorization_lib.h"
+#include <taler/taler_merchant_service.h>
+#include <taler/taler_json_lib.h>
+#include <taler/taler_mhd_lib.h>
+
+/**
+ * What is the maximum frequency at which we allow
+ * clients to attempt to answer security questions?
+ */
+#define MAX_QUESTION_FREQ GNUNET_TIME_relative_multiply ( \
+ GNUNET_TIME_UNIT_SECONDS, 30)
+
+/**
+ * How long should the wallet check for auto-refunds before giving up?
+ */
+#define AUTO_REFUND_TIMEOUT GNUNET_TIME_relative_multiply ( \
+ GNUNET_TIME_UNIT_MINUTES, 2)
+
+/**
+ * How long should the wallet check for payment before giving up?
+ */
+#define PAYMENT_TIMEOUT GNUNET_TIME_relative_multiply ( \
+ GNUNET_TIME_UNIT_SECONDS, 15)
+
+
+/**
+ * How many retries do we allow per code?
+ */
+#define INITIAL_RETRY_COUNTER 3
+
+
+struct ChallengeContext
+{
+
+ /**
+ * Payment Identifier
+ */
+ struct ANASTASIS_PaymentSecretP payment_identifier;
+
+ /**
+ * Public key of the challenge which is solved.
+ */
+ struct ANASTASIS_CRYPTO_TruthUUIDP truth_uuid;
+
+ /**
+ * Key to decrypt the truth.
+ */
+ struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
+
+ /**
+ * Cost for paying the challenge.
+ */
+ struct TALER_Amount challenge_cost;
+
+ /**
+ * Our handler context.
+ */
+ struct TM_HandlerContext *hc;
+
+ /**
+ * Opaque parsing context.
+ */
+ void *opaque_post_parsing_context;
+
+ /**
+ * Uploaded JSON data, NULL if upload is not yet complete.
+ */
+ json_t *root;
+
+ /**
+ * Kept in DLL for shutdown handling while suspended.
+ */
+ struct ChallengeContext *next;
+
+ /**
+ * Kept in DLL for shutdown handling while suspended.
+ */
+ struct ChallengeContext *prev;
+
+ /**
+ * Connection handle for closing or resuming
+ */
+ struct MHD_Connection *connection;
+
+ /**
+ * Reference to the authorization plugin which was loaded
+ */
+ struct ANASTASIS_AuthorizationPlugin *authorization;
+
+ /**
+ * Status of the authorization
+ */
+ struct ANASTASIS_AUTHORIZATION_State *as;
+
+ /**
+ * Used while we are awaiting proposal creation.
+ */
+ struct TALER_MERCHANT_PostOrdersHandle *po;
+
+ /**
+ * Used while we are waiting payment.
+ */
+ struct TALER_MERCHANT_OrderMerchantGetHandle *cpo;
+
+ /**
+ * HTTP response code to use on resume, if non-NULL.
+ */
+ struct MHD_Response *resp;
+
+ /**
+ * Our entry in the #to_heap, or NULL.
+ */
+ struct GNUNET_CONTAINER_HeapNode *hn;
+
+ /**
+ * When should this request time out?
+ */
+ struct GNUNET_TIME_Absolute timeout;
+
+ /**
+ * Random authorization code we are using.
+ */
+ uint64_t code;
+
+ /**
+ * HTTP response code to use on resume, if resp is set.
+ */
+ unsigned int response_code;
+
+ /**
+ * true if client did not provide a payment secret / order ID.
+ */
+ bool no_payment_identifier_provided;
+
+ /**
+ * True if this entry is in the #gc_head DLL.
+ */
+ bool in_list;
+
+ /**
+ * True if this entry is currently suspended.
+ */
+ bool suspended;
+
+};
+
+
+/**
+ * Information we track for refunds.
+ */
+struct RefundEntry
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct RefundEntry *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct RefundEntry *prev;
+
+ /**
+ * Operation handle.
+ */
+ struct TALER_MERCHANT_OrderRefundHandle *ro;
+
+ /**
+ * Which order is being refunded.
+ */
+ char *order_id;
+
+ /**
+ * Payment Identifier
+ */
+ struct ANASTASIS_PaymentSecretP payment_identifier;
+
+ /**
+ * Public key of the challenge which is solved.
+ */
+ struct ANASTASIS_CRYPTO_TruthUUIDP truth_uuid;
+};
+
+
+/**
+ * Head of linked list of active refund operations.
+ */
+static struct RefundEntry *re_head;
+
+/**
+ * Tail of linked list of active refund operations.
+ */
+static struct RefundEntry *re_tail;
+
+/**
+ * Head of linked list over all authorization processes
+ */
+static struct ChallengeContext *gc_head;
+
+/**
+ * Tail of linked list over all authorization processes
+ */
+static struct ChallengeContext *gc_tail;
+
+/**
+ * Task running #do_timeout().
+ */
+static struct GNUNET_SCHEDULER_Task *to_task;
+
+
+/**
+ * Generate a response telling the client that answering this
+ * challenge failed because the rate limit has been exceeded.
+ *
+ * @param gc request to answer for
+ * @return MHD status code
+ */
+static MHD_RESULT
+reply_rate_limited (const struct ChallengeContext *gc)
+{
+ return TALER_MHD_REPLY_JSON_PACK (
+ gc->connection,
+ MHD_HTTP_TOO_MANY_REQUESTS,
+ TALER_MHD_PACK_EC (TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED),
+ GNUNET_JSON_pack_uint64 ("request_limit",
+ gc->authorization->retry_counter),
+ GNUNET_JSON_pack_time_rel ("request_frequency",
+ gc->authorization->code_rotation_period));
+}
+
+
+/**
+ * Timeout requests that are past their due date.
+ *
+ * @param cls NULL
+ */
+static void
+do_timeout (void *cls)
+{
+ struct ChallengeContext *gc;
+
+ (void) cls;
+ to_task = NULL;
+ while (NULL !=
+ (gc = GNUNET_CONTAINER_heap_peek (AH_to_heap)))
+ {
+ if (GNUNET_TIME_absolute_is_future (gc->timeout))
+ break;
+ if (gc->suspended)
+ {
+ /* Test needed as we may have a "concurrent"
+ wakeup from another task that did not clear
+ this entry from the heap before the
+ response process concluded. */
+ gc->suspended = false;
+ MHD_resume_connection (gc->connection);
+ }
+ GNUNET_assert (NULL != gc->hn);
+ gc->hn = NULL;
+ GNUNET_assert (gc ==
+ GNUNET_CONTAINER_heap_remove_root (AH_to_heap));
+ }
+ if (NULL == gc)
+ return;
+ to_task = GNUNET_SCHEDULER_add_at (gc->timeout,
+ &do_timeout,
+ NULL);
+}
+
+
+void
+AH_truth_challenge_shutdown (void)
+{
+ struct ChallengeContext *gc;
+ struct RefundEntry *re;
+
+ while (NULL != (re = re_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (re_head,
+ re_tail,
+ re);
+ if (NULL != re->ro)
+ {
+ TALER_MERCHANT_post_order_refund_cancel (re->ro);
+ re->ro = NULL;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Refund `%s' failed due to shutdown\n",
+ re->order_id);
+ GNUNET_free (re->order_id);
+ GNUNET_free (re);
+ }
+
+ while (NULL != (gc = gc_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (gc_head,
+ gc_tail,
+ gc);
+ gc->in_list = false;
+ if (NULL != gc->cpo)
+ {
+ TALER_MERCHANT_merchant_order_get_cancel (gc->cpo);
+ gc->cpo = NULL;
+ }
+ if (NULL != gc->po)
+ {
+ TALER_MERCHANT_orders_post_cancel (gc->po);
+ gc->po = NULL;
+ }
+ if (gc->suspended)
+ {
+ gc->suspended = false;
+ MHD_resume_connection (gc->connection);
+ }
+ if (NULL != gc->as)
+ {
+ gc->authorization->cleanup (gc->as);
+ gc->as = NULL;
+ gc->authorization = NULL;
+ }
+ }
+ ANASTASIS_authorization_plugin_shutdown ();
+ if (NULL != to_task)
+ {
+ GNUNET_SCHEDULER_cancel (to_task);
+ to_task = NULL;
+ }
+}
+
+
+/**
+ * Callback to process a POST /orders/ID/refund request
+ *
+ * @param cls closure with a `struct RefundEntry *`
+ * @param rr response details
+ */
+static void
+refund_cb (
+ void *cls,
+ const struct TALER_MERCHANT_RefundResponse *rr)
+{
+ struct RefundEntry *re = cls;
+
+ re->ro = NULL;
+ switch (rr->hr.http_status)
+ {
+ case MHD_HTTP_OK:
+ {
+ enum GNUNET_DB_QueryStatus qs;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Refund `%s' succeeded\n",
+ re->order_id);
+ qs = db->record_challenge_refund (db->cls,
+ &re->truth_uuid,
+ &re->payment_identifier);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
+ break;
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ break;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ GNUNET_break (0);
+ break;
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ break;
+ }
+ }
+ break;
+ default:
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Refund `%s' failed with HTTP status %u: %s (#%u)\n",
+ re->order_id,
+ rr->hr.http_status,
+ rr->hr.hint,
+ (unsigned int) rr->hr.ec);
+ break;
+ }
+ GNUNET_CONTAINER_DLL_remove (re_head,
+ re_tail,
+ re);
+ GNUNET_free (re->order_id);
+ GNUNET_free (re);
+}
+
+
+/**
+ * Start to give a refund for the challenge created by @a gc.
+ *
+ * @param gc request where we failed and should now grant a refund for
+ */
+static void
+begin_refund (const struct ChallengeContext *gc)
+{
+ struct RefundEntry *re;
+
+ re = GNUNET_new (struct RefundEntry);
+ re->order_id = GNUNET_STRINGS_data_to_string_alloc (
+ &gc->payment_identifier,
+ sizeof (gc->payment_identifier));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Challenge execution failed, triggering refund for order `%s'\n",
+ re->order_id);
+ re->payment_identifier = gc->payment_identifier;
+ re->truth_uuid = gc->truth_uuid;
+ re->ro = TALER_MERCHANT_post_order_refund (AH_ctx,
+ AH_backend_url,
+ re->order_id,
+ &gc->challenge_cost,
+ "failed to issue challenge",
+ &refund_cb,
+ re);
+ if (NULL == re->ro)
+ {
+ GNUNET_break (0);
+ GNUNET_free (re->order_id);
+ GNUNET_free (re);
+ return;
+ }
+ GNUNET_CONTAINER_DLL_insert (re_head,
+ re_tail,
+ re);
+}
+
+
+/**
+ * Callback used to notify the application about completed requests.
+ * Cleans up the requests data structures.
+ *
+ * @param hc
+ */
+static void
+request_done (struct TM_HandlerContext *hc)
+{
+ struct ChallengeContext *gc = hc->ctx;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Request completed\n");
+ if (NULL == gc)
+ return;
+ hc->cc = NULL;
+ GNUNET_assert (! gc->suspended);
+ if (gc->in_list)
+ {
+ GNUNET_CONTAINER_DLL_remove (gc_head,
+ gc_tail,
+ gc);
+ gc->in_list = false;
+ }
+ if (NULL != gc->hn)
+ {
+ GNUNET_assert (gc ==
+ GNUNET_CONTAINER_heap_remove_node (gc->hn));
+ gc->hn = NULL;
+ }
+ if (NULL != gc->as)
+ {
+ gc->authorization->cleanup (gc->as);
+ gc->authorization = NULL;
+ gc->as = NULL;
+ }
+ if (NULL != gc->cpo)
+ {
+ TALER_MERCHANT_merchant_order_get_cancel (gc->cpo);
+ gc->cpo = NULL;
+ }
+ if (NULL != gc->po)
+ {
+ TALER_MERCHANT_orders_post_cancel (gc->po);
+ gc->po = NULL;
+ }
+ if (NULL != gc->root)
+ {
+ json_decref (gc->root);
+ gc->root = NULL;
+ }
+ TALER_MHD_parse_post_cleanup_callback (gc->opaque_post_parsing_context);
+ GNUNET_free (gc);
+ hc->ctx = NULL;
+}
+
+
+/**
+ * Transmit a payment request for @a order_id on @a connection
+ *
+ * @param gc context to make payment request for
+ */
+static void
+make_payment_request (struct ChallengeContext *gc)
+{
+ struct MHD_Response *resp;
+
+ resp = MHD_create_response_from_buffer (0,
+ NULL,
+ MHD_RESPMEM_PERSISTENT);
+ GNUNET_assert (NULL != resp);
+ TALER_MHD_add_global_headers (resp);
+ {
+ char *hdr;
+ char *order_id;
+ const char *pfx;
+ const char *hn;
+
+ if (0 == strncasecmp ("https://",
+ AH_backend_url,
+ strlen ("https://")))
+ {
+ pfx = "taler://";
+ hn = &AH_backend_url[strlen ("https://")];
+ }
+ else if (0 == strncasecmp ("http://",
+ AH_backend_url,
+ strlen ("http://")))
+ {
+ pfx = "taler+http://";
+ hn = &AH_backend_url[strlen ("http://")];
+ }
+ else
+ {
+ /* This invariant holds as per check in anastasis-httpd.c */
+ GNUNET_assert (0);
+ }
+ /* This invariant holds as per check in anastasis-httpd.c */
+ GNUNET_assert (0 != strlen (hn));
+
+ order_id = GNUNET_STRINGS_data_to_string_alloc (
+ &gc->payment_identifier,
+ sizeof (gc->payment_identifier));
+ GNUNET_asprintf (&hdr,
+ "%spay/%s%s/",
+ pfx,
+ hn,
+ order_id);
+ GNUNET_free (order_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Sending payment request `%s'\n",
+ hdr);
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (resp,
+ ANASTASIS_HTTP_HEADER_TALER,
+ hdr));
+ GNUNET_free (hdr);
+ }
+ gc->resp = resp;
+ gc->response_code = MHD_HTTP_PAYMENT_REQUIRED;
+}
+
+
+/**
+ * Callbacks of this type are used to serve the result of submitting a
+ * /contract request to a merchant.
+ *
+ * @param cls our `struct ChallengeContext`
+ * @param por response details
+ */
+static void
+proposal_cb (void *cls,
+ const struct TALER_MERCHANT_PostOrdersReply *por)
+{
+ struct ChallengeContext *gc = cls;
+ enum GNUNET_DB_QueryStatus qs;
+
+ gc->po = NULL;
+ GNUNET_assert (gc->in_list);
+ GNUNET_CONTAINER_DLL_remove (gc_head,
+ gc_tail,
+ gc);
+ gc->in_list = false;
+ GNUNET_assert (gc->suspended);
+ gc->suspended = false;
+ MHD_resume_connection (gc->connection);
+ AH_trigger_daemon (NULL);
+ if (MHD_HTTP_OK != por->hr.http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Backend returned status %u/%d\n",
+ por->hr.http_status,
+ (int) por->hr.ec);
+ GNUNET_break (0);
+ gc->resp = TALER_MHD_MAKE_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("code",
+ TALER_EC_ANASTASIS_TRUTH_PAYMENT_CREATE_BACKEND_ERROR),
+ GNUNET_JSON_pack_string ("hint",
+ "Failed to setup order with merchant backend"),
+ GNUNET_JSON_pack_uint64 ("backend-ec",
+ por->hr.ec),
+ GNUNET_JSON_pack_uint64 ("backend-http-status",
+ por->hr.http_status),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_steal ("backend-reply",
+ (json_t *) por->hr.reply)));
+ gc->response_code = MHD_HTTP_BAD_GATEWAY;
+ return;
+ }
+ qs = db->record_challenge_payment (db->cls,
+ &gc->truth_uuid,
+ &gc->payment_identifier,
+ &gc->challenge_cost);
+ if (0 >= qs)
+ {
+ GNUNET_break (0);
+ gc->resp = TALER_MHD_make_error (TALER_EC_GENERIC_DB_STORE_FAILED,
+ "record challenge payment");
+ gc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Setup fresh order, creating payment request\n");
+ make_payment_request (gc);
+}
+
+
+/**
+ * Callback to process a GET /check-payment request
+ *
+ * @param cls our `struct ChallengeContext`
+ * @param osr order status
+ */
+static void
+check_payment_cb (void *cls,
+ const struct TALER_MERCHANT_OrderStatusResponse *osr)
+
+{
+ struct ChallengeContext *gc = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr;
+
+ gc->cpo = NULL;
+ GNUNET_assert (gc->in_list);
+ GNUNET_CONTAINER_DLL_remove (gc_head,
+ gc_tail,
+ gc);
+ gc->in_list = false;
+ GNUNET_assert (gc->suspended);
+ gc->suspended = false;
+ MHD_resume_connection (gc->connection);
+ AH_trigger_daemon (NULL);
+
+ switch (hr->http_status)
+ {
+ case MHD_HTTP_OK:
+ GNUNET_assert (NULL != osr);
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ /* We created this order before, how can it be not found now? */
+ GNUNET_break (0);
+ gc->resp = TALER_MHD_make_error (TALER_EC_ANASTASIS_TRUTH_ORDER_DISAPPEARED,
+ NULL);
+ gc->response_code = MHD_HTTP_BAD_GATEWAY;
+ return;
+ case MHD_HTTP_BAD_GATEWAY:
+ gc->resp = TALER_MHD_make_error (
+ TALER_EC_ANASTASIS_TRUTH_BACKEND_EXCHANGE_BAD,
+ NULL);
+ gc->response_code = MHD_HTTP_BAD_GATEWAY;
+ return;
+ case MHD_HTTP_GATEWAY_TIMEOUT:
+ gc->resp = TALER_MHD_make_error (TALER_EC_ANASTASIS_GENERIC_BACKEND_TIMEOUT,
+ "Timeout check payment status");
+ GNUNET_assert (NULL != gc->resp);
+ gc->response_code = MHD_HTTP_GATEWAY_TIMEOUT;
+ return;
+ default:
+ {
+ char status[14];
+
+ GNUNET_snprintf (status,
+ sizeof (status),
+ "%u",
+ hr->http_status);
+ gc->resp = TALER_MHD_make_error (
+ TALER_EC_ANASTASIS_TRUTH_UNEXPECTED_PAYMENT_STATUS,
+ status);
+ GNUNET_assert (NULL != gc->resp);
+ gc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ return;
+ }
+ }
+
+ GNUNET_assert (MHD_HTTP_OK == hr->http_status);
+ switch (osr->details.ok.status)
+ {
+ case TALER_MERCHANT_OSC_PAID:
+ {
+ enum GNUNET_DB_QueryStatus qs;
+
+ qs = db->update_challenge_payment (db->cls,
+ &gc->truth_uuid,
+ &gc->payment_identifier);
+ if (0 <= qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Order has been paid, continuing with request processing\n");
+ return; /* continue as planned */
+ }
+ GNUNET_break (0);
+ gc->resp = TALER_MHD_make_error (TALER_EC_GENERIC_DB_STORE_FAILED,
+ "update challenge payment");
+ gc->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ return; /* continue as planned */
+ }
+ case TALER_MERCHANT_OSC_CLAIMED:
+ case TALER_MERCHANT_OSC_UNPAID:
+ /* repeat payment request */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Order remains unpaid, sending payment request again\n");
+ make_payment_request (gc);
+ return;
+ }
+ /* should never get here */
+ GNUNET_break (0);
+}
+
+
+/**
+ * Helper function used to ask our backend to begin processing a
+ * payment for the user's account. May perform asynchronous
+ * operations by suspending the connection if required.
+ *
+ * @param gc context to begin payment for.
+ * @return MHD status code
+ */
+static MHD_RESULT
+begin_payment (struct ChallengeContext *gc)
+{
+ enum GNUNET_DB_QueryStatus qs;
+ char *order_id;
+
+ qs = db->lookup_challenge_payment (db->cls,
+ &gc->truth_uuid,
+ &gc->payment_identifier);
+ if (qs < 0)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "lookup challenge payment");
+ }
+ GNUNET_assert (! gc->in_list);
+ gc->in_list = true;
+ GNUNET_CONTAINER_DLL_insert (gc_tail,
+ gc_head,
+ gc);
+ GNUNET_assert (! gc->suspended);
+ gc->suspended = true;
+ MHD_suspend_connection (gc->connection);
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ {
+ /* We already created the order, check if it was paid */
+ struct GNUNET_TIME_Relative timeout;
+
+ order_id = GNUNET_STRINGS_data_to_string_alloc (
+ &gc->payment_identifier,
+ sizeof (gc->payment_identifier));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Order exists, checking payment status for order `%s'\n",
+ order_id);
+ timeout = GNUNET_TIME_absolute_get_remaining (gc->timeout);
+ gc->cpo = TALER_MERCHANT_merchant_order_get (AH_ctx,
+ AH_backend_url,
+ order_id,
+ NULL /* NOT session-bound */,
+ timeout,
+ &check_payment_cb,
+ gc);
+ }
+ else
+ {
+ /* Create a fresh order */
+ static const char *no_uuids[1] = { NULL };
+ json_t *order;
+ struct GNUNET_TIME_Timestamp pay_deadline;
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
+ &gc->payment_identifier,
+ sizeof (struct ANASTASIS_PaymentSecretP));
+ order_id = GNUNET_STRINGS_data_to_string_alloc (
+ &gc->payment_identifier,
+ sizeof (gc->payment_identifier));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Creating fresh order `%s'\n",
+ order_id);
+ pay_deadline = GNUNET_TIME_relative_to_timestamp (
+ ANASTASIS_CHALLENGE_OFFER_LIFETIME);
+ order = GNUNET_JSON_PACK (
+ TALER_JSON_pack_amount ("amount",
+ &gc->challenge_cost),
+ GNUNET_JSON_pack_string ("summary",
+ "challenge fee for anastasis service"),
+ GNUNET_JSON_pack_string ("order_id",
+ order_id),
+ GNUNET_JSON_pack_time_rel ("auto_refund",
+ AUTO_REFUND_TIMEOUT),
+ GNUNET_JSON_pack_timestamp ("pay_deadline",
+ pay_deadline));
+ gc->po = TALER_MERCHANT_orders_post2 (AH_ctx,
+ AH_backend_url,
+ order,
+ AUTO_REFUND_TIMEOUT,
+ NULL, /* no payment target */
+ 0,
+ NULL, /* no inventory products */
+ 0,
+ no_uuids, /* no uuids */
+ false, /* do NOT require claim token */
+ &proposal_cb,
+ gc);
+ json_decref (order);
+ }
+ GNUNET_free (order_id);
+ AH_trigger_curl ();
+ return MHD_YES;
+}
+
+
+/**
+ * Mark @a gc as suspended and update the respective
+ * data structures and jobs.
+ *
+ * @param[in,out] gc context of the suspended operation
+ */
+static void
+gc_suspended (struct ChallengeContext *gc)
+{
+ gc->suspended = true;
+ if (NULL == AH_to_heap)
+ AH_to_heap = GNUNET_CONTAINER_heap_create (
+ GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ gc->hn = GNUNET_CONTAINER_heap_insert (AH_to_heap,
+ gc,
+ gc->timeout.abs_value_us);
+ if (NULL != to_task)
+ {
+ GNUNET_SCHEDULER_cancel (to_task);
+ to_task = NULL;
+ }
+ {
+ struct ChallengeContext *rn;
+
+ rn = GNUNET_CONTAINER_heap_peek (AH_to_heap);
+ to_task = GNUNET_SCHEDULER_add_at (rn->timeout,
+ &do_timeout,
+ NULL);
+ }
+}
+
+
+/**
+ * Run the authorization method-specific 'process' function and continue
+ * based on its result with generating an HTTP response.
+ *
+ * @param connection the connection we are handling
+ * @param gc our overall handler context
+ */
+static MHD_RESULT
+run_authorization_process (struct MHD_Connection *connection,
+ struct ChallengeContext *gc)
+{
+ enum ANASTASIS_AUTHORIZATION_ChallengeResult ret;
+ enum GNUNET_DB_QueryStatus qs;
+
+ GNUNET_assert (! gc->suspended);
+ if (NULL == gc->authorization->challenge)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ "challenge method not implemented for authorization method");
+ }
+ ret = gc->authorization->challenge (gc->as,
+ connection);
+ switch (ret)
+ {
+ case ANASTASIS_AUTHORIZATION_CRES_SUCCESS:
+ /* Challenge sent successfully */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Authorization request %llu for %s sent successfully\n",
+ (unsigned long long) gc->code,
+ TALER_B2S (&gc->truth_uuid));
+ qs = db->mark_challenge_sent (db->cls,
+ &gc->payment_identifier,
+ &gc->truth_uuid,
+ gc->code);
+ GNUNET_break (0 < qs);
+ gc->authorization->cleanup (gc->as);
+ gc->as = NULL;
+ return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_CRES_FAILED:
+ if (! gc->no_payment_identifier_provided)
+ {
+ begin_refund (gc);
+ }
+ gc->authorization->cleanup (gc->as);
+ gc->as = NULL;
+ return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_CRES_SUSPENDED:
+ /* connection was suspended */
+ gc_suspended (gc);
+ return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED:
+ /* Challenge sent successfully */
+ qs = db->mark_challenge_sent (db->cls,
+ &gc->payment_identifier,
+ &gc->truth_uuid,
+ gc->code);
+ GNUNET_break (0 < qs);
+ gc->authorization->cleanup (gc->as);
+ gc->as = NULL;
+ return MHD_NO;
+ case ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED:
+ gc->authorization->cleanup (gc->as);
+ gc->as = NULL;
+ return MHD_NO;
+ }
+ GNUNET_break (0);
+ return MHD_NO;
+}
+
+
+MHD_RESULT
+AH_handler_truth_challenge (
+ struct MHD_Connection *connection,
+ struct TM_HandlerContext *hc,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
+ const char *upload_data,
+ size_t *upload_data_size)
+{
+ struct ChallengeContext *gc = hc->ctx;
+ void *encrypted_truth;
+ size_t encrypted_truth_size;
+ void *decrypted_truth;
+ size_t decrypted_truth_size;
+ char *truth_mime = NULL;
+
+ if (NULL == gc)
+ {
+ /* Fresh request, do initial setup */
+ gc = GNUNET_new (struct ChallengeContext);
+ gc->hc = hc;
+ hc->ctx = gc;
+ gc->connection = connection;
+ gc->truth_uuid = *truth_uuid;
+ gc->hc->cc = &request_done;
+ gc->timeout = GNUNET_TIME_relative_to_absolute (
+ PAYMENT_TIMEOUT);
+ } /* end of first-time initialization (if NULL == gc) */
+ else
+ {
+ /* might have been woken up by authorization plugin,
+ so clear the flag. MDH called us, so we are
+ clearly no longer suspended */
+ gc->suspended = false;
+ if (NULL != gc->resp)
+ {
+ MHD_RESULT ret;
+
+ /* We generated a response asynchronously, queue that */
+ ret = MHD_queue_response (connection,
+ gc->response_code,
+ gc->resp);
+ GNUNET_break (MHD_YES == ret);
+ MHD_destroy_response (gc->resp);
+ gc->resp = NULL;
+ return ret;
+ }
+ if (NULL != gc->as)
+ {
+ /* Authorization process is "running", check what is going on */
+ GNUNET_assert (NULL != gc->authorization);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Continuing with running the authorization process\n");
+ GNUNET_assert (! gc->suspended);
+ return run_authorization_process (connection,
+ gc);
+
+ }
+ /* We get here if the async check for payment said this request
+ was indeed paid! */
+ }
+
+ /* parse byte stream upload into JSON */
+ if (NULL == gc->root)
+ {
+ enum GNUNET_GenericReturnValue res;
+
+ res = TALER_MHD_parse_post_json (connection,
+ &gc->opaque_post_parsing_context,
+ upload_data,
+ upload_data_size,
+ &gc->root);
+ if (GNUNET_SYSERR == res)
+ {
+ GNUNET_assert (NULL == gc->root);
+ return MHD_NO; /* bad upload, could not even generate error */
+ }
+ if ( (GNUNET_NO == res) ||
+ (NULL == gc->root) )
+ {
+ GNUNET_assert (NULL == gc->root);
+ return MHD_YES; /* so far incomplete upload or parser error */
+ }
+
+ /* 'root' is now initialized */
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("truth_decryption_key",
+ &gc->truth_key),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("payment_secret",
+ &gc->payment_identifier),
+ &gc->no_payment_identifier_provided),
+ GNUNET_JSON_spec_end ()
+ };
+ enum GNUNET_GenericReturnValue res;
+
+ res = TALER_MHD_parse_json_data (connection,
+ gc->root,
+ spec);
+ if (GNUNET_SYSERR == res)
+ {
+ GNUNET_break (0);
+ return MHD_NO; /* hard failure */
+ }
+ if (GNUNET_NO == res)
+ {
+ GNUNET_break_op (0);
+ return MHD_YES; /* failure */
+ }
+ if (! gc->no_payment_identifier_provided)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Client provided payment identifier `%s'\n",
+ TALER_B2S (&gc->payment_identifier));
+ }
+ }
+
+ {
+ /* load encrypted truth from DB */
+ enum GNUNET_DB_QueryStatus qs;
+ char *method;
+
+ qs = db->get_escrow_challenge (db->cls,
+ &gc->truth_uuid,
+ &encrypted_truth,
+ &encrypted_truth_size,
+ &truth_mime,
+ &method);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "get escrow challenge");
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_ANASTASIS_TRUTH_UNKNOWN,
+ NULL);
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ break;
+ }
+ if (0 == strcmp ("question",
+ method))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (encrypted_truth);
+ GNUNET_free (truth_mime);
+ GNUNET_free (method);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_ANASTASIS_TRUTH_CHALLENGE_WRONG_METHOD,
+ "question");
+ }
+
+ gc->authorization
+ = ANASTASIS_authorization_plugin_load (method,
+ db,
+ AH_cfg);
+ if (NULL == gc->authorization)
+ {
+ MHD_RESULT ret;
+
+ ret = TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_METHOD_NO_LONGER_SUPPORTED,
+ method);
+ GNUNET_free (encrypted_truth);
+ GNUNET_free (truth_mime);
+ GNUNET_free (method);
+ return ret;
+ }
+
+ if (gc->authorization->user_provided_code)
+ {
+ MHD_RESULT ret;
+
+ GNUNET_break_op (0);
+ ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_ANASTASIS_TRUTH_CHALLENGE_WRONG_METHOD,
+ method);
+ GNUNET_free (encrypted_truth);
+ GNUNET_free (truth_mime);
+ GNUNET_free (method);
+ return ret;
+ }
+
+ gc->challenge_cost = gc->authorization->cost;
+ GNUNET_free (method);
+ }
+
+ if (! gc->authorization->payment_plugin_managed)
+ {
+ if (! TALER_amount_is_zero (&gc->challenge_cost))
+ {
+ /* Check database to see if the transaction is paid for */
+ enum GNUNET_DB_QueryStatus qs;
+ bool paid;
+
+ if (gc->no_payment_identifier_provided)
+ {
+ GNUNET_free (truth_mime);
+ GNUNET_free (encrypted_truth);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Beginning payment, client did not provide payment identifier\n");
+ return begin_payment (gc);
+ }
+ qs = db->check_challenge_payment (db->cls,
+ &gc->payment_identifier,
+ &gc->truth_uuid,
+ &paid);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ GNUNET_free (truth_mime);
+ GNUNET_free (encrypted_truth);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "check challenge payment");
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ /* Create fresh payment identifier (cannot trust client) */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Client-provided payment identifier is unknown.\n");
+ GNUNET_free (truth_mime);
+ GNUNET_free (encrypted_truth);
+ return begin_payment (gc);
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ if (! paid)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Payment identifier known. Checking payment with client's payment identifier\n");
+ GNUNET_free (truth_mime);
+ GNUNET_free (encrypted_truth);
+ return begin_payment (gc);
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Payment confirmed\n");
+ break;
+ }
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Request is free of charge\n");
+ }
+ }
+
+ /* We've been paid, now validate response */
+ {
+ /* decrypt encrypted_truth */
+ ANASTASIS_CRYPTO_truth_decrypt (&gc->truth_key,
+ encrypted_truth,
+ encrypted_truth_size,
+ &decrypted_truth,
+ &decrypted_truth_size);
+ GNUNET_free (encrypted_truth);
+ }
+ if (NULL == decrypted_truth)
+ {
+ GNUNET_free (truth_mime);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_ANASTASIS_TRUTH_DECRYPTION_FAILED,
+ NULL);
+ }
+
+ /* Not security question and no answer: use plugin to check if
+ decrypted truth is a valid challenge! */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "No challenge provided, creating fresh challenge\n");
+ {
+ enum GNUNET_GenericReturnValue ret;
+
+ ret = gc->authorization->validate (gc->authorization->cls,
+ connection,
+ truth_mime,
+ decrypted_truth,
+ decrypted_truth_size);
+ GNUNET_free (truth_mime);
+ switch (ret)
+ {
+ case GNUNET_OK:
+ /* data valid, continued below */
+ break;
+ case GNUNET_NO:
+ /* data invalid, reply was queued */
+ GNUNET_free (decrypted_truth);
+ return MHD_YES;
+ case GNUNET_SYSERR:
+ /* data invalid, reply was NOT queued */
+ GNUNET_free (decrypted_truth);
+ return MHD_NO;
+ }
+ }
+
+ /* Setup challenge and begin authorization process */
+ {
+ struct GNUNET_TIME_Timestamp transmission_date;
+ enum GNUNET_DB_QueryStatus qs;
+
+ qs = db->create_challenge_code (db->cls,
+ &gc->truth_uuid,
+ gc->authorization->code_rotation_period,
+ gc->authorization->code_validity_period,
+ gc->authorization->retry_counter,
+ &transmission_date,
+ &gc->code);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ GNUNET_free (decrypted_truth);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "create_challenge_code");
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ /* 0 == retry_counter of existing challenge => rate limit exceeded */
+ GNUNET_free (decrypted_truth);
+ return reply_rate_limited (gc);
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* challenge code was stored successfully*/
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Created fresh challenge\n");
+ break;
+ }
+
+ if (GNUNET_TIME_relative_cmp (
+ GNUNET_TIME_absolute_get_duration (
+ transmission_date.abs_time),
+ <,
+ gc->authorization->code_retransmission_frequency) )
+ {
+ /* Too early for a retransmission! */
+ GNUNET_free (decrypted_truth);
+ return TALER_MHD_REPLY_JSON_PACK (
+ gc->connection,
+ MHD_HTTP_OK,
+ GNUNET_JSON_pack_string ("challenge_type",
+ "TAN_ALREADY_SENT"));
+ }
+ }
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Beginning authorization process\n");
+ gc->as = gc->authorization->start (gc->authorization->cls,
+ &AH_trigger_daemon,
+ NULL,
+ &gc->truth_uuid,
+ gc->code,
+ decrypted_truth,
+ decrypted_truth_size);
+ GNUNET_free (decrypted_truth);
+ if (NULL == gc->as)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ NULL);
+ }
+ if (! gc->in_list)
+ {
+ gc->in_list = true;
+ GNUNET_CONTAINER_DLL_insert (gc_head,
+ gc_tail,
+ gc);
+ }
+ GNUNET_assert (! gc->suspended);
+ return run_authorization_process (connection,
+ gc);
+}
diff --git a/src/backend/anastasis-httpd_truth.c b/src/backend/anastasis-httpd_truth-solve.c
index aedd0a2..eb09dc7 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth-solve.c
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2019, 2021 Anastasis SARL
+ Copyright (C) 2019-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -14,8 +14,8 @@
Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file anastasis-httpd_truth.c
- * @brief functions to handle incoming requests on /truth
+ * @file anastasis-httpd_truth-solve.c
+ * @brief functions to handle incoming requests on /truth/$TID/solve
* @author Dennis Neufeld
* @author Dominik Meister
* @author Christian Grothoff
@@ -29,6 +29,7 @@
#include "anastasis_authorization_lib.h"
#include <taler/taler_merchant_service.h>
#include <taler/taler_json_lib.h>
+#include <taler/taler_mhd_lib.h>
/**
* What is the maximum frequency at which we allow
@@ -38,13 +39,6 @@
GNUNET_TIME_UNIT_SECONDS, 30)
/**
- * How long do we hold an HTTP client connection if
- * we are awaiting payment before giving up?
- */
-#define CHECK_PAYMENT_GENERIC_TIMEOUT GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MINUTES, 30)
-
-/**
* How long should the wallet check for auto-refunds before giving up?
*/
#define AUTO_REFUND_TIMEOUT GNUNET_TIME_relative_multiply ( \
@@ -57,7 +51,7 @@
#define INITIAL_RETRY_COUNTER 3
-struct GetContext
+struct SolveContext
{
/**
@@ -86,14 +80,24 @@ struct GetContext
struct TM_HandlerContext *hc;
/**
+ * Opaque parsing context.
+ */
+ void *opaque_post_parsing_context;
+
+ /**
+ * Uploaded JSON data, NULL if upload is not yet complete.
+ */
+ json_t *root;
+
+ /**
* Kept in DLL for shutdown handling while suspended.
*/
- struct GetContext *next;
+ struct SolveContext *next;
/**
* Kept in DLL for shutdown handling while suspended.
*/
- struct GetContext *prev;
+ struct SolveContext *prev;
/**
* Connection handle for closing or resuming
@@ -152,9 +156,9 @@ struct GetContext
unsigned int response_code;
/**
- * true if client provided a payment secret / order ID?
+ * true if client did not provide a payment secret / order ID.
*/
- bool payment_identifier_provided;
+ bool no_payment_identifier_provided;
/**
* True if this entry is in the #gc_head DLL.
@@ -166,69 +170,18 @@ struct GetContext
*/
bool suspended;
- /**
- * Did the request include a response?
- */
- bool have_response;
-
-};
-
-/**
- * Information we track for refunds.
- */
-struct RefundEntry
-{
- /**
- * Kept in a DLL.
- */
- struct RefundEntry *next;
-
- /**
- * Kept in a DLL.
- */
- struct RefundEntry *prev;
-
- /**
- * Operation handle.
- */
- struct TALER_MERCHANT_OrderRefundHandle *ro;
-
- /**
- * Which order is being refunded.
- */
- char *order_id;
-
- /**
- * Payment Identifier
- */
- struct ANASTASIS_PaymentSecretP payment_identifier;
-
- /**
- * Public key of the challenge which is solved.
- */
- struct ANASTASIS_CRYPTO_TruthUUIDP truth_uuid;
};
/**
- * Head of linked list of active refund operations.
- */
-static struct RefundEntry *re_head;
-
-/**
- * Tail of linked list of active refund operations.
- */
-static struct RefundEntry *re_tail;
-
-/**
* Head of linked list over all authorization processes
*/
-static struct GetContext *gc_head;
+static struct SolveContext *gc_head;
/**
* Tail of linked list over all authorization processes
*/
-static struct GetContext *gc_tail;
+static struct SolveContext *gc_tail;
/**
* Task running #do_timeout().
@@ -237,6 +190,37 @@ static struct GNUNET_SCHEDULER_Task *to_task;
/**
+ * Generate a response telling the client that answering this
+ * challenge failed because the rate limit has been exceeded.
+ *
+ * @param gc request to answer for
+ * @return MHD status code
+ */
+static MHD_RESULT
+reply_rate_limited (const struct SolveContext *gc)
+{
+ if (NULL != gc->authorization)
+ return TALER_MHD_REPLY_JSON_PACK (
+ gc->connection,
+ MHD_HTTP_TOO_MANY_REQUESTS,
+ TALER_MHD_PACK_EC (TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED),
+ GNUNET_JSON_pack_uint64 ("request_limit",
+ gc->authorization->retry_counter),
+ GNUNET_JSON_pack_time_rel ("request_frequency",
+ gc->authorization->code_rotation_period));
+ /* must be security question */
+ return TALER_MHD_REPLY_JSON_PACK (
+ gc->connection,
+ MHD_HTTP_TOO_MANY_REQUESTS,
+ TALER_MHD_PACK_EC (TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED),
+ GNUNET_JSON_pack_uint64 ("request_limit",
+ INITIAL_RETRY_COUNTER),
+ GNUNET_JSON_pack_time_rel ("request_frequency",
+ MAX_QUESTION_FREQ));
+}
+
+
+/**
* Timeout requests that are past their due date.
*
* @param cls NULL
@@ -244,7 +228,7 @@ static struct GNUNET_SCHEDULER_Task *to_task;
static void
do_timeout (void *cls)
{
- struct GetContext *gc;
+ struct SolveContext *gc;
(void) cls;
to_task = NULL;
@@ -276,27 +260,9 @@ do_timeout (void *cls)
void
-AH_truth_shutdown (void)
+AH_truth_solve_shutdown (void)
{
- struct GetContext *gc;
- struct RefundEntry *re;
-
- while (NULL != (re = re_head))
- {
- GNUNET_CONTAINER_DLL_remove (re_head,
- re_tail,
- re);
- if (NULL != re->ro)
- {
- TALER_MERCHANT_post_order_refund_cancel (re->ro);
- re->ro = NULL;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Refund `%s' failed due to shutdown\n",
- re->order_id);
- GNUNET_free (re->order_id);
- GNUNET_free (re);
- }
+ struct SolveContext *gc;
while (NULL != (gc = gc_head))
{
@@ -336,118 +302,15 @@ AH_truth_shutdown (void)
/**
- * Callback to process a POST /orders/ID/refund request
- *
- * @param cls closure with a `struct RefundEntry *`
- * @param hr HTTP response details
- * @param taler_refund_uri the refund uri offered to the wallet
- * @param h_contract hash of the contract a Browser may need to authorize
- * obtaining the HTTP response.
- */
-static void
-refund_cb (
- void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const char *taler_refund_uri,
- const struct GNUNET_HashCode *h_contract)
-{
- struct RefundEntry *re = cls;
-
- re->ro = NULL;
- switch (hr->http_status)
- {
- case MHD_HTTP_OK:
- {
- enum GNUNET_DB_QueryStatus qs;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Refund `%s' succeeded\n",
- re->order_id);
- qs = db->record_challenge_refund (db->cls,
- &re->truth_uuid,
- &re->payment_identifier);
- switch (qs)
- {
- case GNUNET_DB_STATUS_HARD_ERROR:
- GNUNET_break (0);
- break;
- case GNUNET_DB_STATUS_SOFT_ERROR:
- GNUNET_break (0);
- break;
- case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- GNUNET_break (0);
- break;
- case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- break;
- }
- }
- break;
- default:
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Refund `%s' failed with HTTP status %u: %s (#%u)\n",
- re->order_id,
- hr->http_status,
- hr->hint,
- (unsigned int) hr->ec);
- break;
- }
- GNUNET_CONTAINER_DLL_remove (re_head,
- re_tail,
- re);
- GNUNET_free (re->order_id);
- GNUNET_free (re);
-}
-
-
-/**
- * Start to give a refund for the challenge created by @a gc.
- *
- * @param gc request where we failed and should now grant a refund for
- */
-static void
-begin_refund (const struct GetContext *gc)
-{
- struct RefundEntry *re;
-
- re = GNUNET_new (struct RefundEntry);
- re->order_id = GNUNET_STRINGS_data_to_string_alloc (
- &gc->payment_identifier,
- sizeof (gc->payment_identifier));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Challenge execution failed, triggering refund for order `%s'\n",
- re->order_id);
- re->payment_identifier = gc->payment_identifier;
- re->truth_uuid = gc->truth_uuid;
- re->ro = TALER_MERCHANT_post_order_refund (AH_ctx,
- AH_backend_url,
- re->order_id,
- &gc->challenge_cost,
- "failed to issue challenge",
- &refund_cb,
- re);
- if (NULL == re->ro)
- {
- GNUNET_break (0);
- GNUNET_free (re->order_id);
- GNUNET_free (re);
- return;
- }
- GNUNET_CONTAINER_DLL_insert (re_head,
- re_tail,
- re);
-}
-
-
-/**
* Callback used to notify the application about completed requests.
* Cleans up the requests data structures.
*
- * @param hc
+ * @param[in,out] hc
*/
static void
request_done (struct TM_HandlerContext *hc)
{
- struct GetContext *gc = hc->ctx;
+ struct SolveContext *gc = hc->ctx;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Request completed\n");
@@ -484,6 +347,12 @@ request_done (struct TM_HandlerContext *hc)
TALER_MERCHANT_orders_post_cancel (gc->po);
gc->po = NULL;
}
+ if (NULL != gc->root)
+ {
+ json_decref (gc->root);
+ gc->root = NULL;
+ }
+ TALER_MHD_parse_post_cleanup_callback (gc->opaque_post_parsing_context);
GNUNET_free (gc);
hc->ctx = NULL;
}
@@ -495,7 +364,7 @@ request_done (struct TM_HandlerContext *hc)
* @param gc context to make payment request for
*/
static void
-make_payment_request (struct GetContext *gc)
+make_payment_request (struct SolveContext *gc)
{
struct MHD_Response *resp;
@@ -559,14 +428,14 @@ make_payment_request (struct GetContext *gc)
* Callbacks of this type are used to serve the result of submitting a
* /contract request to a merchant.
*
- * @param cls our `struct GetContext`
+ * @param cls our `struct SolveContext`
* @param por response details
*/
static void
proposal_cb (void *cls,
const struct TALER_MERCHANT_PostOrdersReply *por)
{
- struct GetContext *gc = cls;
+ struct SolveContext *gc = cls;
enum GNUNET_DB_QueryStatus qs;
gc->po = NULL;
@@ -622,17 +491,16 @@ proposal_cb (void *cls,
/**
* Callback to process a GET /check-payment request
*
- * @param cls our `struct GetContext`
- * @param hr HTTP response details
+ * @param cls our `struct SolveContext`
* @param osr order status
*/
static void
check_payment_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_OrderStatusResponse *osr)
{
- struct GetContext *gc = cls;
+ struct SolveContext *gc = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr;
gc->cpo = NULL;
GNUNET_assert (gc->in_list);
@@ -686,7 +554,8 @@ check_payment_cb (void *cls,
}
}
- switch (osr->status)
+ GNUNET_assert (MHD_HTTP_OK == hr->http_status);
+ switch (osr->details.ok.status)
{
case TALER_MERCHANT_OSC_PAID:
{
@@ -729,7 +598,7 @@ check_payment_cb (void *cls,
* @return MHD status code
*/
static MHD_RESULT
-begin_payment (struct GetContext *gc)
+begin_payment (struct SolveContext *gc)
{
enum GNUNET_DB_QueryStatus qs;
char *order_id;
@@ -769,7 +638,6 @@ begin_payment (struct GetContext *gc)
AH_backend_url,
order_id,
NULL /* NOT session-bound */,
- false,
timeout,
&check_payment_cb,
gc);
@@ -777,8 +645,9 @@ begin_payment (struct GetContext *gc)
else
{
/* Create a fresh order */
+ static const char *no_uuids[1] = { NULL };
json_t *order;
- struct GNUNET_TIME_Absolute pay_deadline;
+ struct GNUNET_TIME_Timestamp pay_deadline;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
&gc->payment_identifier,
@@ -789,9 +658,8 @@ begin_payment (struct GetContext *gc)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Creating fresh order `%s'\n",
order_id);
- pay_deadline = GNUNET_TIME_relative_to_absolute (
+ pay_deadline = GNUNET_TIME_relative_to_timestamp (
ANASTASIS_CHALLENGE_OFFER_LIFETIME);
- GNUNET_TIME_round_abs (&pay_deadline);
order = GNUNET_JSON_PACK (
TALER_JSON_pack_amount ("amount",
&gc->challenge_cost),
@@ -801,8 +669,8 @@ begin_payment (struct GetContext *gc)
order_id),
GNUNET_JSON_pack_time_rel ("auto_refund",
AUTO_REFUND_TIMEOUT),
- GNUNET_JSON_pack_time_abs ("pay_deadline",
- pay_deadline));
+ GNUNET_JSON_pack_timestamp ("pay_deadline",
+ pay_deadline));
gc->po = TALER_MERCHANT_orders_post2 (AH_ctx,
AH_backend_url,
order,
@@ -811,7 +679,7 @@ begin_payment (struct GetContext *gc)
0,
NULL, /* no inventory products */
0,
- NULL, /* no uuids */
+ no_uuids, /* no uuids */
false, /* do NOT require claim token */
&proposal_cb,
gc);
@@ -837,6 +705,9 @@ return_key_share (
{
struct ANASTASIS_CRYPTO_EncryptedKeyShareP encrypted_keyshare;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Returning key share of %s\n",
+ TALER_B2S (truth_uuid));
{
enum GNUNET_DB_QueryStatus qs;
@@ -853,6 +724,12 @@ return_key_share (
TALER_EC_GENERIC_DB_FETCH_FAILED,
"get key share");
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ /* this should be "impossible", after all the
+ client was able to solve the challenge!
+ (Exception: we deleted the truth via GC
+ just while the client was trying to recover.
+ Alas, highly unlikely...) */
+ GNUNET_break (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_ANASTASIS_TRUTH_KEY_SHARE_GONE,
@@ -862,8 +739,6 @@ return_key_share (
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Returning key share\n");
{
struct MHD_Response *resp;
MHD_RESULT ret;
@@ -888,8 +763,10 @@ return_key_share (
* @param[in,out] gc context of the suspended operation
*/
static void
-gc_suspended (struct GetContext *gc)
+gc_suspended (struct SolveContext *gc)
{
+ GNUNET_assert (NULL == gc->hn);
+ GNUNET_assert (! gc->suspended);
gc->suspended = true;
if (NULL == AH_to_heap)
AH_to_heap = GNUNET_CONTAINER_heap_create (
@@ -903,7 +780,7 @@ gc_suspended (struct GetContext *gc)
to_task = NULL;
}
{
- struct GetContext *rn;
+ struct SolveContext *rn;
rn = GNUNET_CONTAINER_heap_peek (AH_to_heap);
to_task = GNUNET_SCHEDULER_add_at (rn->timeout,
@@ -922,56 +799,38 @@ gc_suspended (struct GetContext *gc)
*/
static MHD_RESULT
run_authorization_process (struct MHD_Connection *connection,
- struct GetContext *gc)
+ struct SolveContext *gc)
{
- enum ANASTASIS_AUTHORIZATION_Result ret;
- enum GNUNET_DB_QueryStatus qs;
+ enum ANASTASIS_AUTHORIZATION_SolveResult ret;
GNUNET_assert (! gc->suspended);
- ret = gc->authorization->process (gc->as,
- gc->timeout,
- connection);
+ if (NULL == gc->authorization->solve)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ "solve method not implemented for authorization method");
+ }
+ ret = gc->authorization->solve (gc->as,
+ gc->timeout,
+ &gc->challenge_response,
+ connection);
switch (ret)
{
- case ANASTASIS_AUTHORIZATION_RES_SUCCESS:
- /* Challenge sent successfully */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Authorization request sent successfully\n");
- qs = db->mark_challenge_sent (db->cls,
- &gc->payment_identifier,
- &gc->truth_uuid,
- gc->code);
- GNUNET_break (0 < qs);
- gc->authorization->cleanup (gc->as);
- gc->as = NULL;
- return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_FAILED:
- if (gc->payment_identifier_provided)
- {
- begin_refund (gc);
- }
- gc->authorization->cleanup (gc->as);
- gc->as = NULL;
- return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
+ case ANASTASIS_AUTHORIZATION_SRES_SUSPENDED:
/* connection was suspended */
gc_suspended (gc);
return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED:
- /* Challenge sent successfully */
- qs = db->mark_challenge_sent (db->cls,
- &gc->payment_identifier,
- &gc->truth_uuid,
- gc->code);
- GNUNET_break (0 < qs);
+ case ANASTASIS_AUTHORIZATION_SRES_FAILED:
gc->authorization->cleanup (gc->as);
gc->as = NULL;
- return MHD_NO;
- case ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED:
+ return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED:
gc->authorization->cleanup (gc->as);
gc->as = NULL;
return MHD_NO;
- case ANASTASIS_AUTHORIZATION_RES_FINISHED:
+ case ANASTASIS_AUTHORIZATION_SRES_FINISHED:
GNUNET_assert (! gc->suspended);
gc->authorization->cleanup (gc->as);
gc->as = NULL;
@@ -992,9 +851,8 @@ run_authorization_process (struct MHD_Connection *connection,
/**
- * Use the database to rate-limit queries to the
- * authentication procedure, but without actually
- * storing 'real' challenge codes.
+ * Use the database to rate-limit queries to the authentication
+ * procedure, but without actually storing 'real' challenge codes.
*
* @param[in,out] gc context to rate limit requests for
* @return #GNUNET_OK if rate-limiting passes,
@@ -1003,17 +861,17 @@ run_authorization_process (struct MHD_Connection *connection,
* was queued
*/
static enum GNUNET_GenericReturnValue
-rate_limit (struct GetContext *gc)
+rate_limit (struct SolveContext *gc)
{
enum GNUNET_DB_QueryStatus qs;
- struct GNUNET_TIME_Absolute rt;
+ struct GNUNET_TIME_Timestamp rt;
uint64_t code;
enum ANASTASIS_DB_CodeStatus cs;
struct GNUNET_HashCode hc;
bool satisfied;
uint64_t dummy;
- rt = GNUNET_TIME_UNIT_FOREVER_ABS;
+ rt = GNUNET_TIME_UNIT_FOREVER_TS;
qs = db->create_challenge_code (db->cls,
&gc->truth_uuid,
MAX_QUESTION_FREQ,
@@ -1029,19 +887,18 @@ rate_limit (struct GetContext *gc)
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
"create_challenge_code (for rate limiting)"))
- ? GNUNET_NO
- : GNUNET_SYSERR;
+ ? GNUNET_NO
+ : GNUNET_SYSERR;
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
return (MHD_YES ==
- TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_TOO_MANY_REQUESTS,
- TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED,
- NULL))
- ? GNUNET_NO
- : GNUNET_SYSERR;
+ reply_rate_limited (gc))
+ ? GNUNET_NO
+ : GNUNET_SYSERR;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Using intentionally wrong answer to produce rate-limiting\n");
/* decrement trial counter */
ANASTASIS_hash_answer (code + 1, /* always use wrong answer */
&hc);
@@ -1063,16 +920,13 @@ rate_limit (struct GetContext *gc)
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_FETCH_FAILED,
"verify_challenge_code"))
- ? GNUNET_NO
- : GNUNET_SYSERR;
+ ? GNUNET_NO
+ : GNUNET_SYSERR;
case ANASTASIS_DB_CODE_STATUS_NO_RESULTS:
return (MHD_YES ==
- TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_TOO_MANY_REQUESTS,
- TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED,
- NULL))
- ? GNUNET_NO
- : GNUNET_SYSERR;
+ reply_rate_limited (gc))
+ ? GNUNET_NO
+ : GNUNET_SYSERR;
case ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED:
/* this should be impossible, we used code+1 */
GNUNET_assert (0);
@@ -1091,19 +945,12 @@ rate_limit (struct GetContext *gc)
* @return MHD status code
*/
static MHD_RESULT
-handle_security_question (struct GetContext *gc,
+handle_security_question (struct SolveContext *gc,
const void *decrypted_truth,
size_t decrypted_truth_size)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Handling security question challenge\n");
- if (! gc->have_response)
- {
- return TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_FORBIDDEN,
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_RESPONSE_REQUIRED,
- NULL);
- }
/* rate limit */
{
enum GNUNET_GenericReturnValue ret;
@@ -1135,8 +982,8 @@ handle_security_question (struct GetContext *gc,
/**
* Handle special case of an answer being directly checked by the
- * plugin and not by our database. Rate limits answers against brute
- * forcing.
+ * plugin and not by our database. Also ensures that the
+ * request is rate-limited.
*
* @param[in,out] gc request to handle
* @param decrypted_truth hash to check against
@@ -1144,17 +991,17 @@ handle_security_question (struct GetContext *gc,
* @return MHD status code
*/
static MHD_RESULT
-direct_validation (struct GetContext *gc,
+direct_validation (struct SolveContext *gc,
const void *decrypted_truth,
size_t decrypted_truth_size)
{
/* Non-random code, call plugin directly! */
- enum ANASTASIS_AUTHORIZATION_Result aar;
- enum GNUNET_GenericReturnValue res;
+ enum ANASTASIS_AUTHORIZATION_SolveResult aar;
+ enum GNUNET_GenericReturnValue ret;
- res = rate_limit (gc);
- if (GNUNET_OK != res)
- return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
+ ret = rate_limit (gc);
+ if (GNUNET_OK != ret)
+ return (GNUNET_NO == ret) ? MHD_YES : MHD_NO;
gc->as = gc->authorization->start (gc->authorization->cls,
&AH_trigger_daemon,
NULL,
@@ -1170,25 +1017,96 @@ direct_validation (struct GetContext *gc,
TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
NULL);
}
- aar = gc->authorization->process (gc->as,
- GNUNET_TIME_UNIT_ZERO_ABS,
- gc->connection);
- switch (aar)
+ if (NULL == gc->authorization->solve)
{
- case ANASTASIS_AUTHORIZATION_RES_SUCCESS:
GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ "solve method not implemented for authorization method");
+ }
+ aar = gc->authorization->solve (gc->as,
+ gc->timeout,
+ &gc->challenge_response,
+ gc->connection);
+ switch (aar)
+ {
+ case ANASTASIS_AUTHORIZATION_SRES_FAILED:
return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_FAILED:
- return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
+ case ANASTASIS_AUTHORIZATION_SRES_SUSPENDED:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Suspending request handling\n");
gc_suspended (gc);
return MHD_YES;
- case ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED:
- GNUNET_break (0);
+ case ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED:
return MHD_NO;
- case ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED:
+ case ANASTASIS_AUTHORIZATION_SRES_FINISHED:
+ return return_key_share (&gc->truth_uuid,
+ gc->connection);
+ }
+ GNUNET_break (0);
+ return MHD_NO;
+}
+
+
+/**
+ * Handle special case of an answer being checked
+ * by the plugin asynchronously (IBAN) after we inverted
+ * the hash using the database.
+ *
+ * @param[in,out] gc request to handle
+ * @param code validation code provided by the client
+ * @param decrypted_truth hash to check against
+ * @param decrypted_truth_size number of bytes in @a decrypted_truth
+ * @return MHD status code
+ */
+static MHD_RESULT
+iban_validation (struct SolveContext *gc,
+ uint64_t code,
+ const void *decrypted_truth,
+ size_t decrypted_truth_size)
+{
+ enum ANASTASIS_AUTHORIZATION_SolveResult aar;
+
+ gc->as = gc->authorization->start (gc->authorization->cls,
+ &AH_trigger_daemon,
+ NULL,
+ &gc->truth_uuid,
+ code,
+ decrypted_truth,
+ decrypted_truth_size);
+ if (NULL == gc->as)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ NULL);
+ }
+ if (NULL == gc->authorization->solve)
+ {
+ GNUNET_break (0);
+ return TALER_MHD_reply_with_error (gc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
+ "solve method not implemented for authorization method");
+ }
+ aar = gc->authorization->solve (gc->as,
+ gc->timeout,
+ &gc->challenge_response,
+ gc->connection);
+ switch (aar)
+ {
+ case ANASTASIS_AUTHORIZATION_SRES_FAILED:
+ return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_SRES_SUSPENDED:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Suspending request handling\n");
+ gc_suspended (gc);
+ return MHD_YES;
+ case ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED:
return MHD_NO;
- case ANASTASIS_AUTHORIZATION_RES_FINISHED:
+ case ANASTASIS_AUTHORIZATION_SRES_FINISHED:
return return_key_share (&gc->truth_uuid,
gc->connection);
}
@@ -1198,12 +1116,14 @@ direct_validation (struct GetContext *gc,
MHD_RESULT
-AH_handler_truth_get (
+AH_handler_truth_solve (
struct MHD_Connection *connection,
+ struct TM_HandlerContext *hc,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
- struct TM_HandlerContext *hc)
+ const char *upload_data,
+ size_t *upload_data_size)
{
- struct GetContext *gc = hc->ctx;
+ struct SolveContext *gc = hc->ctx;
void *encrypted_truth;
size_t encrypted_truth_size;
void *decrypted_truth;
@@ -1214,124 +1134,16 @@ AH_handler_truth_get (
if (NULL == gc)
{
/* Fresh request, do initial setup */
- gc = GNUNET_new (struct GetContext);
+ gc = GNUNET_new (struct SolveContext);
gc->hc = hc;
hc->ctx = gc;
gc->connection = connection;
gc->truth_uuid = *truth_uuid;
gc->hc->cc = &request_done;
- {
- const char *pay_id;
-
- pay_id = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER);
- if (NULL != pay_id)
- {
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (
- pay_id,
- strlen (pay_id),
- &gc->payment_identifier,
- sizeof (struct ANASTASIS_PaymentSecretP)))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER);
- }
- gc->payment_identifier_provided = true;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Client provided payment identifier `%s'\n",
- pay_id);
- }
- }
-
- {
- /* check if header contains Truth-Decryption-Key */
- const char *tdk;
-
- tdk = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- ANASTASIS_HTTP_HEADER_TRUTH_DECRYPTION_KEY);
- if (NULL == tdk)
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MISSING,
- ANASTASIS_HTTP_HEADER_TRUTH_DECRYPTION_KEY);
- }
-
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (
- tdk,
- strlen (tdk),
- &gc->truth_key,
- sizeof (struct ANASTASIS_CRYPTO_TruthKeyP)))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- ANASTASIS_HTTP_HEADER_TRUTH_DECRYPTION_KEY);
- }
- }
-
- {
- const char *challenge_response_s;
-
- challenge_response_s = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "response");
- if ( (NULL != challenge_response_s) &&
- (GNUNET_OK !=
- GNUNET_CRYPTO_hash_from_string (challenge_response_s,
- &gc->challenge_response)) )
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "response");
- }
- gc->have_response = (NULL != challenge_response_s);
- }
-
- {
- const char *long_poll_timeout_ms;
-
- long_poll_timeout_ms = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "timeout_ms");
- if (NULL != long_poll_timeout_ms)
- {
- unsigned int timeout;
- char dummy;
-
- if (1 != sscanf (long_poll_timeout_ms,
- "%u%c",
- &timeout,
- &dummy))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "timeout_ms (must be non-negative number)");
- }
- gc->timeout
- = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_MILLISECONDS,
- timeout));
- }
- else
- {
- gc->timeout = GNUNET_TIME_relative_to_absolute (
- GNUNET_TIME_UNIT_SECONDS);
- }
- }
+ gc->timeout = GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_UNIT_SECONDS);
+ TALER_MHD_parse_request_timeout (connection,
+ &gc->timeout);
} /* end of first-time initialization (if NULL == gc) */
else
{
@@ -1361,14 +1173,72 @@ AH_handler_truth_get (
GNUNET_assert (! gc->suspended);
return run_authorization_process (connection,
gc);
-
}
/* We get here if the async check for payment said this request
was indeed paid! */
}
+ if (NULL == gc->root)
{
- /* load encrypted truth from DB */
+ /* parse byte stream upload into JSON */
+ enum GNUNET_GenericReturnValue res;
+
+ res = TALER_MHD_parse_post_json (connection,
+ &gc->opaque_post_parsing_context,
+ upload_data,
+ upload_data_size,
+ &gc->root);
+ if (GNUNET_SYSERR == res)
+ {
+ GNUNET_assert (NULL == gc->root);
+ return MHD_NO; /* bad upload, could not even generate error */
+ }
+ if ( (GNUNET_NO == res) ||
+ (NULL == gc->root) )
+ {
+ GNUNET_assert (NULL == gc->root);
+ return MHD_YES; /* so far incomplete upload or parser error */
+ }
+
+ /* 'root' is now initialized, parse JSON body */
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("truth_decryption_key",
+ &gc->truth_key),
+ GNUNET_JSON_spec_fixed_auto ("h_response",
+ &gc->challenge_response),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("payment_secret",
+ &gc->payment_identifier),
+ &gc->no_payment_identifier_provided),
+ GNUNET_JSON_spec_end ()
+ };
+ enum GNUNET_GenericReturnValue res;
+
+ res = TALER_MHD_parse_json_data (connection,
+ gc->root,
+ spec);
+ if (GNUNET_SYSERR == res)
+ {
+ GNUNET_break (0);
+ return MHD_NO; /* hard failure */
+ }
+ if (GNUNET_NO == res)
+ {
+ GNUNET_break_op (0);
+ return MHD_YES; /* failure */
+ }
+ if (! gc->no_payment_identifier_provided)
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Client provided payment identifier `%s'\n",
+ TALER_B2S (&gc->payment_identifier));
+ }
+ }
+
+ {
+ /* load encrypted truth from DB; we may do this repeatedly
+ while handling the same request, if payment was checked
+ asynchronously! */
enum GNUNET_DB_QueryStatus qs;
char *method;
@@ -1426,6 +1296,7 @@ AH_handler_truth_get (
GNUNET_free (method);
}
+ /* check for payment */
if ( (is_question) ||
(! gc->authorization->payment_plugin_managed) )
{
@@ -1435,7 +1306,7 @@ AH_handler_truth_get (
enum GNUNET_DB_QueryStatus qs;
bool paid;
- if (! gc->payment_identifier_provided)
+ if (gc->no_payment_identifier_provided)
{
GNUNET_free (truth_mime);
GNUNET_free (encrypted_truth);
@@ -1486,21 +1357,21 @@ AH_handler_truth_get (
}
}
- /* We've been paid, now validate response */
- {
- /* decrypt encrypted_truth */
- ANASTASIS_CRYPTO_truth_decrypt (&gc->truth_key,
- encrypted_truth,
- encrypted_truth_size,
- &decrypted_truth,
- &decrypted_truth_size);
- GNUNET_free (encrypted_truth);
- }
+ /* We've been paid, now validate the response */
+ /* decrypt encrypted_truth */
+ ANASTASIS_CRYPTO_truth_decrypt (&gc->truth_key,
+ encrypted_truth,
+ encrypted_truth_size,
+ &decrypted_truth,
+ &decrypted_truth_size);
+ GNUNET_free (encrypted_truth);
if (NULL == decrypted_truth)
{
+ /* most likely, the decryption key is simply wrong */
+ GNUNET_break_op (0);
GNUNET_free (truth_mime);
return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_EXPECTATION_FAILED,
+ MHD_HTTP_BAD_REQUEST,
TALER_EC_ANASTASIS_TRUTH_DECRYPTION_FAILED,
NULL);
}
@@ -1520,10 +1391,9 @@ AH_handler_truth_get (
}
/* Not security question, check for answer in DB */
- if (gc->have_response)
{
enum ANASTASIS_DB_CodeStatus cs;
- bool satisfied;
+ bool satisfied = false;
uint64_t code;
GNUNET_free (truth_mime);
@@ -1531,6 +1401,16 @@ AH_handler_truth_get (
{
MHD_RESULT res;
+ if (GNUNET_TIME_absolute_is_past (gc->timeout))
+ {
+ GNUNET_free (decrypted_truth);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Timeout with user provided code\n");
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_FORBIDDEN,
+ TALER_EC_ANASTASIS_IBAN_MISSING_TRANSFER,
+ "timeout awaiting validation");
+ }
res = direct_validation (gc,
decrypted_truth,
decrypted_truth_size);
@@ -1563,134 +1443,32 @@ AH_handler_truth_get (
TALER_EC_GENERIC_DB_FETCH_FAILED,
"verify_challenge_code");
case ANASTASIS_DB_CODE_STATUS_NO_RESULTS:
+ GNUNET_free (decrypted_truth);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Response code unknown (possibly expired). Testing if we may provide a new one.\n");
- gc->have_response = false;
- break;
+ "Specified challenge code %s was not issued\n",
+ GNUNET_h2s (&gc->challenge_response));
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_FORBIDDEN,
+ TALER_EC_ANASTASIS_TRUTH_CHALLENGE_UNKNOWN,
+ "specific challenge code was not issued");
case ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED:
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Response code valid (%s)\n",
- satisfied ? "satisfied" : "unsatisfied");
- if (satisfied)
+ if (! satisfied)
{
+ MHD_RESULT res;
+
+ res = iban_validation (gc,
+ code,
+ decrypted_truth,
+ decrypted_truth_size);
GNUNET_free (decrypted_truth);
- return return_key_share (&gc->truth_uuid,
- connection);
+ return res;
}
- /* continue with authorization plugin below */
- gc->code = code;
- break;
+ GNUNET_free (decrypted_truth);
+ return return_key_share (&gc->truth_uuid,
+ connection);
default:
GNUNET_break (0);
return MHD_NO;
}
}
- if (! gc->have_response)
- {
- /* Not security question and no answer: use plugin to check if
- decrypted truth is a valid challenge! */
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "No challenge provided, creating fresh challenge\n");
- {
- enum GNUNET_GenericReturnValue ret;
-
- ret = gc->authorization->validate (gc->authorization->cls,
- connection,
- truth_mime,
- decrypted_truth,
- decrypted_truth_size);
- GNUNET_free (truth_mime);
- switch (ret)
- {
- case GNUNET_OK:
- /* data valid, continued below */
- break;
- case GNUNET_NO:
- /* data invalid, reply was queued */
- GNUNET_free (decrypted_truth);
- return MHD_YES;
- case GNUNET_SYSERR:
- /* data invalid, reply was NOT queued */
- GNUNET_free (decrypted_truth);
- return MHD_NO;
- }
- }
-
- /* Setup challenge and begin authorization process */
- {
- struct GNUNET_TIME_Absolute transmission_date;
- enum GNUNET_DB_QueryStatus qs;
-
- qs = db->create_challenge_code (db->cls,
- &gc->truth_uuid,
- gc->authorization->code_rotation_period,
- gc->authorization->code_validity_period,
- gc->authorization->retry_counter,
- &transmission_date,
- &gc->code);
- switch (qs)
- {
- case GNUNET_DB_STATUS_HARD_ERROR:
- case GNUNET_DB_STATUS_SOFT_ERROR:
- GNUNET_break (0);
- GNUNET_free (decrypted_truth);
- return TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "create_challenge_code");
- case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- /* 0 == retry_counter of existing challenge => rate limit exceeded */
- GNUNET_free (decrypted_truth);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_TOO_MANY_REQUESTS,
- TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED,
- NULL);
- case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- /* challenge code was stored successfully*/
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Created fresh challenge\n");
- break;
- }
-
- if (GNUNET_TIME_absolute_get_duration (transmission_date).rel_value_us <
- gc->authorization->code_retransmission_frequency.rel_value_us)
- {
- /* Too early for a retransmission! */
- GNUNET_free (decrypted_truth);
- return TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_ALREADY_REPORTED,
- TALER_EC_ANASTASIS_TRUTH_CHALLENGE_ACTIVE,
- NULL);
- }
- }
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Beginning authorization process\n");
- gc->as = gc->authorization->start (gc->authorization->cls,
- &AH_trigger_daemon,
- NULL,
- &gc->truth_uuid,
- gc->code,
- decrypted_truth,
- decrypted_truth_size);
- GNUNET_free (decrypted_truth);
- if (NULL == gc->as)
- {
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (gc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_ANASTASIS_TRUTH_AUTHORIZATION_START_FAILED,
- NULL);
- }
- if (! gc->in_list)
- {
- gc->in_list = true;
- GNUNET_CONTAINER_DLL_insert (gc_head,
- gc_tail,
- gc);
- }
- GNUNET_assert (! gc->suspended);
- return run_authorization_process (connection,
- gc);
}
diff --git a/src/backend/anastasis-httpd_truth_upload.c b/src/backend/anastasis-httpd_truth-upload.c
index 8eb410c..1c2a58d 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth-upload.c
@@ -287,15 +287,14 @@ proposal_cb (void *cls,
* Callback to process a GET /check-payment request
*
* @param cls our `struct PolicyUploadContext`
- * @param hr HTTP response details
* @param osr order status
*/
static void
check_payment_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_OrderStatusResponse *osr)
{
struct TruthUploadContext *tuc = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &osr->hr;
tuc->cpo = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -311,7 +310,7 @@ check_payment_cb (void *cls,
NULL);
break;
case MHD_HTTP_OK:
- switch (osr->status)
+ switch (osr->details.ok.status)
{
case TALER_MERCHANT_OSC_PAID:
{
@@ -321,13 +320,12 @@ check_payment_cb (void *cls,
const json_t *contract;
struct TALER_Amount amount;
struct GNUNET_JSON_Specification cspec[] = {
- TALER_JSON_spec_amount ("amount",
- AH_currency,
- &amount),
+ TALER_JSON_spec_amount_any ("amount",
+ &amount),
GNUNET_JSON_spec_end ()
};
- contract = osr->details.paid.contract_terms;
+ contract = osr->details.ok.details.paid.contract_terms;
if (GNUNET_OK !=
GNUNET_JSON_parse (contract,
cspec,
@@ -356,7 +354,7 @@ check_payment_cb (void *cls,
qs = db->record_truth_upload_payment (
db->cls,
&tuc->truth_uuid,
- &osr->details.paid.deposit_total,
+ &osr->details.ok.details.paid.deposit_total,
paid_until);
if (qs <= 0)
{
@@ -398,6 +396,7 @@ check_payment_cb (void *cls,
case MHD_HTTP_NOT_FOUND:
/* Setup fresh order */
{
+ static const char *no_uuids[1] = { NULL };
char *order_id;
json_t *order;
@@ -417,7 +416,6 @@ check_payment_cb (void *cls,
"description", "challenge storage fee",
"quantity", (json_int_t) tuc->years_to_pay,
"unit", "years",
-
"order_id",
order_id);
GNUNET_free (order_id);
@@ -429,7 +427,7 @@ check_payment_cb (void *cls,
0,
NULL, /* no inventory products */
0,
- NULL, /* no uuids */
+ no_uuids, /* no uuids */
false, /* do NOT require claim token */
&proposal_cb,
tuc);
@@ -487,7 +485,6 @@ begin_payment (struct TruthUploadContext *tuc)
AH_backend_url,
order_id,
NULL /* our payments are NOT session-bound */,
- false,
timeout,
&check_payment_cb,
tuc);
@@ -526,7 +523,8 @@ AH_handler_truth_post (
const char *type;
enum GNUNET_DB_QueryStatus qs;
uint32_t storage_years;
- struct GNUNET_TIME_Absolute paid_until;
+ struct GNUNET_TIME_Timestamp paid_until
+ = GNUNET_TIME_UNIT_ZERO_TS;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("key_share_data",
&key_share_data),
@@ -537,7 +535,8 @@ AH_handler_truth_post (
&encrypted_truth_size),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("truth_mime",
- &truth_mime)),
+ &truth_mime),
+ NULL),
GNUNET_JSON_spec_uint32 ("storage_duration_years",
&storage_years),
GNUNET_JSON_spec_end ()
@@ -550,78 +549,12 @@ AH_handler_truth_post (
tuc->truth_uuid = *truth_uuid;
hc->ctx = tuc;
hc->cc = &cleanup_truth_post;
-
- /* check for excessive upload */
- {
- const char *lens;
- unsigned long len;
- char dummy;
-
- lens = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- MHD_HTTP_HEADER_CONTENT_LENGTH);
- if ( (NULL == lens) ||
- (1 != sscanf (lens,
- "%lu%c",
- &len,
- &dummy)) )
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (
- connection,
- MHD_HTTP_BAD_REQUEST,
- (NULL == lens)
- ? TALER_EC_ANASTASIS_GENERIC_MISSING_CONTENT_LENGTH
- : TALER_EC_ANASTASIS_GENERIC_MALFORMED_CONTENT_LENGTH,
- NULL);
- }
- if (len / 1024 / 1024 >= AH_upload_limit_mb)
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_PAYLOAD_TOO_LARGE,
- TALER_EC_SYNC_MALFORMED_CONTENT_LENGTH,
- "Content-length value not acceptable");
- }
- }
-
- {
- const char *long_poll_timeout_ms;
-
- long_poll_timeout_ms = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "timeout_ms");
- if (NULL != long_poll_timeout_ms)
- {
- unsigned int timeout;
- char dummy;
-
- if (1 != sscanf (long_poll_timeout_ms,
- "%u%c",
- &timeout,
- &dummy))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "timeout_ms (must be non-negative number)");
- }
- tuc->timeout
- = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_MILLISECONDS,
- timeout));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Long polling for %u ms enabled\n",
- timeout);
- }
- else
- {
- tuc->timeout = GNUNET_TIME_relative_to_absolute (
- GNUNET_TIME_UNIT_SECONDS);
- }
- }
-
+ TALER_MHD_check_content_length (connection,
+ AH_upload_limit_mb * 1024LLU * 1024LLU);
+ tuc->timeout = GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_UNIT_SECONDS);
+ TALER_MHD_parse_request_timeout (connection,
+ &tuc->timeout);
} /* end 'if (NULL == tuc)' */
if (NULL != tuc->resp)
@@ -695,85 +628,78 @@ AH_handler_truth_post (
if (0 == storage_years)
storage_years = 1;
+ if (! TALER_amount_is_zero (&AH_truth_upload_fee))
{
- struct TALER_Amount zero_amount;
-
- TALER_amount_set_zero (AH_currency,
- &zero_amount);
- if (0 != TALER_amount_cmp (&AH_truth_upload_fee,
- &zero_amount))
+ struct GNUNET_TIME_Timestamp desired_until;
+ enum GNUNET_DB_QueryStatus qs;
+
+ desired_until
+ = GNUNET_TIME_relative_to_timestamp (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
+ storage_years));
+ qs = db->check_truth_upload_paid (db->cls,
+ truth_uuid,
+ &paid_until);
+ if (qs < 0)
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ NULL);
+ if ( (0 == qs) ||
+ (GNUNET_TIME_timestamp_cmp (paid_until,
+ <,
+ desired_until) ) )
{
- struct GNUNET_TIME_Absolute desired_until;
- enum GNUNET_DB_QueryStatus qs;
-
- desired_until
- = GNUNET_TIME_relative_to_absolute (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
- storage_years));
- qs = db->check_truth_upload_paid (db->cls,
- truth_uuid,
- &paid_until);
- if (qs < 0)
+ struct GNUNET_TIME_Relative rem;
+
+ if (GNUNET_TIME_absolute_is_past (paid_until.abs_time))
+ paid_until = GNUNET_TIME_timestamp_get ();
+ rem = GNUNET_TIME_absolute_get_difference (paid_until.abs_time,
+ desired_until.abs_time);
+ tuc->years_to_pay = rem.rel_value_us
+ / GNUNET_TIME_UNIT_YEARS.rel_value_us;
+ if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
+ tuc->years_to_pay++;
+ if (0 >
+ TALER_amount_multiply (&tuc->upload_fee,
+ &AH_truth_upload_fee,
+ tuc->years_to_pay))
+ {
+ GNUNET_break_op (0);
return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- NULL);
- if ( (0 == qs) ||
- (paid_until.abs_value_us < desired_until.abs_value_us) )
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "storage_duration_years");
+ }
+ if (! TALER_amount_is_zero (&tuc->upload_fee))
{
- struct GNUNET_TIME_Absolute now;
- struct GNUNET_TIME_Relative rem;
-
- now = GNUNET_TIME_absolute_get ();
- if (paid_until.abs_value_us < now.abs_value_us)
- paid_until = now;
- rem = GNUNET_TIME_absolute_get_difference (paid_until,
- desired_until);
- tuc->years_to_pay = rem.rel_value_us
- / GNUNET_TIME_UNIT_YEARS.rel_value_us;
- if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
- tuc->years_to_pay++;
- if (0 >
- TALER_amount_multiply (&tuc->upload_fee,
- &AH_truth_upload_fee,
- tuc->years_to_pay))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "storage_duration_years");
- }
- if ( (0 != tuc->upload_fee.fraction) ||
- (0 != tuc->upload_fee.value) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Truth upload payment required (%d)!\n",
- qs);
- return begin_payment (tuc);
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Truth upload payment required (%d)!\n",
+ qs);
+ return begin_payment (tuc);
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TRUTH paid until %s (%d)!\n",
- GNUNET_STRINGS_relative_time_to_string (
- GNUNET_TIME_absolute_get_remaining (
- paid_until),
- GNUNET_YES),
- qs);
- }
- else
- {
- paid_until
- = GNUNET_TIME_relative_to_absolute (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
- ANASTASIS_MAX_YEARS_STORAGE));
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "TRUTH paid until %s (%d)!\n",
+ GNUNET_TIME_relative2s (
+ GNUNET_TIME_absolute_get_remaining (
+ paid_until.abs_time),
+ GNUNET_YES),
+ qs);
+ }
+ else
+ {
+ paid_until
+ = GNUNET_TIME_relative_to_timestamp (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
+ ANASTASIS_MAX_YEARS_STORAGE));
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Storing truth until %s!\n",
- GNUNET_STRINGS_absolute_time_to_string (paid_until));
+ "Storing truth %s until %s!\n",
+ TALER_B2S (truth_uuid),
+ GNUNET_TIME_timestamp2s (paid_until));
qs = db->store_truth (db->cls,
truth_uuid,
&key_share_data,
@@ -783,7 +709,8 @@ AH_handler_truth_post (
encrypted_truth,
encrypted_truth_size,
type,
- GNUNET_TIME_absolute_get_remaining (paid_until));
+ GNUNET_TIME_absolute_get_remaining (
+ paid_until.abs_time));
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -813,8 +740,8 @@ AH_handler_truth_post (
ok = ( (xtruth_size == encrypted_truth_size) &&
(0 == strcmp (xmethod,
type)) &&
- (0 == strcmp (truth_mime,
- xtruth_mime)) &&
+ (0 == strcmp (((NULL == truth_mime) ? "" : truth_mime),
+ ((NULL == xtruth_mime) ? "" : xtruth_mime))) &&
(0 == memcmp (xtruth,
encrypted_truth,
xtruth_size)) );
diff --git a/src/backend/anastasis-httpd_truth.h b/src/backend/anastasis-httpd_truth.h
index 87e570b..a436394 100644
--- a/src/backend/anastasis-httpd_truth.h
+++ b/src/backend/anastasis-httpd_truth.h
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2014, 2015, 2016, 2021 Anastasis SARL
+ Copyright (C) 2020-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -24,13 +24,18 @@
#define ANASTASIS_HTTPD_TRUTH_H
#include <microhttpd.h>
-
/**
- * Prepare all active GET truth requests for system shutdown.
+ * Prepare all active POST truth solve requests for system shutdown.
*/
void
-AH_truth_shutdown (void);
+AH_truth_solve_shutdown (void);
+
+/**
+ * Prepare all active POST truth challenge requests for system shutdown.
+ */
+void
+AH_truth_challenge_shutdown (void);
/**
* Prepare all active POST truth requests for system shutdown.
@@ -40,36 +45,60 @@ AH_truth_upload_shutdown (void);
/**
- * Handle a GET to /truth/$UUID
+ * Handle a POST to /truth/$UUID.
*
- * @param connection the MHD connection to handle
+ * @param[in,out] connection the MHD connection to handle
+ * @param[in,out] hc connection context
* @param truth_uuid the truth UUID
- * @param hc connection context
+ * @param truth_data truth data
+ * @param truth_data_size number of bytes (left) in @a truth_data
* @return MHD result code
*/
MHD_RESULT
-AH_handler_truth_get (
+AH_handler_truth_post (
struct MHD_Connection *connection,
+ struct TM_HandlerContext *hc,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
- struct TM_HandlerContext *hc);
+ const char *truth_data,
+ size_t *truth_data_size);
/**
- * Handle a POST to /truth/$UUID.
+ * Handle a POST to /truth/$UUID/solve.
*
- * @param connection the MHD connection to handle
- * @param hc connection context
+ * @param[in,out] connection the MHD connection to handle
+ * @param[in,out] hc connection context
* @param truth_uuid the truth UUID
* @param truth_data truth data
* @param truth_data_size number of bytes (left) in @a truth_data
* @return MHD result code
*/
MHD_RESULT
-AH_handler_truth_post (
+AH_handler_truth_solve (
struct MHD_Connection *connection,
struct TM_HandlerContext *hc,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
- const char *truth_data,
- size_t *truth_data_size);
+ const char *upload_data,
+ size_t *upload_data_size);
+
+
+/**
+ * Handle a POST to /truth/$UUID/challenge.
+ *
+ * @param[in,out] connection the MHD connection to handle
+ * @param[in,out] hc connection context
+ * @param truth_uuid the truth UUID
+ * @param truth_data truth data
+ * @param truth_data_size number of bytes (left) in @a truth_data
+ * @return MHD result code
+ */
+MHD_RESULT
+AH_handler_truth_challenge (
+ struct MHD_Connection *connection,
+ struct TM_HandlerContext *hc,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
+ const char *upload_data,
+ size_t *upload_data_size);
+
#endif
diff --git a/src/backend/anastasis.conf b/src/backend/anastasis.conf
index ad85be2..4721760 100644
--- a/src/backend/anastasis.conf
+++ b/src/backend/anastasis.conf
@@ -49,7 +49,7 @@ UPLOAD_LIMIT_MB = 16
FULFILLMENT_URL = taler://fulfillment-success
# Server salt 16 Byte
-# SERVER_SALT = gUfO1KGOKYIFlFQg
+# PROVIDER_SALT = gUfO1KGOKYIFlFQg
# Directory with our terms of service.
diff --git a/src/cli/.gitignore b/src/cli/.gitignore
index dbf01fa..111e321 100644
--- a/src/cli/.gitignore
+++ b/src/cli/.gitignore
@@ -1,6 +1,13 @@
*.log
+*.err
+*.out
anastasis-reducer
test_reducer_home
*.trs
taler-bank.err
wallet.err
+anastasis-discover
+talercheck
+test_reducer.conf.edited
+wallet-withdraw.out
+libeufin-transfer-initiate.out
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 8434c91..8b2a9a0 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -2,6 +2,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/include
bin_PROGRAMS = \
+ anastasis-discover \
anastasis-reducer
if USE_COVERAGE
@@ -19,7 +20,11 @@ check_SCRIPTS = \
test_anastasis_reducer_done_policy_review.sh \
test_anastasis_reducer_enter_secret.sh \
test_anastasis_reducer_recovery_enter_user_attributes.sh \
- test_iban.sh
+ test_anastasis_reducer_recovery_no_pay.sh \
+ test_anastasis_reducer_recovery_hanging.sh
+
+# Removed for now, libeufin is not yet working OK for this.
+# test_iban.sh
AM_TESTS_ENVIRONMENT=export ANASTASIS_PREFIX=$${ANASTASIS_PREFIX:-@libdir@};export PATH=$${ANASTASIS_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
@@ -29,12 +34,19 @@ TESTS = \
EXTRA_DIST = \
$(check_SCRIPTS) \
+ setup.sh \
+ test_reducer_home/.local/share/taler/exchange-offline/master.priv \
test_reducer.conf \
+ test_reducer_free.conf \
test_free_reducer.conf \
test_anastasis_reducer_1.conf \
test_anastasis_reducer_2.conf \
test_anastasis_reducer_3.conf \
test_anastasis_reducer_4.conf \
+ test_anastasis_reducer_free_1.conf \
+ test_anastasis_reducer_free_2.conf \
+ test_anastasis_reducer_free_3.conf \
+ test_anastasis_reducer_free_4.conf \
resources/00-backup.json \
resources/01-backup.json \
resources/02-backup.json \
@@ -58,3 +70,17 @@ anastasis_reducer_LDADD = \
-lgnunetutil \
-ljansson \
$(XLIB)
+
+
+anastasis_discover_SOURCES = \
+ anastasis-cli-discover.c
+anastasis_discover_LDADD = \
+ $(top_builddir)/src/util/libanastasisutil.la \
+ $(top_builddir)/src/reducer/libanastasisredux.la \
+ -ltalerjson \
+ -ltalerutil \
+ -lgnunetjson \
+ -lgnunetcurl \
+ -lgnunetutil \
+ -ljansson \
+ $(XLIB)
diff --git a/src/cli/anastasis-cli-discover.c b/src/cli/anastasis-cli-discover.c
new file mode 100644
index 0000000..f614165
--- /dev/null
+++ b/src/cli/anastasis-cli-discover.c
@@ -0,0 +1,261 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2022 Anastasis SARL
+
+ Anastasis is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file cli/anastasis-cli-discover.c
+ * @brief command line tool to discover recovery policies
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_curl_lib.h>
+#include "anastasis_redux.h"
+#include <taler/taler_util.h>
+#include <taler/taler_error_codes.h>
+#include <taler/taler_json_lib.h>
+#include "anastasis_util_lib.h"
+
+/**
+ * Closure for #GNUNET_CURL_gnunet_scheduler_reschedule().
+ */
+static struct GNUNET_CURL_RescheduleContext *rc;
+
+/**
+ * Curl context for communication with anastasis backend
+ */
+static struct GNUNET_CURL_Context *ctx;
+
+/**
+ * Input to -a option given.
+ */
+static char *input;
+
+/**
+ * JSON containing previous state
+ */
+static json_t *prev_state;
+
+/**
+ * JSON containing arguments for action
+ */
+static json_t *arguments;
+
+/**
+ * Handle to an ongoing action.
+ */
+struct ANASTASIS_PolicyDiscovery *pd;
+
+/**
+ * Return value from main.
+ */
+static int global_ret;
+
+
+/**
+ * Function called on each discovered recovery policy. Called
+ * with all arguments NULL if we have received all policies that
+ * we could possibly receive for the current operation.
+ *
+ * The client can then start a new policy discovery process, using the
+ * smallest (also most recent) @a version received per @a provider_url
+ * in the cursor to resume. Note that in this case, the application
+ * logic is responsible for de-duplication using @a hcpd, or it may show
+ * policies again if they are at different providers under versions not
+ * queried up to the cursor.
+ *
+ * @param cls closure
+ * @param hcpd hash of the compressed policy document (unique per policy)
+ * @param provider_url which provider claims to have this policy
+ * @param version version of the policy at this provider
+ * @param attribute_mask combination of optional identity attributes
+ * present in the state that was used to locate this version
+ * @param server_time when did the provider receive the upload
+ * @param secret_name name the user assigned to the backup
+ */
+static void
+print_policy_cb (void *cls,
+ const struct GNUNET_HashCode *hcpd,
+ const char *provider_url,
+ uint32_t version,
+ json_int_t attribute_mask,
+ struct GNUNET_TIME_Timestamp server_time,
+ const char *secret_name,
+ const json_t *providers)
+{
+ if (NULL == hcpd)
+ {
+ fprintf (stderr,
+ "All results received, terminating\n");
+ pd = NULL;
+ global_ret = 0;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ fprintf (stdout,
+ "%s %u %u : \"%s\" \"%s\" (%s)\n",
+ provider_url,
+ (unsigned int) version,
+ (unsigned int) attribute_mask,
+ GNUNET_TIME_timestamp2s (server_time),
+ secret_name,
+ GNUNET_h2s (hcpd));
+}
+
+
+/**
+ * @brief Shutdown the application.
+ *
+ * @param cls closure
+ */
+static void
+shutdown_task (void *cls)
+{
+ (void) cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Shutdown initiated\n");
+ if (NULL != pd)
+ {
+ ANASTASIS_policy_discovery_stop (pd);
+ pd = NULL;
+ }
+ ANASTASIS_redux_done ();
+ if (NULL != ctx)
+ {
+ GNUNET_CURL_fini (ctx);
+ ctx = NULL;
+ }
+ if (NULL != rc)
+ {
+ GNUNET_CURL_gnunet_rc_destroy (rc);
+ rc = NULL;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Shutdown complete\n");
+}
+
+
+/**
+ * @brief Start the application
+ *
+ * @param cls closure
+ * @param args arguments left
+ * @param cfgfile config file name
+ * @param cfg handle for the configuration file
+ */
+static void
+run (void *cls,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ (void) cls;
+ json_error_t error;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Starting anastasis-discover\n");
+ GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+ NULL);
+ /* load cursor */
+ if (NULL != input)
+ {
+ arguments = json_loads (input,
+ JSON_DECODE_ANY,
+ &error);
+ if (NULL == arguments)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+ "Failed to parse arguments on line %u:%u: %s!\n",
+ error.line,
+ error.column,
+ error.text);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ }
+ /* load state */
+ if (NULL != args[0])
+ {
+ prev_state = json_load_file (args[0],
+ JSON_DECODE_ANY,
+ &error);
+ args++;
+ }
+ else
+ {
+ prev_state = json_loadf (stdin,
+ JSON_DECODE_ANY,
+ &error);
+ }
+ if (NULL == prev_state)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
+ "Failed to parse initial state on line %u:%u: %s!\n",
+ error.line,
+ error.column,
+ error.text);
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ /* initialize HTTP client event loop */
+ ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
+ &rc);
+ rc = GNUNET_CURL_gnunet_rc_create (ctx);
+ ANASTASIS_redux_init (ctx);
+ pd = ANASTASIS_policy_discovery_start (prev_state,
+ arguments,
+ &print_policy_cb,
+ NULL);
+}
+
+
+int
+main (int argc,
+ char *const *argv)
+{
+ /* the available command line options */
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_string ('a',
+ "arguments",
+ "JSON",
+ "pass a JSON string containing cursor to use",
+ &input),
+
+ GNUNET_GETOPT_OPTION_END
+ };
+ enum GNUNET_GenericReturnValue ret;
+
+ /* FIRST get the libtalerutil initialization out
+ of the way. Then throw that one away, and force
+ the SYNC defaults to be used! */
+ (void) TALER_project_data_default ();
+ GNUNET_OS_init (ANASTASIS_project_data_default ());
+ ret = GNUNET_PROGRAM_run (argc,
+ argv,
+ "anastasis-discover",
+ "This is an application for finding secrets that could be recovered.\n",
+ options,
+ &run,
+ NULL);
+ if (GNUNET_SYSERR == ret)
+ return 3;
+ if (GNUNET_NO == ret)
+ return 0;
+ return global_ret;
+}
+
+
+/* end of anastasis-cli-discover.c */
diff --git a/src/cli/anastasis-cli-redux.c b/src/cli/anastasis-cli-redux.c
index dc9c7ab..e2d2e1d 100644
--- a/src/cli/anastasis-cli-redux.c
+++ b/src/cli/anastasis-cli-redux.c
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2020,2021 Anastasis SARL
+ Copyright (C) 2020,2021,2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free Software
@@ -41,6 +41,12 @@ static struct GNUNET_CURL_RescheduleContext *rc;
static struct GNUNET_CURL_Context *ctx;
/**
+ * Application ID to include in the user attributes.
+ * (-a option).
+ */
+char *application_id;
+
+/**
* -b option given.
*/
static int b_flag;
@@ -146,6 +152,9 @@ action_cb (void *cls,
"Redux failed with error %d: %s\n",
error_code,
TALER_ErrorCode_get_hint (error_code));
+ json_dumpf (result_state,
+ stderr,
+ JSON_INDENT (2));
}
GNUNET_SCHEDULER_shutdown ();
global_ret = (TALER_EC_NONE != error_code) ? 1 : 0;
@@ -309,6 +318,21 @@ run (void *cls,
&rc);
rc = GNUNET_CURL_gnunet_rc_create (ctx);
ANASTASIS_redux_init (ctx);
+ /* Expand identity_attributes if -a is given explicitly and we
+ are at the respective step of the reduction */
+ if ( (0 == strcasecmp (action,
+ "enter_user_attributes")) &&
+ (NULL != application_id) &&
+ (NULL != arguments) )
+ {
+ json_t *attr = json_object_get (arguments,
+ "identity_attributes");
+ if (NULL != attr)
+ GNUNET_assert (0 ==
+ json_object_set_new (attr,
+ "application-id",
+ json_string (application_id)));
+ }
ra = ANASTASIS_redux_action (prev_state,
action,
arguments,
@@ -324,6 +348,16 @@ main (int argc,
{
/* the available command line options */
struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_string ('A',
+ "application",
+ "ID",
+ "set the application ID",
+ &application_id),
+ GNUNET_GETOPT_option_string ('a',
+ "arguments",
+ "JSON",
+ "pass a JSON string containing arguments to reducer",
+ &input),
GNUNET_GETOPT_option_flag ('b',
"backup",
"use reducer to handle states for backup process",
@@ -332,12 +366,6 @@ main (int argc,
"restore",
"use reducer to handle states for restore process",
&r_flag),
- GNUNET_GETOPT_option_string ('a',
- "arguments",
- "JSON",
- "pass a JSON string containing arguments to reducer",
- &input),
-
GNUNET_GETOPT_OPTION_END
};
enum GNUNET_GenericReturnValue ret;
@@ -354,6 +382,7 @@ main (int argc,
options,
&run,
NULL);
+ GNUNET_free (application_id);
if (GNUNET_SYSERR == ret)
return 3;
if (GNUNET_NO == ret)
diff --git a/src/cli/resources/00-backup.json b/src/cli/resources/00-backup.json
index 6e6c320..700f8cd 100644
--- a/src/cli/resources/00-backup.json
+++ b/src/cli/resources/00-backup.json
@@ -2,7 +2,8 @@
"continents": [
"Europe",
"North America",
- "Testcontinent"
+ "Demoworld"
],
- "backup_state": "CONTINENT_SELECTING"
-} \ No newline at end of file
+ "backup_state": "CONTINENT_SELECTING",
+ "reducer_type": "backup"
+}
diff --git a/src/cli/resources/00-recovery.json b/src/cli/resources/00-recovery.json
index acff19a..e9b14f3 100644
--- a/src/cli/resources/00-recovery.json
+++ b/src/cli/resources/00-recovery.json
@@ -4,5 +4,6 @@
"North America",
"Testcontinent"
],
+ "reducer_type": "recovery",
"recovery_state": "CONTINENT_SELECTING"
-} \ No newline at end of file
+}
diff --git a/src/cli/resources/01-backup.json b/src/cli/resources/01-backup.json
index 842d3af..be2a9d9 100644
--- a/src/cli/resources/01-backup.json
+++ b/src/cli/resources/01-backup.json
@@ -2,15 +2,16 @@
"continents": [
"Europe",
"North America",
- "Testcontinent"
+ "Demoworld"
],
"backup_state": "COUNTRY_SELECTING",
- "selected_continent": "Testcontinent",
+ "reducer_type": "backup",
+ "selected_continent": "Demoworld",
"countries": [
{
"code": "xx",
"name": "Testland",
- "continent": "Testcontinent",
+ "continent": "Demoworld",
"continent_i18n": {
"xx": "Testkontinent"
},
@@ -19,23 +20,7 @@
"de_CH": "Testlandi",
"fr": "Testpais",
"en": "Testland"
- },
- "currency": "TESTKUDOS"
- },
- {
- "code": "xy",
- "name": "Demoland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
- "name_i18n": {
- "de_DE": "Demolandt",
- "de_CH": "Demolandi",
- "fr": "Demopais",
- "en": "Demoland"
- },
- "currency": "KUDOS"
+ }
}
]
-} \ No newline at end of file
+}
diff --git a/src/cli/resources/01-recovery.json b/src/cli/resources/01-recovery.json
index 11aafd3..5489814 100644
--- a/src/cli/resources/01-recovery.json
+++ b/src/cli/resources/01-recovery.json
@@ -5,6 +5,7 @@
"Testcontinent"
],
"recovery_state": "COUNTRY_SELECTING",
+ "reducer_type": "recovery",
"selected_continent": "Testcontinent",
"countries": [
{
@@ -38,4 +39,4 @@
"currency": "KUDOS"
}
]
-} \ No newline at end of file
+}
diff --git a/src/cli/resources/02-backup.json b/src/cli/resources/02-backup.json
index c9bba16..a298b69 100644
--- a/src/cli/resources/02-backup.json
+++ b/src/cli/resources/02-backup.json
@@ -2,50 +2,31 @@
"continents": [
"Europe",
"North America",
- "Testcontinent"
+ "Demoworld"
],
"backup_state": "USER_ATTRIBUTES_COLLECTING",
+ "reducer_type": "backup",
"selected_continent": "Testcontinent",
"countries": [
{
"code": "xx",
"name": "Testland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
+ "continent": "Demoworld",
"name_i18n": {
"de_DE": "Testlandt",
"de_CH": "Testlandi",
"fr": "Testpais",
"en": "Testland"
- },
- "currency": "TESTKUDOS"
- },
- {
- "code": "xy",
- "name": "Demoland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
- "name_i18n": {
- "de_DE": "Demolandt",
- "de_CH": "Demolandi",
- "fr": "Demopais",
- "en": "Demoland"
- },
- "currency": "KUDOS"
+ }
}
],
"authentication_providers": {
- "http://localhost:8086/": {},
- "http://localhost:8087/": {},
- "http://localhost:8088/": {},
- "http://localhost:8089/": {}
+ "http://localhost:8086/": { "status" : "not-contacted" },
+ "http://localhost:8087/": { "status" : "not-contacted" },
+ "http://localhost:8088/": { "status" : "not-contacted" },
+ "http://localhost:8089/": { "status" : "not-contacted" }
},
"selected_country": "xx",
- "currencies": [ "TESTKUDOS" ],
"required_attributes": [
{
"type": "string",
diff --git a/src/cli/resources/02-recovery.json b/src/cli/resources/02-recovery.json
index 79cfd6d..875fae0 100644
--- a/src/cli/resources/02-recovery.json
+++ b/src/cli/resources/02-recovery.json
@@ -5,6 +5,7 @@
"Testcontinent"
],
"recovery_state": "USER_ATTRIBUTES_COLLECTING",
+ "reducer_type": "recovery",
"selected_continent": "Testcontinent",
"countries": [
{
@@ -39,10 +40,10 @@
}
],
"authentication_providers": {
- "http://localhost:8086/": {},
- "http://localhost:8087/": {},
- "http://localhost:8088/": {},
- "http://localhost:8089/": {}
+ "http://localhost:8086/": { "status" : "not-contacted" },
+ "http://localhost:8087/": { "status" : "not-contacted" },
+ "http://localhost:8088/": { "status" : "not-contacted" },
+ "http://localhost:8089/": { "status" : "not-contacted" }
},
"selected_country": "xx",
"currencies": [ "TESTKUDOS" ],
diff --git a/src/cli/resources/03-backup.json b/src/cli/resources/03-backup.json
index 4dd5368..15627a9 100644
--- a/src/cli/resources/03-backup.json
+++ b/src/cli/resources/03-backup.json
@@ -2,44 +2,27 @@
"continents": [
"Europe",
"North America",
- "Testcontinent"
+ "Demoworld"
],
"backup_state": "AUTHENTICATIONS_EDITING",
- "selected_continent": "Testcontinent",
+ "reducer_type": "backup",
+ "selected_continent": "Demoworld",
"countries": [
{
"code": "xx",
"name": "Testland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
+ "continent": "Demoworld",
"name_i18n": {
"de_DE": "Testlandt",
"de_CH": "Testlandi",
"fr": "Testpais",
"en": "Testland"
- },
- "currency": "TESTKUDOS"
- },
- {
- "code": "xy",
- "name": "Demoland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
- "name_i18n": {
- "de_DE": "Demolandt",
- "de_CH": "Demolandi",
- "fr": "Demopais",
- "en": "Demoland"
- },
- "currency": "KUDOS"
+ }
}
],
"authentication_providers": {
"http://localhost:8086/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -52,13 +35,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #1 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
+ "provider_salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
"http_status": 200
},
"http://localhost:8087/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -71,13 +54,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #2 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
+ "provider_salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
"http_status": 200
},
"http://localhost:8088/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -90,13 +73,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #3 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
+ "provider_salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
"http_status": 200
},
"http://localhost:8089/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -109,15 +92,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #4 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
+ "provider_salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
"http_status": 200
}
},
"selected_country": "xx",
- "currencies": ["TESTKUDOS"],
"required_attributes": [
{
"type": "string",
diff --git a/src/cli/resources/04-backup.json b/src/cli/resources/04-backup.json
index db51f5a..c7dc6fe 100644
--- a/src/cli/resources/04-backup.json
+++ b/src/cli/resources/04-backup.json
@@ -2,44 +2,27 @@
"continents": [
"Europe",
"North America",
- "Testcontinent"
+ "Demoworld"
],
"backup_state": "AUTHENTICATIONS_EDITING",
- "selected_continent": "Testcontinent",
+ "reducer_type": "backup",
+ "selected_continent": "Demoworld",
"countries": [
{
"code": "xx",
"name": "Testland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
+ "continent": "Demoworld",
"name_i18n": {
"de_DE": "Testlandt",
"de_CH": "Testlandi",
"fr": "Testpais",
"en": "Testland"
- },
- "currency": "TESTKUDOS"
- },
- {
- "code": "xy",
- "name": "Demoland",
- "continent": "Testcontinent",
- "continent_i18n": {
- "xx": "Testkontinent"
- },
- "name_i18n": {
- "de_DE": "Demolandt",
- "de_CH": "Demolandi",
- "fr": "Demopais",
- "en": "Demoland"
- },
- "currency": "KUDOS"
+ }
}
],
"authentication_providers": {
"http://localhost:8086/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -52,13 +35,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #1 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
+ "provider_salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
"http_status": 200
},
"http://localhost:8087/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -71,13 +54,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #2 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
+ "provider_salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
"http_status": 200
},
"http://localhost:8088/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -90,13 +73,13 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #3 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
+ "provider_salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
"http_status": 200
},
"http://localhost:8089/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -109,10 +92,9 @@
"truth_lifetime": {
"d_ms": 63115200000
},
- "currency": "TESTKUDOS",
"business_name": "Data loss #4 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
+ "provider_salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
"http_status": 200
}
},
diff --git a/src/cli/resources/05-backup.json b/src/cli/resources/05-backup.json
index 143d9e3..c8f52f0 100644
--- a/src/cli/resources/05-backup.json
+++ b/src/cli/resources/05-backup.json
@@ -5,6 +5,7 @@
"Testcontinent"
],
"backup_state": "POLICIES_REVIEWING",
+ "reducer_type": "backup",
"selected_continent": "Testcontinent",
"countries": [
{
@@ -40,6 +41,7 @@
],
"authentication_providers": {
"http://localhost:8086/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -55,10 +57,11 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #1 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
+ "provider_salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
"http_status": 200
},
"http://localhost:8087/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -74,10 +77,11 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #2 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
+ "provider_salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
"http_status": 200
},
"http://localhost:8088/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -93,10 +97,11 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #3 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
+ "provider_salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
"http_status": 200
},
"http://localhost:8089/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -112,7 +117,7 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #4 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
+ "provider_salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
"http_status": 200
}
},
diff --git a/src/cli/resources/06-backup.json b/src/cli/resources/06-backup.json
index 9944a17..04d8b02 100644
--- a/src/cli/resources/06-backup.json
+++ b/src/cli/resources/06-backup.json
@@ -5,6 +5,7 @@
"Testcontinent"
],
"backup_state": "SECRET_EDITING",
+ "reducer_type": "backup",
"selected_continent": "Testcontinent",
"countries": [
{
@@ -40,6 +41,7 @@
],
"authentication_providers": {
"http://localhost:8086/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -55,10 +57,11 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #1 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
+ "provider_salt": "F0HEYJQW81ZAZ3VYMZHFG8T1Z0",
"http_status": 200
},
"http://localhost:8087/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -74,10 +77,11 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #2 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
+ "provider_salt": "D378FWXHJB8JHPQFQRZGGV9PWG",
"http_status": 200
},
"http://localhost:8088/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -93,10 +97,11 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #3 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
+ "provider_salt": "7W9W4A4TTWSWRPJ76RNDPJHSPR",
"http_status": 200
},
"http://localhost:8089/": {
+ "status" : "ok",
"methods": [
{
"type": "question",
@@ -112,7 +117,7 @@
"currency": "TESTKUDOS",
"business_name": "Data loss #4 Inc.",
"storage_limit_in_megabytes": 1,
- "salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
+ "provider_salt": "PN0VJF6KDSBYN40SGRCEXPB07M",
"http_status": 200
}
},
diff --git a/src/cli/setup.sh b/src/cli/setup.sh
new file mode 100755
index 0000000..6d26168
--- /dev/null
+++ b/src/cli/setup.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+# This file is in the public domain
+
+# Script to be inlined into the main test scripts. Defines function 'setup()'
+# which wraps around 'taler-unified-setup.sh' to launch GNU Taler services.
+# Call setup() with the arguments to pass to 'taler-unified-setup'. setup()
+# will then launch GNU Taler, wait for the process to be complete before
+# returning. The script will also install an exit handler to ensure the GNU
+# Taler processes are stopped when the shell exits.
+
+set -eu
+
+# Cleanup to run whenever we exit
+function exit_cleanup()
+{
+ if [ ! -z ${SETUP_PID+x} ]
+ then
+ echo "Killing taler-unified-setup ($SETUP_PID)" >&2
+ kill -TERM "$SETUP_PID" 2> /dev/null || true
+ wait "$SETUP_PID" 2> /dev/null || true
+ fi
+}
+
+# Install cleanup handler (except for kill -9)
+trap exit_cleanup EXIT
+
+function setup()
+{
+ echo "Starting test system ..." >&2
+ # Create a named pipe in a temp directory we own.
+ FIFO_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d fifo-XXXXXX)
+ FIFO_OUT=$(echo "$FIFO_DIR/out")
+ mkfifo "$FIFO_OUT"
+ # Open pipe as FD 3 (RW) and FD 4 (RO)
+ exec 3<> "$FIFO_OUT" 4< "$FIFO_OUT"
+ rm -rf "$FIFO_DIR"
+ # We require '-W' for our termination logic to work.
+ taler-unified-setup.sh -W "$@" >&3 &
+ SETUP_PID=$!
+ # Close FD3
+ exec 3>&-
+ sed -u '/<<READY>>/ q' <&4
+ # Close FD4
+ exec 4>&-
+ echo "Test system ready" >&2
+}
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_fail() {
+ echo "$@" >&2
+ exit 1
+}
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+ echo "SKIPPING: $1"
+ exit 77
+}
+
+function get_payto_uri() {
+ export LIBEUFIN_SANDBOX_USERNAME="$1"
+ export LIBEUFIN_SANDBOX_PASSWORD="$2"
+ export LIBEUFIN_SANDBOX_URL="http://localhost:18082"
+ libeufin-cli sandbox demobank info --bank-account "$1" | jq --raw-output '.paytoUri'
+}
+
+function get_bankaccount_transactions() {
+ export LIBEUFIN_SANDBOX_USERNAME=$1
+ export LIBEUFIN_SANDBOX_PASSWORD=$2
+ export LIBEUFIN_SANDBOX_URL="http://localhost:18082"
+ libeufin-cli sandbox demobank list-transactions --bank-account $1
+}
diff --git a/src/cli/test_anastasis_reducer_1.conf b/src/cli/test_anastasis_reducer_1.conf
index 3a05690..2a3a0e4 100644
--- a/src/cli/test_anastasis_reducer_1.conf
+++ b/src/cli/test_anastasis_reducer_1.conf
@@ -3,7 +3,7 @@
[anastasis]
PORT = 8086
-SERVER_SALT = AUfO1KGOKYIFlFQg
+PROVIDER_SALT = AUfO1KGOKYIFlFQg
BUSINESS_NAME = "Data loss #1 Inc."
[stasis-postgres]
diff --git a/src/cli/test_anastasis_reducer_2.conf b/src/cli/test_anastasis_reducer_2.conf
index 4eef5f0..71b133f 100644
--- a/src/cli/test_anastasis_reducer_2.conf
+++ b/src/cli/test_anastasis_reducer_2.conf
@@ -3,7 +3,7 @@
[anastasis]
PORT = 8087
-SERVER_SALT = BUfO1KGOKYIFlFQg
+PROVIDER_SALT = BUfO1KGOKYIFlFQg
BUSINESS_NAME = "Data loss #2 Inc."
[stasis-postgres]
diff --git a/src/cli/test_anastasis_reducer_3.conf b/src/cli/test_anastasis_reducer_3.conf
index 08f4700..47233ff 100644
--- a/src/cli/test_anastasis_reducer_3.conf
+++ b/src/cli/test_anastasis_reducer_3.conf
@@ -3,7 +3,7 @@
[anastasis]
PORT = 8088
-SERVER_SALT = CUfO1KGOKYIFlFQg
+PROVIDER_SALT = CUfO1KGOKYIFlFQg
BUSINESS_NAME = "Data loss #3 Inc."
[stasis-postgres]
diff --git a/src/cli/test_anastasis_reducer_4.conf b/src/cli/test_anastasis_reducer_4.conf
index dee90e3..f515a78 100644
--- a/src/cli/test_anastasis_reducer_4.conf
+++ b/src/cli/test_anastasis_reducer_4.conf
@@ -3,7 +3,7 @@
[anastasis]
PORT = 8089
-SERVER_SALT = DUfO1KGOKYIFlFQg
+PROVIDER_SALT = DUfO1KGOKYIFlFQg
BUSINESS_NAME = "Data loss #4 Inc."
[stasis-postgres]
diff --git a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
index b8662e8..8a04b0a 100755
--- a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
@@ -126,16 +126,6 @@ fi
echo "OK"
-echo -n "Test user attributes collection in a recovery state ..."
-anastasis-reducer -a \
- '{"identity_attributes": {
- "full_name": "Max Musterman",
- "sq_number": "4",
- "birthdate": "2000-01-01"}}' \
- enter_user_attributes resources/02-recovery.json $TFILE 2> /dev/null && exit_fail "Expected recovery to fail due to lacking policy data"
-
-echo "OK"
-
rm -f $TFILE
exit 0
diff --git a/src/cli/test_anastasis_reducer_done_authentication.sh b/src/cli/test_anastasis_reducer_done_authentication.sh
index 87c738c..545c733 100755
--- a/src/cli/test_anastasis_reducer_done_authentication.sh
+++ b/src/cli/test_anastasis_reducer_done_authentication.sh
@@ -46,9 +46,9 @@ echo " OK"
echo -n "Test done authentication (next) ..."
-anastasis-reducer next resources/04-backup.json $TFILE
+anastasis-reducer next resources/04-backup.json "$TFILE"
-STATE=`jq -r -e .backup_state < $TFILE`
+STATE=$(jq -r -e .backup_state < "$TFILE")
if test "$STATE" != "POLICIES_REVIEWING"
then
exit_fail "Expected new state to be AUTHENTICATIONS_EDITING, got $STATE"
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh b/src/cli/test_anastasis_reducer_enter_secret.sh
index 8005f08..3b25537 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -1,6 +1,7 @@
#!/bin/bash
# This file is in the public domain.
+# shellcheck disable=SC2317
## Coloring style Text shell script
COLOR='\033[0;35m'
NOCOLOR='\033[0m'
@@ -9,46 +10,22 @@ NORM="$(tput sgr0)"
set -eu
-# Exit, with status code "skip" (no 'real' failure)
-function exit_skip() {
- echo " SKIP: $1"
- exit 77
-}
-
-# Exit, with error message (hard failure)
-function exit_fail() {
- echo " FAIL: $1"
- exit 1
-}
-
-# Cleanup to run whenever we exit
-function cleanup()
-{
- for n in `jobs -p`
- do
- kill $n 2> /dev/null || true
- done
- rm -rf $CONF $WALLET_DB $TFILE $UFILE $TMP_DIR
- wait
-}
-
-CONF_1="test_anastasis_reducer_1.conf"
-CONF_2="test_anastasis_reducer_2.conf"
-CONF_3="test_anastasis_reducer_3.conf"
-CONF_4="test_anastasis_reducer_4.conf"
-
-# Exchange configuration file will be edited, so we create one
-# from the template.
-CONF=`mktemp test_reducerXXXXXX.conf`
-cp test_reducer.conf $CONF
-
-TMP_DIR=`mktemp -d keys-tmp-XXXXXX`
-WALLET_DB=`mktemp test_reducer_walletXXXXXX.json`
-TFILE=`mktemp test_reducer_statePPXXXXXX`
-UFILE=`mktemp test_reducer_stateBFXXXXXX`
-
-# Install cleanup handler (except for kill -9)
-trap cleanup EXIT
+# Replace with 0 for nexus...
+USE_FAKEBANK=1
+if [ 1 = "$USE_FAKEBANK" ]
+then
+ ACCOUNT="exchange-account-2"
+ WIRE_METHOD="x-taler-bank"
+ BANK_FLAGS="-f -d $WIRE_METHOD -u $ACCOUNT"
+ BANK_URL="http://localhost:18082/"
+ MERCHANT_PAYTO="payto://x-taler-bank/localhost/anastasis?receiver-name=anastasis"
+else
+ ACCOUNT="exchange-account-1"
+ WIRE_METHOD="iban"
+ BANK_FLAGS="-ns -d $WIRE_METHOD -u $ACCOUNT"
+ BANK_URL="http://localhost:18082/"
+ MERCHANT_PAYTO="payto://iban/SANDBOXX/DE648226?receiver-name=anastasis"
+fi
# Check we can actually run
echo -n "Testing for jq"
@@ -63,9 +40,6 @@ taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange required"
taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant required"
echo " FOUND"
-echo -n "Testing for taler-bank-manage"
-taler-bank-manage --help >/dev/null </dev/null || exit_skip " MISSING"
-echo " FOUND"
echo -n "Testing for taler-wallet-cli"
taler-wallet-cli -v >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
@@ -74,87 +48,65 @@ echo -n "Testing for anastasis-httpd"
anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
-echo -n "Initialize anastasis database ..."
-# Name of the Postgres database we will use for the script.
-# Will be dropped, do NOT use anything that might be used
-# elsewhere
-TARGET_DB_1=`anastasis-config -c $CONF_1 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-TARGET_DB_2=`anastasis-config -c $CONF_2 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-TARGET_DB_3=`anastasis-config -c $CONF_3 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-TARGET_DB_4=`anastasis-config -c $CONF_4 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-
-dropdb $TARGET_DB_1 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_1 || exit_skip "Could not create database $TARGET_DB_1"
-anastasis-dbinit -c $CONF_1 2> anastasis-dbinit_1.log
-dropdb $TARGET_DB_2 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_2 || exit_skip "Could not create database $TARGET_DB_2"
-anastasis-dbinit -c $CONF_2 2> anastasis-dbinit_2.log
-dropdb $TARGET_DB_3 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_3 || exit_skip "Could not create database $TARGET_DB_3"
-anastasis-dbinit -c $CONF_3 2> anastasis-dbinit_3.log
-dropdb $TARGET_DB_4 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_4 || exit_skip "Could not create database $TARGET_DB_4"
-anastasis-dbinit -c $CONF_4 2> anastasis-dbinit_4.log
+. setup.sh
+# Launch exchange, merchant and bank.
+# shellcheck disable=SC2086
+setup -c "test_reducer.conf" \
+ -aemw \
+ $BANK_FLAGS
-echo " OK"
-echo -n "Generating Taler auditor, exchange and merchant configurations ..."
-
-DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
-rm -rf $DATA_DIR
-
-# obtain key configuration data
-MASTER_PRIV_FILE=`taler-config -f -c $CONF -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE"`
-MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
-mkdir -p $MASTER_PRIV_DIR
-gnunet-ecc -g1 $MASTER_PRIV_FILE > /dev/null 2> /dev/null
-MASTER_PUB=`gnunet-ecc -p $MASTER_PRIV_FILE`
-EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
-MERCHANT_PORT=`taler-config -c $CONF -s MERCHANT -o PORT`
-MERCHANT_URL=http://localhost:${MERCHANT_PORT}/
-BANK_PORT=`taler-config -c $CONF -s BANK -o HTTP_PORT`
-BANK_URL=http://localhost:${BANK_PORT}/
-AUDITOR_URL=http://localhost:8083/
-AUDITOR_PRIV_FILE=`taler-config -f -c $CONF -s AUDITOR -o AUDITOR_PRIV_FILE`
-AUDITOR_PRIV_DIR=`dirname $AUDITOR_PRIV_FILE`
-mkdir -p $AUDITOR_PRIV_DIR
-gnunet-ecc -g1 $AUDITOR_PRIV_FILE > /dev/null 2> /dev/null
-AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
-
-# patch configuration
-TALER_DB=talercheck
-taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
-taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
-taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
-taler-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
-taler-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
+# Cleanup to run whenever we exit
+function cleanup()
+{
+ exit_cleanup
+ for n in $(jobs -p)
+ do
+ kill "$n" 2> /dev/null || true
+ done
+ rm -rf "$CONF" "$WALLET_DB" "$TFILE" "$UFILE" "$TMP_DIR"
+ wait
+}
-echo " OK"
+CONF_1="test_anastasis_reducer_1.conf"
+CONF_2="test_anastasis_reducer_2.conf"
+CONF_3="test_anastasis_reducer_3.conf"
+CONF_4="test_anastasis_reducer_4.conf"
-echo -n "Setting up exchange ..."
+# Exchange configuration file will be edited, so we create one
+# from the template.
+CONF="test_reducer.conf.edited"
-# reset database
-dropdb $TALER_DB >/dev/null 2>/dev/null || true
-createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
-taler-exchange-dbinit -c $CONF
-taler-merchant-dbinit -c $CONF
-taler-auditor-dbinit -c $CONF
-taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
+TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d keys-tmp-XXXXXX)
+WALLET_DB=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_walletXXXXXX.json)
+TFILE=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_statePPXXXXXX)
+UFILE=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_stateBFXXXXXX)
-echo " OK"
+# Install cleanup handler (except for kill -9)
+trap cleanup EXIT
-# Launch services
-echo -n "Launching taler services ..."
-taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > taler-bank.log 2> taler-bank.err &
-taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log &
-taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log &
-taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
-taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
-taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
-taler-auditor-httpd -L INFO -c $CONF 2> taler-auditor-httpd.log &
+
+echo -n "Initialize anastasis databases ..."
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB_1=$(anastasis-config -c "$CONF_1" -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+TARGET_DB_2=$(anastasis-config -c "$CONF_2" -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+TARGET_DB_3=$(anastasis-config -c "$CONF_3" -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+TARGET_DB_4=$(anastasis-config -c "$CONF_4" -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+
+dropdb "$TARGET_DB_1" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_1" || exit_skip "Could not create database $TARGET_DB_1"
+anastasis-dbinit -c "$CONF_1" 2> anastasis-dbinit_1.log
+dropdb "$TARGET_DB_2" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_2" || exit_skip "Could not create database $TARGET_DB_2"
+anastasis-dbinit -c "$CONF_2" 2> anastasis-dbinit_2.log
+dropdb "$TARGET_DB_3" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_3" || exit_skip "Could not create database $TARGET_DB_3"
+anastasis-dbinit -c "$CONF_3" 2> anastasis-dbinit_3.log
+dropdb "$TARGET_DB_4" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_4" || exit_skip "Could not create database $TARGET_DB_4"
+anastasis-dbinit -c "$CONF_4" 2> anastasis-dbinit_4.log
echo " OK"
@@ -165,82 +117,9 @@ $PREFIX anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
$PREFIX anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
$PREFIX anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
-# Wait for bank to be available (usually the slowest)
-for n in `seq 1 50`
-do
- echo -n "."
- sleep 0.2
- OK=0
- # bank
- wget --tries=1 --timeout=1 http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
-done
-
-if [ 1 != $OK ]
-then
- exit_skip "Failed to launch services (bank)"
-fi
-
-# Wait for all other taler services to be available
-for n in `seq 1 50`
-do
- echo -n "."
- sleep 0.1
- OK=0
- # exchange
- wget --tries=1 --timeout=1 http://localhost:8081/seed -o /dev/null -O /dev/null >/dev/null || continue
- # merchant
- wget --tries=1 --timeout=1 http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
- # auditor
- wget --tries=1 --timeout=1 http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
-done
-
-if [ 1 != $OK ]
-then
- exit_skip "Failed to launch taler services"
-fi
-
-echo "OK"
-
-echo -n "Setting up keys ..."
-taler-exchange-offline -c $CONF \
- download \
- sign \
- enable-account payto://x-taler-bank/localhost/Exchange \
- enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
- wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 \
- upload &> taler-exchange-offline.log
-
-echo -n "."
-
-for n in `seq 1 3`
-do
- echo -n "."
- OK=0
- wget --tries=1 --timeout=1 http://localhost:8081/keys -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
-done
-
-if [ 1 != $OK ]
-then
- exit_skip "Failed to setup keys"
-fi
-
-echo " OK"
-
-echo -n "Setting up auditor signatures ..."
-taler-auditor-offline -c $CONF \
- download sign upload &> taler-auditor-offline.log
-echo " OK"
-
echo -n "Waiting for anastasis services ..."
-
# Wait for anastasis services to be available
-for n in `seq 1 50`
+for n in $(seq 1 50)
do
echo -n "."
sleep 0.1
@@ -257,7 +136,7 @@ do
break
done
-if [ 1 != $OK ]
+if [ 1 != "$OK" ]
then
exit_skip "Failed to launch anastasis services"
fi
@@ -266,154 +145,193 @@ echo "OK"
echo -n "Configuring merchant instance ..."
# Setup merchant
-curl -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/management/instances
+curl -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' http://localhost:9966/management/instances
+
+
+curl -H "Content-Type: application/json" -X POST -d '{"payto_uri":"'"$MERCHANT_PAYTO"'"}' http://localhost:9966/private/accounts
+
echo " DONE"
-echo -en $COLOR$BOLD"Test enter secret in a backup state ..."$NORM$NOCOLOR
+echo -en "${COLOR}${BOLD}Test enter secret in a backup state ...${NORM}${NOCOLOR}"
$PREFIX anastasis-reducer -a \
'{"secret": { "value" : "veryhardtoguesssecret", "mime" : "text/plain" } }' \
- enter_secret resources/06-backup.json $TFILE
+ enter_secret resources/06-backup.json "$TFILE"
-STATE=`jq -r -e .backup_state < $TFILE`
-if test "$STATE" != "SECRET_EDITING"
+STATE=$(jq -r -e .backup_state < "$TFILE")
+if [ "$STATE" != "SECRET_EDITING" ]
then
- jq -e . $TFILE
+ jq -e . "$TFILE"
exit_fail "Expected new state to be 'SECRET_EDITING', got '$STATE'"
fi
echo " DONE"
-echo -en $COLOR$BOLD"Test expiration change ..."$NORM$NOCOLOR
+echo -en "${COLOR}${BOLD}Test expiration change ...${NORM}${NOCOLOR}"
-MILLIS=`date '+%s'`000
+SECS=$(date '+%s')
# Use 156 days into the future to get 1 year
-MILLIS=`expr $MILLIS + 13478400000`
+SECS=$(( SECS + 13478400 ))
$PREFIX anastasis-reducer -a \
"$(jq -n '
- {"expiration": { "t_ms" : $MSEC } }' \
- --argjson MSEC $MILLIS
+ {"expiration": { "t_s" : $SEC } }' \
+ --argjson SEC "$SECS"
)" \
- update_expiration $TFILE $UFILE
+ update_expiration "$TFILE" "$UFILE"
-STATE=`jq -r -e .backup_state < $UFILE`
+STATE=$(jq -r -e .backup_state < "$UFILE")
if test "$STATE" != "SECRET_EDITING"
then
- jq -e . $UFILE
+ jq -e . "$UFILE"
exit_fail "Expected new state to be 'SECRET_EDITING', got '$STATE'"
fi
-FEES=`jq -r -e '.upload_fees[0].fee' < $UFILE`
+FEES=$(jq -r -e '.upload_fees[0].fee' < "$UFILE")
# 4x 4.99 for annual fees, plus 4x0.01 for truth uploads
-if test "$FEES" != "TESTKUDOS:20"
+if [ "$FEES" != "TESTKUDOS:20" ]
then
- jq -e . $TFILE
+ jq -e . "$UFILE"
exit_fail "Expected upload fees to be 'TESTKUDOS:20', got '$FEES'"
fi
echo " DONE"
-echo -en $COLOR$BOLD"Test advance to payment ..."$NORM$NOCOLOR
+echo -en "${COLOR}${BOLD}Test advance to payment ...${NORM}${NOCOLOR}"
-$PREFIX anastasis-reducer next $UFILE $TFILE
+$PREFIX anastasis-reducer next "$UFILE" "$TFILE"
-STATE=`jq -r -e .backup_state < $TFILE`
-if test "$STATE" != "TRUTHS_PAYING"
+STATE=$(jq -r -e .backup_state < "$TFILE")
+if [ "$STATE" != "TRUTHS_PAYING" ]
then
- jq -e . $TFILE
+ jq -e . "$TFILE"
exit_fail "Expected new state to be 'TRUTHS_PAYING', got '$STATE'"
fi
-TMETHOD=`jq -r -e '.policies[0].methods[0].truth.type' < $TFILE`
-if test $TMETHOD != "question"
-then
- exit_fail "Expected method to be >='question', got $TMETHOD"
-fi
+# FIXME: this test is specific to how the
+# C reducer stores state (redundantly!), should converge eventually!
+
+#TMETHOD=$(jq -r -e '.policies[0].methods[0].truth.type' < $TFILE)
+#if test $TMETHOD != "question"
+#then
+# exit_fail "Expected method to be >='question', got $TMETHOD"
+#fi
+#
+#echo " OK"
+
-echo " OK"
#Pay
-echo -en $COLOR$BOLD"Withdrawing amount to wallet ..."$NORM$NOCOLOR
+echo -en "${COLOR}${BOLD}Withdrawing amount to wallet ...${NORM}${NOCOLOR}"
+
+EXCHANGE_URL="$(taler-config -c "$CONF" -s exchange -o BASE_URL)"
-rm $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' \
+rm "$WALLET_DB"
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ api \
+ --expect-success 'withdrawTestBalance' \
"$(jq -n '
{
amount: "TESTKUDOS:40",
- bankBaseUrl: $BANK_URL,
+ corebankApiBaseUrl: $BANK_URL,
exchangeBaseUrl: $EXCHANGE_URL
}' \
- --arg BANK_URL "$BANK_URL" \
- --arg EXCHANGE_URL "$EXCHANGE_URL"
- )" 2>wallet.err >wallet.log
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>wallet.err >wallet.log
+ --arg BANK_URL "${BANK_URL}" \
+ --arg EXCHANGE_URL "${EXCHANGE_URL}"
+ )" 2>wallet-withdraw.err \
+ >wallet-withdraw.log
+taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-withdraw-finish.err \
+ >wallet-withdraw-finish.log
echo " OK"
-echo -en $COLOR$BOLD"Making payments for truth uploads ... "$NORM$NOCOLOR
-OBJECT_SIZE=`jq -r -e '.payments | length' < $TFILE`
-for ((INDEX=0; INDEX < $OBJECT_SIZE; INDEX++))
+echo -en "${COLOR}${BOLD}Making payments for truth uploads ... ${NORM}${NOCOLOR}"
+OBJECT_SIZE=$(jq -r -e '.payments | length' < "$TFILE")
+for ((INDEX=0; INDEX < "$OBJECT_SIZE"; INDEX++))
do
- PAY_URI=`jq --argjson INDEX $INDEX -r -e '.payments[$INDEX]' < $TFILE`
+ PAY_URI=$(jq --argjson INDEX $INDEX -r -e '.payments[$INDEX]' < "$TFILE")
# run wallet CLI
echo -n "$INDEX"
- taler-wallet-cli --wallet-db=$WALLET_DB handle-uri $PAY_URI -y 2>wallet.err >wallet.log
+ taler-wallet-cli \
+ --no-throttle \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "${PAY_URI}" \
+ -y \
+ 2>wallet-pay1.err \
+ >wallet-pay1.log
echo -n ","
done
echo " OK"
-echo -e $COLOR$BOLD"Running wallet run-pending..."$NORM$NOCOLOR
-taler-wallet-cli --wallet-db=$WALLET_DB run-pending 2>wallet.err >wallet.log
-echo -e $COLOR$BOLD"Payments done"$NORM$NOCOLOR
-
-
-echo -en $COLOR$BOLD"Try to upload again ..."$NORM$NOCOLOR
-$PREFIX anastasis-reducer pay $TFILE $UFILE
-mv $UFILE $TFILE
+echo -e "${COLOR}${BOLD}Running wallet run-until-done...${NORM}${NOCOLOR}"
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-pay-finish.err \
+ >wallet-pay-finish.log
+echo -e "${COLOR}${BOLD}Payments done${NORM}${NOCOLOR}"
+
+
+echo -en "${COLOR}${BOLD}Try to upload again ...${NORM}${NOCOLOR}"
+$PREFIX anastasis-reducer pay "$TFILE" "$UFILE"
+mv "$UFILE" "$TFILE"
echo " OK"
-STATE=`jq -r -e .backup_state < $TFILE`
-if test "$STATE" != "POLICIES_PAYING"
+STATE="$(jq -r -e .backup_state < "$TFILE")"
+if [ "$STATE" != "POLICIES_PAYING" ]
then
exit_fail "Expected new state to be 'POLICIES_PAYING', got '$STATE'"
fi
-export TFILE
-export UFILE
-
-echo -en $COLOR$BOLD"Making payments for policy uploads ... "$NORM$NOCOLOR
-OBJECT_SIZE=`jq -r -e '.policy_payment_requests | length' < $TFILE`
-for ((INDEX=0; INDEX < $OBJECT_SIZE; INDEX++))
+echo -en "${COLOR}${BOLD}Making payments for policy uploads ... ${NORM}${NOCOLOR}"
+OBJECT_SIZE="$(jq -r -e '.policy_payment_requests | length' < "$TFILE")"
+for ((INDEX=0; INDEX < "$OBJECT_SIZE"; INDEX++))
do
- PAY_URI=`jq --argjson INDEX $INDEX -r -e '.policy_payment_requests[$INDEX].payto' < $TFILE`
+ PAY_URI="$(jq --argjson INDEX "$INDEX" -r -e '.policy_payment_requests[$INDEX].payto' < "$TFILE")"
# run wallet CLI
export PAY_URI
echo -n "$INDEX"
- taler-wallet-cli --wallet-db=$WALLET_DB handle-uri $PAY_URI -y 2>wallet.err >wallet.log
+ taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "$PAY_URI" \
+ -y \
+ 2>"wallet-pay2-$INDEX.err" \
+ >"wallet-pay2-$INDEX.log"
echo -n ","
done
echo " OK"
-echo -e $COLOR$BOLD"Running wallet run-pending..."$NORM$NOCOLOR
-taler-wallet-cli --wallet-db=$WALLET_DB run-pending 2>wallet.err >wallet.log
-echo -e $COLOR$BOLD"Payments done"$NORM$NOCOLOR
+echo -e "${COLOR}${BOLD}Running wallet run-until-done...${NORM}${NOCOLOR}"
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-pay2-finish.err \
+ >wallet-pay2-finish.log
+echo -e "${COLOR}${BOLD}Payments done${NORM}${NOCOLOR}"
-echo -en $COLOR$BOLD"Try to upload again ..."$NORM$NOCOLOR
-$PREFIX anastasis-reducer pay $TFILE $UFILE
+echo -en "${COLOR}${BOLD}Try to upload again ...${NORM}${NOCOLOR}"
+$PREFIX anastasis-reducer pay "$TFILE" "$UFILE"
echo " OK"
echo -n "Final checks ..."
-STATE=`jq -r -e .backup_state < $UFILE`
-if test "$STATE" != "BACKUP_FINISHED"
+STATE=$(jq -r -e .backup_state < "$UFILE")
+if [ "$STATE" != "BACKUP_FINISHED" ]
then
exit_fail "Expected new state to be BACKUP_FINISHED, got $STATE"
fi
-jq -r -e .core_secret < $UFILE > /dev/null && exit_fail "'core_secret' was not cleared upon success"
+jq -r -e .core_secret \
+ < "$UFILE" \
+ > /dev/null \
+ && exit_fail "'core_secret' was not cleared upon success"
echo " OK"
-
exit 0
diff --git a/src/cli/test_anastasis_reducer_free_1.conf b/src/cli/test_anastasis_reducer_free_1.conf
new file mode 100644
index 0000000..0e7ad9a
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_free_1.conf
@@ -0,0 +1,10 @@
+# This file is in the public domain.
+@INLINE@ test_reducer_free.conf
+
+[anastasis]
+PORT = 8086
+PROVIDER_SALT = AUfO1KGOKYIFlFQg
+BUSINESS_NAME = "Data loss #1 Inc."
+
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck1
diff --git a/src/cli/test_anastasis_reducer_free_2.conf b/src/cli/test_anastasis_reducer_free_2.conf
new file mode 100644
index 0000000..a628ff4
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_free_2.conf
@@ -0,0 +1,10 @@
+# This file is in the public domain.
+@INLINE@ test_reducer_free.conf
+
+[anastasis]
+PORT = 8087
+PROVIDER_SALT = BUfO1KGOKYIFlFQg
+BUSINESS_NAME = "Data loss #2 Inc."
+
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck2
diff --git a/src/cli/test_anastasis_reducer_free_3.conf b/src/cli/test_anastasis_reducer_free_3.conf
new file mode 100644
index 0000000..adbe392
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_free_3.conf
@@ -0,0 +1,10 @@
+# This file is in the public domain.
+@INLINE@ test_reducer_free.conf
+
+[anastasis]
+PORT = 8088
+PROVIDER_SALT = CUfO1KGOKYIFlFQg
+BUSINESS_NAME = "Data loss #3 Inc."
+
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck3
diff --git a/src/cli/test_anastasis_reducer_free_4.conf b/src/cli/test_anastasis_reducer_free_4.conf
new file mode 100644
index 0000000..cd0c701
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_free_4.conf
@@ -0,0 +1,10 @@
+# This file is in the public domain.
+@INLINE@ test_reducer_free.conf
+
+[anastasis]
+PORT = 8089
+PROVIDER_SALT = DUfO1KGOKYIFlFQg
+BUSINESS_NAME = "Data loss #4 Inc."
+
+[stasis-postgres]
+CONFIG = postgres:///anastasischeck4
diff --git a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
index d65020e..551ab36 100755
--- a/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_recovery_enter_user_attributes.sh
@@ -1,52 +1,26 @@
#!/bin/bash
# This file is in the public domain.
-set -eu
-
-# Exit, with status code "skip" (no 'real' failure)
-function exit_skip() {
- echo " SKIP: $1"
- exit 77
-}
-
-# Exit, with error message (hard failure)
-function exit_fail() {
- echo " FAIL: $1"
- exit 1
-}
-
-# Cleanup to run whenever we exit
-function cleanup()
-{
- for n in `jobs -p`
- do
- kill $n 2> /dev/null || true
- done
- rm -rf $CONF $WALLET_DB $R1FILE $R2FILE $B1FILE $B2FILE $TMP_DIR
- wait
-}
-
+# shellcheck disable=SC2317
-CONF_1="test_anastasis_reducer_1.conf"
-CONF_2="test_anastasis_reducer_2.conf"
-CONF_3="test_anastasis_reducer_3.conf"
-CONF_4="test_anastasis_reducer_4.conf"
-
-
-# Configuration file will be edited, so we create one
-# from the template.
-CONF=`mktemp test_reducerXXXXXX.conf`
-cp test_reducer.conf $CONF
-
-TMP_DIR=`mktemp -d keys-tmp-XXXXXX`
-WALLET_DB=`mktemp test_reducer_walletXXXXXX.json`
-B1FILE=`mktemp test_reducer_stateB1XXXXXX`
-B2FILE=`mktemp test_reducer_stateB2XXXXXX`
-R1FILE=`mktemp test_reducer_stateR1XXXXXX`
-R2FILE=`mktemp test_reducer_stateR2XXXXXX`
+set -eu
-# Install cleanup handler (except for kill -9)
-trap cleanup EXIT
+# Replace with 0 for nexus...
+USE_FAKEBANK=1
+if [ 1 = "$USE_FAKEBANK" ]
+then
+ ACCOUNT="exchange-account-2"
+ WIRE_METHOD="x-taler-bank"
+ BANK_FLAGS="-f -d $WIRE_METHOD -u $ACCOUNT"
+ BANK_URL="http://localhost:18082/"
+ MERCHANT_PAYTO="payto://x-taler-bank/localhost/anastasis?receiver-name=anastasis"
+else
+ ACCOUNT="exchange-account-1"
+ WIRE_METHOD="iban"
+ BANK_FLAGS="-ns -d $WIRE_METHOD -u $ACCOUNT"
+ BANK_URL="http://localhost:18082/"
+ MERCHANT_PAYTO="payto://iban/SANDBOXX/DE648226?receiver-name=anastasis"
+fi
# Check we can actually run
echo -n "Testing for jq"
@@ -61,9 +35,6 @@ taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange required"
taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant required"
echo " FOUND"
-echo -n "Testing for taler-bank-manage"
-taler-bank-manage --help >/dev/null </dev/null || exit_skip " MISSING"
-echo " FOUND"
echo -n "Testing for taler-wallet-cli"
taler-wallet-cli -v >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
@@ -72,173 +43,117 @@ echo -n "Testing for anastasis-httpd"
anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
-echo -n "Initialize anastasis database ..."
-# Name of the Postgres database we will use for the script.
-# Will be dropped, do NOT use anything that might be used
-# elsewhere
-TARGET_DB_1=`anastasis-config -c $CONF_1 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-TARGET_DB_2=`anastasis-config -c $CONF_2 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-TARGET_DB_3=`anastasis-config -c $CONF_3 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-TARGET_DB_4=`anastasis-config -c $CONF_4 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-
-dropdb $TARGET_DB_1 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_1 || exit_skip "Could not create database $TARGET_DB_1"
-anastasis-dbinit -c $CONF_1 2> anastasis-dbinit_1.log
-dropdb $TARGET_DB_2 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_2 || exit_skip "Could not create database $TARGET_DB_2"
-anastasis-dbinit -c $CONF_2 2> anastasis-dbinit_2.log
-dropdb $TARGET_DB_3 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_3 || exit_skip "Could not create database $TARGET_DB_3"
-anastasis-dbinit -c $CONF_3 2> anastasis-dbinit_3.log
-dropdb $TARGET_DB_4 >/dev/null 2>/dev/null || true
-createdb $TARGET_DB_4 || exit_skip "Could not create database $TARGET_DB_4"
-anastasis-dbinit -c $CONF_4 2> anastasis-dbinit_4.log
+. setup.sh
+# Launch exchange, merchant and bank.
+# shellcheck disable=SC2086
+setup -c "test_reducer.conf" \
+ -aemw \
+ $BANK_FLAGS
-echo " OK"
+# Cleanup to run whenever we exit
+function cleanup()
+{
+ exit_cleanup
+ for n in $(jobs -p)
+ do
+ kill "$n" 2> /dev/null || true
+ done
+ rm -rf "$CONF" "$WALLET_DB" "$R1FILE" "$R2FILE" "$B1FILE" "$B2FILE" "$TMP_DIR"
+ wait
+}
-echo -n "Generating Taler auditor, exchange and merchant configurations ..."
-
-DATA_DIR=`taler-config -f -c $CONF -s PATHS -o TALER_HOME`
-rm -rf $DATA_DIR
-
-# obtain key configuration data
-MASTER_PRIV_FILE=`taler-config -f -c $CONF -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE"`
-MASTER_PRIV_DIR=`dirname $MASTER_PRIV_FILE`
-mkdir -p $MASTER_PRIV_DIR
-gnunet-ecc -g1 $MASTER_PRIV_FILE > /dev/null 2> /dev/null
-MASTER_PUB=`gnunet-ecc -p $MASTER_PRIV_FILE`
-EXCHANGE_URL=`taler-config -c $CONF -s EXCHANGE -o BASE_URL`
-MERCHANT_PORT=`taler-config -c $CONF -s MERCHANT -o PORT`
-MERCHANT_URL=http://localhost:${MERCHANT_PORT}/
-BANK_PORT=`taler-config -c $CONF -s BANK -o HTTP_PORT`
-BANK_URL=http://localhost:${BANK_PORT}/
-AUDITOR_URL=http://localhost:8083/
-AUDITOR_PRIV_FILE=`taler-config -f -c $CONF -s AUDITOR -o AUDITOR_PRIV_FILE`
-AUDITOR_PRIV_DIR=`dirname $AUDITOR_PRIV_FILE`
-mkdir -p $AUDITOR_PRIV_DIR
-gnunet-ecc -g1 $AUDITOR_PRIV_FILE > /dev/null 2> /dev/null
-AUDITOR_PUB=`gnunet-ecc -p $AUDITOR_PRIV_FILE`
-
-# patch configuration
-TALER_DB=talercheck
-taler-config -c $CONF -s exchange -o MASTER_PUBLIC_KEY -V $MASTER_PUB
-taler-config -c $CONF -s merchant-exchange-default -o MASTER_KEY -V $MASTER_PUB
-taler-config -c $CONF -s exchangedb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s auditordb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s merchantdb-postgres -o CONFIG -V postgres:///$TALER_DB
-taler-config -c $CONF -s bank -o database -V postgres:///$TALER_DB
-taler-config -c $CONF -s exchange -o KEYDIR -V "${TMP_DIR}/keydir/"
-taler-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
+function sync_providers() {
+ infile=$1
+ outfile=$2
+ echo "Synchronizing providers"
+ # Sync with providers (up to 3 providers aren't synced here)
+ for x in 1 2 3; do
+ echo "Synchronizing providers (round $x)"
+ anastasis-reducer sync_providers < "$infile" > "$outfile" 2> /dev/null || true
+ CODE=$(jq -r -e ".code // 0" < "$outfile")
+ # ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED
+ # FIXME: Temporary workaround for C reducer. See #7227.
+ if [ "$CODE" = "8420" ]
+ then
+ # restore previous non-error state
+ cat "$infile" > "$outfile"
+ break
+ fi
+ # ANASTASIS_REDUCER_ACTION_INVALID
+ if [ "$CODE" = "8400" ]
+ then
+ # restore previous non-error state
+ cat "$infile" > "$outfile"
+ break
+ fi
+ if [ "$CODE" != "0" ]
+ then
+ exit_fail "Expected no error or 8420/8400, got $CODE"
+ fi
+ cat "$outfile" > "$infile"
+ done
+ echo "Providers synced."
+}
-echo " OK"
-echo -n "Setting up exchange ..."
+CONF_1="test_anastasis_reducer_1.conf"
+CONF_2="test_anastasis_reducer_2.conf"
+CONF_3="test_anastasis_reducer_3.conf"
+CONF_4="test_anastasis_reducer_4.conf"
-# reset database
-dropdb $TALER_DB >/dev/null 2>/dev/null || true
-createdb $TALER_DB || exit_skip "Could not create database $TALER_DB"
-taler-exchange-dbinit -c $CONF
-taler-merchant-dbinit -c $CONF
-taler-auditor-dbinit -c $CONF
-taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
-echo " OK"
+# Configuration file will be edited, so we create one
+# from the template.
+CONF="$(mktemp -p "${TMPDIR:-/tmp}" test_reducerXXXXXX.conf)"
+cp test_reducer.conf "$CONF"
-# Launch services
-echo -n "Launching taler services ..."
-taler-bank-manage-testing $CONF postgres:///$TALER_DB serve > taler-bank.log 2> taler-bank.err &
-taler-exchange-secmod-eddsa -c $CONF 2> taler-exchange-secmod-eddsa.log &
-taler-exchange-secmod-rsa -c $CONF 2> taler-exchange-secmod-rsa.log &
-taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
-taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
-taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
-taler-auditor-httpd -L INFO -c $CONF 2> taler-auditor-httpd.log &
+TMP_DIR=$(mktemp -p "${TMPDIR:-/tmp}" -d keys-tmp-XXXXXX)
+WALLET_DB=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_walletXXXXXX.json)
+B1FILE=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_stateB1XXXXXX)
+B2FILE=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_stateB2XXXXXX)
+R1FILE=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_stateR1XXXXXX)
+R2FILE=$(mktemp -p "${TMPDIR:-/tmp}" test_reducer_stateR2XXXXXX)
+
+# Install cleanup handler (except for kill -9)
+trap cleanup EXIT
+
+echo -n "Initialize anastasis database ..."
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB_1=$(anastasis-config -c $CONF_1 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+TARGET_DB_2=$(anastasis-config -c $CONF_2 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+TARGET_DB_3=$(anastasis-config -c $CONF_3 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+TARGET_DB_4=$(anastasis-config -c $CONF_4 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+
+dropdb "$TARGET_DB_1" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_1" || exit_skip "Could not create database $TARGET_DB_1"
+anastasis-dbinit -c "$CONF_1" 2> anastasis-dbinit_1.log
+dropdb "$TARGET_DB_2" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_2" || exit_skip "Could not create database $TARGET_DB_2"
+anastasis-dbinit -c "$CONF_2" 2> anastasis-dbinit_2.log
+dropdb "$TARGET_DB_3" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_3" || exit_skip "Could not create database $TARGET_DB_3"
+anastasis-dbinit -c "$CONF_3" 2> anastasis-dbinit_3.log
+dropdb "$TARGET_DB_4" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB_4" || exit_skip "Could not create database $TARGET_DB_4"
+anastasis-dbinit -c "$CONF_4" 2> anastasis-dbinit_4.log
echo " OK"
echo -n "Launching anastasis services ..."
PREFIX="" #valgrind
-$PREFIX anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
-$PREFIX anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
-$PREFIX anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
-$PREFIX anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
-
-# Wait for bank to be available (usually the slowest)
-for n in `seq 1 50`
-do
- echo -n "."
- sleep 0.2
- OK=0
- # bank
- wget --tries=1 --timeout=1 http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
-done
-
-if [ 1 != $OK ]
-then
- exit_skip "Failed to launch services (bank)"
-fi
-
-# Wait for all other taler services to be available
-for n in `seq 1 50`
-do
- echo -n "."
- sleep 0.1
- OK=0
- # exchange
- wget --tries=1 --timeout=1 http://localhost:8081/seed -o /dev/null -O /dev/null >/dev/null || continue
- # merchant
- wget --tries=1 --timeout=1 http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
- # auditor
- wget --tries=1 --timeout=1 http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
-done
-
-if [ 1 != $OK ]
-then
- exit_skip "Failed to launch taler services"
-fi
+$PREFIX anastasis-httpd -c "$CONF_1" 2> anastasis-httpd_1.log &
+$PREFIX anastasis-httpd -c "$CONF_2" 2> anastasis-httpd_2.log &
+$PREFIX anastasis-httpd -c "$CONF_3" 2> anastasis-httpd_3.log &
+$PREFIX anastasis-httpd -c "$CONF_4" 2> anastasis-httpd_4.log &
echo "OK"
-echo -n "Setting up keys ..."
-taler-exchange-offline -c $CONF \
- download \
- sign \
- enable-account payto://x-taler-bank/localhost/Exchange \
- enable-auditor $AUDITOR_PUB $AUDITOR_URL "TESTKUDOS Auditor" \
- wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 \
- upload &> taler-exchange-offline.log
-
-echo -n "."
-
-for n in `seq 1 3`
-do
- echo -n "."
- OK=0
- wget --tries=1 --timeout=1 http://localhost:8081/keys -o /dev/null -O /dev/null >/dev/null || continue
- OK=1
- break
-done
-
-if [ 1 != $OK ]
-then
- exit_skip "Failed to setup keys"
-fi
-
-echo " OK"
-
-echo -n "Setting up auditor signatures ..."
-taler-auditor-offline -c $CONF \
- download sign upload &> taler-auditor-offline.log
-echo " OK"
-
echo -n "Waiting for anastasis services ..."
# Wait for anastasis services to be available
-for n in `seq 1 50`
+for n in $(seq 1 50)
do
echo -n "."
sleep 0.1
@@ -255,7 +170,7 @@ do
break
done
-if [ 1 != $OK ]
+if [ 1 != "$OK" ]
then
exit_skip "Failed to launch anastasis services"
fi
@@ -264,29 +179,32 @@ echo "OK"
echo -n "Configuring merchant instance ..."
# Setup merchant
-curl -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/management/instances
+curl -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"id":"default","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 3600000000},"default_pay_delay":{"d_us": 3600000000}}' http://localhost:9966/management/instances
+curl -H "Content-Type: application/json" -X POST -d '{"payto_uri":"'"$MERCHANT_PAYTO"'"}' http://localhost:9966/private/accounts
echo " DONE"
echo -n "Running backup logic ...,"
-anastasis-reducer -b > $B1FILE
+anastasis-reducer -b > "$B1FILE"
echo -n "."
anastasis-reducer -a \
- '{"continent": "Testcontinent"}' \
- select_continent < $B1FILE > $B2FILE
+ '{"continent": "Demoworld"}' \
+ select_continent < "$B1FILE" > "$B2FILE"
echo -n "."
anastasis-reducer -a \
- '{"country_code": "xx",
- "currencies":["TESTKUDOS"]}' \
- select_country < $B2FILE > $B1FILE
+ '{"country_code": "xx"}' \
+ select_country < "$B2FILE" > "$B1FILE"
echo -n "."
anastasis-reducer -a \
'{"identity_attributes": {
"full_name": "Max Musterman",
"sq_number": "4",
"birthdate": "2000-01-01"}}' \
- enter_user_attributes < $B1FILE > $B2FILE
+ enter_user_attributes < "$B1FILE" > "$B2FILE"
+cat "$B2FILE" > "$B1FILE"
+echo -n ","
+sync_providers "$B1FILE" "$B2FILE"
echo -n ","
# "91GPWWR" encodes "Hans"
anastasis-reducer -a \
@@ -295,7 +213,7 @@ anastasis-reducer -a \
"instructions": "What is your name?",
"challenge": "91GPWWR"
} }' \
- add_authentication < $B2FILE > $B1FILE
+ add_authentication < "$B2FILE" > "$B1FILE"
echo -n "."
# "64S36" encodes "123"
anastasis-reducer -a \
@@ -304,7 +222,7 @@ anastasis-reducer -a \
"instructions": "How old are you?",
"challenge": "64S36"
} }' \
- add_authentication < $B1FILE > $B2FILE
+ add_authentication < "$B1FILE" > "$B2FILE"
echo -n "."
# "9NGQ4WR" encodes "Mars"
anastasis-reducer -a \
@@ -313,149 +231,177 @@ anastasis-reducer -a \
"instructions": "Where do you live?",
"challenge": "9NGQ4WR"
} }' \
- add_authentication < $B2FILE > $B1FILE
+ add_authentication < "$B2FILE" > "$B1FILE"
echo -n "."
# Finished adding authentication methods
anastasis-reducer \
- next < $B1FILE > $B2FILE
+ next < "$B1FILE" > "$B2FILE"
echo -n ","
# Finished policy review
anastasis-reducer \
- next < $B2FILE > $B1FILE
+ next < "$B2FILE" > "$B1FILE"
echo -n "."
# Note: 'secret' must here be a Crockford base32-encoded value
anastasis-reducer -a \
'{"secret": { "value" : "VERYHARDT0GVESSSECRET", "mime" : "text/plain" }}' \
- enter_secret < $B1FILE > $B2FILE
-mv $B2FILE $B1FILE
-anastasis-reducer next $B1FILE $B2FILE
+ enter_secret < "$B1FILE" > "$B2FILE"
+mv "$B2FILE" "$B1FILE"
+anastasis-reducer next "$B1FILE" "$B2FILE"
echo " OK"
echo -n "Preparing wallet"
-rm $WALLET_DB
-taler-wallet-cli --no-throttle --wallet-db=$WALLET_DB api 'withdrawTestBalance' \
+
+EXCHANGE_URL="$(taler-config -c "$CONF" -s exchange -o BASE_URL)"
+
+rm -f "$WALLET_DB"
+taler-wallet-cli --no-throttle --wallet-db="$WALLET_DB" api --expect-success 'withdrawTestBalance' \
"$(jq -n '
{
amount: "TESTKUDOS:100",
- bankBaseUrl: $BANK_URL,
+ corebankApiBaseUrl: $BANK_URL,
exchangeBaseUrl: $EXCHANGE_URL
}' \
- --arg BANK_URL "$BANK_URL" \
+ --arg BANK_URL "${BANK_URL}" \
--arg EXCHANGE_URL "$EXCHANGE_URL"
- )" 2> /dev/null >/dev/null
-taler-wallet-cli --wallet-db=$WALLET_DB run-until-done 2>/dev/null >/dev/null
+ )" 2> wallet-withdraw.err > wallet-withdraw.out
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-withdraw-finish.err \
+ >wallet-withdraw-finish.out
echo " OK"
echo -en "Making payments for truth uploads ... "
-OBJECT_SIZE=`jq -r -e '.payments | length' < $B2FILE`
-for ((INDEX=0; INDEX < $OBJECT_SIZE; INDEX++))
+OBJECT_SIZE=$(jq -r -e '.payments | length' < "$B2FILE")
+for ((INDEX=0; INDEX < "$OBJECT_SIZE"; INDEX++))
do
- PAY_URI=`jq --argjson INDEX $INDEX -r -e '.payments[$INDEX]' < $B2FILE`
+ PAY_URI=$(jq --argjson INDEX $INDEX -r -e '.payments[$INDEX]' < "$B2FILE")
# run wallet CLI
echo -n "$INDEX"
- taler-wallet-cli --wallet-db=$WALLET_DB handle-uri $PAY_URI -y 2>/dev/null >/dev/null
+ taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "$PAY_URI" \
+ -y \
+ 2>"wallet-pay-truth-$INDEX.err" \
+ >"wallet-pay-truth-$INDEX.out"
echo -n ", "
done
echo "OK"
-echo -e "Running wallet run-pending..."
-taler-wallet-cli --wallet-db=$WALLET_DB run-pending 2>/dev/null >/dev/null
+echo -e "Running wallet run-until-done..."
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>"wallet-pay-truth-finish-$INDEX.err" \
+ >"wallet-pay-truth-finish-$INDEX.out"
echo -e "Payments done"
-export B2FILE
-export B1FILE
-
echo -en "Try to upload again ..."
-$PREFIX anastasis-reducer pay $B2FILE $B1FILE
-mv $B1FILE $B2FILE
+$PREFIX anastasis-reducer pay "$B2FILE" "$B1FILE"
+mv "$B1FILE" "$B2FILE"
echo " OK"
echo -en "Making payments for policy uploads ... "
-OBJECT_SIZE=`jq -r -e '.policy_payment_requests | length' < $B2FILE`
-for ((INDEX=0; INDEX < $OBJECT_SIZE; INDEX++))
+OBJECT_SIZE=$(jq -r -e '.policy_payment_requests | length' < "$B2FILE")
+for ((INDEX=0; INDEX < "$OBJECT_SIZE"; INDEX++))
do
- PAY_URI=`jq --argjson INDEX $INDEX -r -e '.policy_payment_requests[$INDEX].payto' < $B2FILE`
+ PAY_URI=$(jq --argjson INDEX $INDEX -r -e '.policy_payment_requests[$INDEX].payto' < "$B2FILE")
# run wallet CLI
echo -n "$INDEX"
- taler-wallet-cli --wallet-db=$WALLET_DB handle-uri $PAY_URI -y 2>/dev/null >/dev/null
+ taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ handle-uri "$PAY_URI" \
+ -y \
+ 2>"wallet-pay-policy-$INDEX.err" \
+ >"wallet-pay-policy-$INDEX.out"
echo -n ", "
done
echo " OK"
-echo -en "Running wallet run-pending..."
-taler-wallet-cli --wallet-db=$WALLET_DB run-pending 2>/dev/null >/dev/null
+echo -en "Running wallet run-until-done..."
+taler-wallet-cli \
+ --wallet-db="$WALLET_DB" \
+ run-until-done \
+ 2>wallet-pay-policy-finish.err \
+ >wallet-pay-policy-finish.out
echo -e " payments DONE"
echo -en "Try to upload again ..."
anastasis-reducer \
- pay < $B2FILE > $B1FILE
+ pay < "$B2FILE" > "$B1FILE"
echo " OK: Backup finished"
echo -n "Final backup checks ..."
-STATE=`jq -r -e .backup_state < $B1FILE`
-if test "$STATE" != "BACKUP_FINISHED"
+STATE=$(jq -r -e .backup_state < "$B1FILE")
+if [ "$STATE" != "BACKUP_FINISHED" ]
then
exit_fail "Expected new state to be 'BACKUP_FINISHED', got '$STATE'"
fi
-jq -r -e .core_secret < $B1FILE > /dev/null && exit_fail "'core_secret' was not cleared upon success"
+jq -r -e .core_secret < "$B1FILE" > /dev/null && exit_fail "'core_secret' was not cleared upon success"
echo " OK"
echo -n "Running recovery basic logic ..."
-anastasis-reducer -r > $R1FILE
+anastasis-reducer -r > "$R1FILE"
anastasis-reducer -a \
- '{"continent": "Testcontinent"}' \
- select_continent < $R1FILE > $R2FILE
+ '{"continent": "Demoworld"}' \
+ select_continent < "$R1FILE" > "$R2FILE"
anastasis-reducer -a \
- '{"country_code": "xx",
- "currencies":["TESTKUDOS"]}' \
- select_country < $R2FILE > $R1FILE
-anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < $R1FILE > $R2FILE
+ '{"country_code": "xx"}' \
+ select_country < "$R2FILE" > "$R1FILE"
+anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < "$R1FILE" > "$R2FILE"
-STATE=`jq -r -e .recovery_state < $R2FILE`
-if test "$STATE" != "SECRET_SELECTING"
+STATE=$(jq -r -e .recovery_state < "$R2FILE")
+if [ "$STATE" != "SECRET_SELECTING" ]
then
exit_fail "Expected new state to be 'SECRET_SELECTING', got '$STATE'"
fi
echo " OK"
-echo -n "Selecting default secret"
-mv $R2FILE $R1FILE
-anastasis-reducer next < $R1FILE > $R2FILE
+echo -n "Adding provider (to ensure it is loaded)"
+anastasis-reducer -a '{"provider_url" : "http://localhost:8086/" }' add_provider < "$R2FILE" > "$R1FILE"
+echo " OK"
+
+echo -n "Selecting secret to recover"
+anastasis-reducer -a '{"attribute_mask": 0, "providers" : [ { "version": 1, "url" : "http://localhost:8086/" } ] }' select_version < "$R1FILE" > "$R2FILE"
-STATE=`jq -r -e .recovery_state < $R2FILE`
-if test "$STATE" != "CHALLENGE_SELECTING"
+STATE=$(jq -r -e .recovery_state < "$R2FILE")
+if [ "$STATE" != "CHALLENGE_SELECTING" ]
then
exit_fail "Expected new state to be 'CHALLENGE_SELECTING', got '$STATE'"
fi
echo " OK"
+cat "$R2FILE" > "$R1FILE"
+
+sync_providers "$R1FILE" "$R2FILE"
+
echo -n "Running challenge logic ..."
-UUID0=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
-UUID1=`jq -r -e .recovery_information.challenges[1].uuid < $R2FILE`
-UUID2=`jq -r -e .recovery_information.challenges[2].uuid < $R2FILE`
-UUID0Q=`jq -r -e .recovery_information.challenges[0].instructions < $R2FILE`
-UUID1Q=`jq -r -e .recovery_information.challenges[1].instructions < $R2FILE`
-UUID2Q=`jq -r -e .recovery_information.challenges[2].instructions < $R2FILE`
+UUID0=$(jq -r -e .recovery_information.challenges[0].uuid < "$R2FILE")
+UUID1=$(jq -r -e .recovery_information.challenges[1].uuid < "$R2FILE")
+UUID2=$(jq -r -e .recovery_information.challenges[2].uuid < "$R2FILE")
+#UUID0Q=$(jq -r -e .recovery_information.challenges[0].instructions < "$R2FILE")
+UUID1Q=$(jq -r -e .recovery_information.challenges[1].instructions < "$R2FILE")
+UUID2Q=$(jq -r -e .recovery_information.challenges[2].instructions < "$R2FILE")
-if test "$UUID2Q" = 'How old are you?'
+if [ "$UUID2Q" = 'How old are you?' ]
then
AGE_UUID=$UUID2
-elif test "$UUID1Q" = 'How old are you?'
+elif [ "$UUID1Q" = 'How old are you?' ]
then
AGE_UUID=$UUID1
else
AGE_UUID=$UUID0
fi
-if test "$UUID2Q" = 'What is your name?'
+if [ "$UUID2Q" = 'What is your name?' ]
then
NAME_UUID=$UUID2
-elif test "$UUID1Q" = 'What is your name?'
+elif [ "$UUID1Q" = 'What is your name?' ]
then
NAME_UUID=$UUID1
else
@@ -469,10 +415,10 @@ anastasis-reducer -a \
}' \
--arg UUID "$NAME_UUID"
)" \
- select_challenge < $R2FILE > $R1FILE
+ select_challenge < "$R2FILE" > "$R1FILE"
anastasis-reducer -a '{"answer": "Hans"}' \
- solve_challenge < $R1FILE > $R2FILE
+ solve_challenge < "$R1FILE" > "$R2FILE"
anastasis-reducer -a \
"$(jq -n '
@@ -481,34 +427,34 @@ anastasis-reducer -a \
}' \
--arg UUID "$AGE_UUID"
)" \
- select_challenge < $R2FILE > $R1FILE
+ select_challenge < "$R2FILE" > "$R1FILE"
anastasis-reducer -a '{"answer": "123"}' \
- solve_challenge < $R1FILE > $R2FILE
+ solve_challenge < "$R1FILE" > "$R2FILE"
echo " OK"
echo -n "Checking recovered secret ..."
# finally: check here that we recovered the secret...
-STATE=`jq -r -e .recovery_state < $R2FILE`
-if test "$STATE" != "RECOVERY_FINISHED"
+STATE=$(jq -r -e .recovery_state < "$R2FILE")
+if [ "$STATE" != "RECOVERY_FINISHED" ]
then
- jq -e . $R2FILE
+ jq -e . "$R2FILE"
exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
fi
-SECRET=`jq -r -e .core_secret.value < $R2FILE`
-if test "$SECRET" != "VERYHARDT0GVESSSECRET"
+SECRET=$(jq -r -e .core_secret.value < "$R2FILE")
+if [ "$SECRET" != "VERYHARDT0GVESSSECRET" ]
then
- jq -e . $R2FILE
+ jq -e . "$R2FILE"
exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got '$SECRET'"
fi
-MIME=`jq -r -e .core_secret.mime < $R2FILE`
-if test "$MIME" != "text/plain"
+MIME=$(jq -r -e .core_secret.mime < "$R2FILE")
+if [ "$MIME" != "text/plain" ]
then
- jq -e . $R2FILE
+ jq -e . "$R2FILE"
exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
fi
diff --git a/src/cli/test_anastasis_reducer_recovery_hanging.sh b/src/cli/test_anastasis_reducer_recovery_hanging.sh
new file mode 100755
index 0000000..f67b850
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_recovery_hanging.sh
@@ -0,0 +1,376 @@
+#!/bin/bash
+# This file is in the public domain.
+# Runs tests with a 'hanging' Anastasis provider.
+
+set -eu
+#set -x
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+ echo " SKIP: $1"
+ exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+ echo " FAIL: $1"
+ exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+ for n in `jobs -p`
+ do
+ kill -SIGCONT $n # in case suspended...
+ kill $n 2> /dev/null || true
+ done
+ rm -rf $CONF $R1FILE $R2FILE $B1FILE $B2FILE $TMP_DIR
+ wait
+}
+
+function sync_providers() {
+ infile=$1
+ outfile=$2
+ echo "Synchronizing providers"
+ # Sync with providers (up to 3 providers aren't synced here)
+ for x in 1 2 3; do
+ echo "Synchronizing providers (round $x)"
+ #anastasis-reducer sync_providers < $infile > $outfile 2> /dev/null || true
+ anastasis-reducer sync_providers < $infile > $outfile || true
+ CODE=$(jq -r -e ".code // 0" < $outfile)
+ # ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED
+ # FIXME: Temporary workaround for C reducer. See #7227.
+ if test "$CODE" = "8420"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ # ANASTASIS_REDUCER_ACTION_INVALID
+ if test "$CODE" = "8400"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ if test "$CODE" != "0"; then
+ exit_fail "Expected no error or 8420/8400, got $CODE"
+ fi
+ cat $outfile > $infile
+ done
+ echo "Providers synced."
+}
+
+
+CONF_1="test_anastasis_reducer_free_1.conf"
+CONF_2="test_anastasis_reducer_free_2.conf"
+CONF_3="test_anastasis_reducer_free_3.conf"
+CONF_4="test_anastasis_reducer_free_4.conf"
+
+
+# Configuration file will be edited, so we create one
+# from the template.
+CONF=`mktemp test_reducerXXXXXX.conf`
+cp test_reducer.conf $CONF
+
+TMP_DIR=`mktemp -d keys-tmp-XXXXXX`
+B1FILE=`mktemp test_reducer_stateB1XXXXXX`
+B2FILE=`mktemp test_reducer_stateB2XXXXXX`
+R1FILE=`mktemp test_reducer_stateR1XXXXXX`
+R2FILE=`mktemp test_reducer_stateR2XXXXXX`
+export B1FILE
+export B2FILE
+export R1FILE
+export R2FILE
+
+# Install cleanup handler (except for kill -9)
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+echo -n "Testing for timeout"
+timeout --help > /dev/null || exit_skip "timeout required"
+echo " FOUND"
+echo -n "Testing for anastasis-reducer ..."
+anastasis-reducer -h > /dev/null || exit_skip "anastasis-reducer required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+echo -n "Initialize anastasis database ..."
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB_1=`anastasis-config -c $CONF_1 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+TARGET_DB_2=`anastasis-config -c $CONF_2 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+TARGET_DB_3=`anastasis-config -c $CONF_3 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+TARGET_DB_4=`anastasis-config -c $CONF_4 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+
+dropdb $TARGET_DB_1 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_1 || exit_skip "Could not create database $TARGET_DB_1"
+anastasis-dbinit -c $CONF_1 2> anastasis-dbinit_1.log
+dropdb $TARGET_DB_2 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_2 || exit_skip "Could not create database $TARGET_DB_2"
+anastasis-dbinit -c $CONF_2 2> anastasis-dbinit_2.log
+dropdb $TARGET_DB_3 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_3 || exit_skip "Could not create database $TARGET_DB_3"
+anastasis-dbinit -c $CONF_3 2> anastasis-dbinit_3.log
+dropdb $TARGET_DB_4 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_4 || exit_skip "Could not create database $TARGET_DB_4"
+anastasis-dbinit -c $CONF_4 2> anastasis-dbinit_4.log
+
+echo " OK"
+
+echo -n "Launching anastasis services ..."
+PREFIX="" #valgrind
+$PREFIX anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
+PPID_1=$!
+$PREFIX anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
+PPID_2=$!
+$PREFIX anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
+PPID_3=$!
+$PREFIX anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
+PPID_4=$!
+export PPID_1
+export PPID_2
+export PPID_3
+export PPID_4
+
+echo -n "Waiting for anastasis services ..."
+
+# Wait for anastasis services to be available
+for n in `seq 1 50`
+do
+ echo -n "."
+ sleep 0.1
+ OK=0
+ # anastasis_01
+ wget --tries=1 --timeout=1 http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || continue
+ # anastasis_02
+ wget --tries=1 --timeout=1 http://localhost:8087/ -o /dev/null -O /dev/null >/dev/null || continue
+ # anastasis_03
+ wget --tries=1 --timeout=1 http://localhost:8088/ -o /dev/null -O /dev/null >/dev/null || continue
+ # anastasis_04
+ wget --tries=1 --timeout=1 http://localhost:8089/ -o /dev/null -O /dev/null >/dev/null || continue
+ OK=1
+ break
+done
+
+if [ 1 != $OK ]
+then
+ exit_skip "Failed to launch anastasis services"
+fi
+echo "OK"
+
+echo -n "Running backup logic ...,"
+anastasis-reducer -b > $B1FILE
+echo -n "."
+anastasis-reducer -a \
+ '{"continent": "Demoworld"}' \
+ select_continent < $B1FILE > $B2FILE
+echo -n "."
+anastasis-reducer -a \
+ '{"country_code": "xx"}' \
+ select_country < $B2FILE > $B1FILE
+echo -n "."
+
+kill -SIGSTOP $PPID_4
+START=`date '+%s'`
+timeout 10 anastasis-reducer -L DEBUG -a \
+ '{"identity_attributes": {
+ "full_name": "Max Musterman",
+ "sq_number": "4",
+ "birthdate": "2000-01-01"}}' \
+ enter_user_attributes < $B1FILE > $B2FILE || true
+END=`date '+%s'`
+DELTA=`expr $END - $START`
+kill -SIGCONT $PPID_4
+
+if test $DELTA -ge 5
+then
+ exit_fail "Reducer hangs on suspended provider in 'enter_user_attributes'"
+fi
+
+cat $B2FILE > $B1FILE
+echo -n ","
+sync_providers $B1FILE $B2FILE
+echo -n ","
+# "91GPWWR" encodes "Hans"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "What is your name?",
+ "challenge": "91GPWWR"
+ } }' \
+ add_authentication < $B2FILE > $B1FILE
+echo -n "."
+# "64S36" encodes "123"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "How old are you?",
+ "challenge": "64S36"
+ } }' \
+ add_authentication < $B1FILE > $B2FILE
+echo -n "."
+# "9NGQ4WR" encodes "Mars"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "Where do you live?",
+ "challenge": "9NGQ4WR"
+ } }' \
+ add_authentication < $B2FILE > $B1FILE
+echo -n "."
+# Finished adding authentication methods
+anastasis-reducer \
+ next < $B1FILE > $B2FILE
+
+
+echo -n ","
+# Finished policy review
+anastasis-reducer \
+ next < $B2FILE > $B1FILE
+echo -n "."
+
+# Note: 'secret' must here be a Crockford base32-encoded value
+anastasis-reducer -a \
+ '{"secret": { "value" : "VERYHARDT0GVESSSECRET", "mime" : "text/plain" }}' \
+ enter_secret < $B1FILE > $B2FILE
+anastasis-reducer next $B2FILE $B1FILE
+echo " OK"
+
+echo -n "Final backup checks ..."
+STATE=`jq -r -e .backup_state < $B1FILE`
+if test "$STATE" != "BACKUP_FINISHED"
+then
+ exit_fail "Expected new state to be 'BACKUP_FINISHED', got '$STATE'"
+fi
+
+jq -r -e .core_secret < $B1FILE > /dev/null && exit_fail "'core_secret' was not cleared upon success"
+
+echo " OK"
+
+
+echo -n "Running recovery basic logic ..."
+anastasis-reducer -r > $R1FILE
+anastasis-reducer -a \
+ '{"continent": "Demoworld"}' \
+ select_continent < $R1FILE > $R2FILE
+anastasis-reducer -a \
+ '{"country_code": "xx" }' \
+ select_country < $R2FILE > $R1FILE
+anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < $R1FILE > $R2FILE
+
+
+STATE=`jq -r -e .recovery_state < $R2FILE`
+if test "$STATE" != "SECRET_SELECTING"
+then
+ exit_fail "Expected new state to be 'SECRET_SELECTING', got '$STATE'"
+fi
+echo " OK"
+
+echo -n "Adding provider (to ensure it is loaded)"
+anastasis-reducer -a '{"provider_url" : "http://localhost:8086/" }' add_provider < $R2FILE > $R1FILE
+echo " OK"
+
+echo -n "Selecting secret to recover"
+anastasis-reducer -a '{"attribute_mask": 0, "providers" : [ { "version": 1, "url" : "http://localhost:8086/" } ] }' select_version < $R1FILE > $R2FILE
+
+STATE=`jq -r -e .recovery_state < $R2FILE`
+if test "$STATE" != "CHALLENGE_SELECTING"
+then
+ exit_fail "Expected new state to be 'CHALLENGE_SELECTING', got '$STATE'"
+fi
+echo " OK"
+
+cat $R2FILE > $R1FILE
+sync_providers $R1FILE $R2FILE
+
+echo -n "Running challenge logic ..."
+
+cat $R2FILE | jq .
+
+UUID0=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
+UUID1=`jq -r -e .recovery_information.challenges[1].uuid < $R2FILE`
+UUID2=`jq -r -e .recovery_information.challenges[2].uuid < $R2FILE`
+UUID0Q=`jq -r -e .recovery_information.challenges[0].instructions < $R2FILE`
+UUID1Q=`jq -r -e .recovery_information.challenges[1].instructions < $R2FILE`
+UUID2Q=`jq -r -e .recovery_information.challenges[2].instructions < $R2FILE`
+
+if test "$UUID2Q" = 'How old are you?'
+then
+ AGE_UUID=$UUID2
+elif test "$UUID1Q" = 'How old are you?'
+then
+ AGE_UUID=$UUID1
+else
+ AGE_UUID=$UUID0
+fi
+
+if test "$UUID2Q" = 'What is your name?'
+then
+ NAME_UUID=$UUID2
+elif test "$UUID1Q" = 'What is your name?'
+then
+ NAME_UUID=$UUID1
+else
+ NAME_UUID=$UUID0
+fi
+
+anastasis-reducer -a \
+ "$(jq -n '
+ {
+ uuid: $UUID
+ }' \
+ --arg UUID "$NAME_UUID"
+ )" \
+ select_challenge < $R2FILE > $R1FILE
+
+anastasis-reducer -a '{"answer": "Hans"}' \
+ solve_challenge < $R1FILE > $R2FILE
+
+anastasis-reducer -a \
+ "$(jq -n '
+ {
+ uuid: $UUID
+ }' \
+ --arg UUID "$AGE_UUID"
+ )" \
+ select_challenge < $R2FILE > $R1FILE
+
+anastasis-reducer -a '{"answer": "123"}' \
+ solve_challenge < $R1FILE > $R2FILE
+
+echo " OK"
+
+echo -n "Checking recovered secret ..."
+# finally: check here that we recovered the secret...
+
+STATE=`jq -r -e .recovery_state < $R2FILE`
+if test "$STATE" != "RECOVERY_FINISHED"
+then
+ jq -e . $R2FILE
+ exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
+fi
+
+SECRET=`jq -r -e .core_secret.value < $R2FILE`
+if test "$SECRET" != "VERYHARDT0GVESSSECRET"
+then
+ jq -e . $R2FILE
+ exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got '$SECRET'"
+fi
+
+MIME=`jq -r -e .core_secret.mime < $R2FILE`
+if test "$MIME" != "text/plain"
+then
+ jq -e . $R2FILE
+ exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
+fi
+
+echo " OK"
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_recovery_no_pay.sh b/src/cli/test_anastasis_reducer_recovery_no_pay.sh
new file mode 100755
index 0000000..42f5b0c
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_recovery_no_pay.sh
@@ -0,0 +1,351 @@
+#!/bin/bash
+# This file is in the public domain.
+
+set -eu
+set -x
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+ echo " SKIP: $1"
+ exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+ echo " FAIL: $1"
+ exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+ for n in `jobs -p`
+ do
+ kill $n 2> /dev/null || true
+ done
+ rm -rf $CONF $R1FILE $R2FILE $B1FILE $B2FILE $TMP_DIR
+ wait
+}
+
+function sync_providers() {
+ infile=$1
+ outfile=$2
+ echo "Synchronizing providers"
+ # Sync with providers (up to 3 providers aren't synced here)
+ for x in 1 2 3; do
+ echo "Synchronizing providers (round $x)"
+ #anastasis-reducer sync_providers < $infile > $outfile 2> /dev/null || true
+ anastasis-reducer sync_providers < $infile > $outfile || true
+ CODE=$(jq -r -e ".code // 0" < $outfile)
+ # ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED
+ # FIXME: Temporary workaround for C reducer. See #7227.
+ if test "$CODE" = "8420"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ # ANASTASIS_REDUCER_ACTION_INVALID
+ if test "$CODE" = "8400"; then
+ # restore previous non-error state
+ cat $infile > $outfile
+ break
+ fi
+ if test "$CODE" != "0"; then
+ exit_fail "Expected no error or 8420/8400, got $CODE"
+ fi
+ cat $outfile > $infile
+ done
+ echo "Providers synced."
+}
+
+
+CONF_1="test_anastasis_reducer_free_1.conf"
+CONF_2="test_anastasis_reducer_free_2.conf"
+CONF_3="test_anastasis_reducer_free_3.conf"
+CONF_4="test_anastasis_reducer_free_4.conf"
+
+
+# Configuration file will be edited, so we create one
+# from the template.
+CONF=$(mktemp test_reducerXXXXXX.conf)
+cp test_reducer.conf "$CONF"
+
+TMP_DIR=`mktemp -d keys-tmp-XXXXXX`
+B1FILE=`mktemp test_reducer_stateB1XXXXXX`
+B2FILE=`mktemp test_reducer_stateB2XXXXXX`
+R1FILE=`mktemp test_reducer_stateR1XXXXXX`
+R2FILE=`mktemp test_reducer_stateR2XXXXXX`
+export B1FILE
+export B2FILE
+export R1FILE
+export R2FILE
+
+# Install cleanup handler (except for kill -9)
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+echo -n "Testing for anastasis-reducer ..."
+anastasis-reducer -h > /dev/null || exit_skip "anastasis-reducer required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+echo -n "Initialize anastasis database ..."
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB_1=`anastasis-config -c $CONF_1 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+TARGET_DB_2=`anastasis-config -c $CONF_2 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+TARGET_DB_3=`anastasis-config -c $CONF_3 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+TARGET_DB_4=`anastasis-config -c $CONF_4 -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
+
+dropdb $TARGET_DB_1 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_1 || exit_skip "Could not create database $TARGET_DB_1"
+anastasis-dbinit -c $CONF_1 2> anastasis-dbinit_1.log
+dropdb $TARGET_DB_2 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_2 || exit_skip "Could not create database $TARGET_DB_2"
+anastasis-dbinit -c $CONF_2 2> anastasis-dbinit_2.log
+dropdb $TARGET_DB_3 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_3 || exit_skip "Could not create database $TARGET_DB_3"
+anastasis-dbinit -c $CONF_3 2> anastasis-dbinit_3.log
+dropdb $TARGET_DB_4 >/dev/null 2>/dev/null || true
+createdb $TARGET_DB_4 || exit_skip "Could not create database $TARGET_DB_4"
+anastasis-dbinit -c $CONF_4 2> anastasis-dbinit_4.log
+
+echo " OK"
+
+echo -n "Launching anastasis services ..."
+PREFIX="" #valgrind
+$PREFIX anastasis-httpd -L DEBUG -c $CONF_1 2> anastasis-httpd_1.log &
+$PREFIX anastasis-httpd -L DEBUG -c $CONF_2 2> anastasis-httpd_2.log &
+$PREFIX anastasis-httpd -L DEBUG -c $CONF_3 2> anastasis-httpd_3.log &
+$PREFIX anastasis-httpd -L DEBUG -c $CONF_4 2> anastasis-httpd_4.log &
+
+echo -n "Waiting for anastasis services ..."
+
+# Wait for anastasis services to be available
+for n in `seq 1 50`
+do
+ echo -n "."
+ sleep 0.1
+ OK=0
+ # anastasis_01
+ wget --tries=1 --timeout=1 http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null || continue
+ # anastasis_02
+ wget --tries=1 --timeout=1 http://localhost:8087/ -o /dev/null -O /dev/null >/dev/null || continue
+ # anastasis_03
+ wget --tries=1 --timeout=1 http://localhost:8088/ -o /dev/null -O /dev/null >/dev/null || continue
+ # anastasis_04
+ wget --tries=1 --timeout=1 http://localhost:8089/ -o /dev/null -O /dev/null >/dev/null || continue
+ OK=1
+ break
+done
+
+if [ 1 != $OK ]
+then
+ exit_skip "Failed to launch anastasis services"
+fi
+echo "OK"
+
+echo -n "Running backup logic ...,"
+anastasis-reducer -b > $B1FILE
+echo -n "."
+anastasis-reducer -a \
+ '{"continent": "Demoworld"}' \
+ select_continent < $B1FILE > $B2FILE
+echo -n "."
+anastasis-reducer -a \
+ '{"country_code": "xx"}' \
+ select_country < $B2FILE > $B1FILE
+echo -n "."
+anastasis-reducer -a \
+ '{"identity_attributes": {
+ "full_name": "Max Musterman",
+ "sq_number": "4",
+ "birthdate": "2000-01-01"}}' \
+ enter_user_attributes < $B1FILE > $B2FILE
+cat $B2FILE > $B1FILE
+echo -n ","
+sync_providers $B1FILE $B2FILE
+echo -n ","
+# "91GPWWR" encodes "Hans"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "What is your name?",
+ "challenge": "91GPWWR"
+ } }' \
+ add_authentication < $B2FILE > $B1FILE
+echo -n "."
+# "64S36" encodes "123"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "How old are you?",
+ "challenge": "64S36"
+ } }' \
+ add_authentication < $B1FILE > $B2FILE
+echo -n "."
+# "9NGQ4WR" encodes "Mars"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "Where do you live?",
+ "challenge": "9NGQ4WR"
+ } }' \
+ add_authentication < $B2FILE > $B1FILE
+echo -n "."
+# Finished adding authentication methods
+anastasis-reducer \
+ next < $B1FILE > $B2FILE
+
+
+echo -n ","
+# Finished policy review
+anastasis-reducer \
+ next < $B2FILE > $B1FILE
+echo -n "."
+
+# Note: 'secret' must here be a Crockford base32-encoded value
+anastasis-reducer -a \
+ '{"secret": { "value" : "VERYHARDT0GVESSSECRET", "mime" : "text/plain" }}' \
+ enter_secret < $B1FILE > $B2FILE
+anastasis-reducer next $B2FILE $B1FILE
+echo " OK"
+
+echo -n "Final backup checks ..."
+STATE=`jq -r -e .backup_state < $B1FILE`
+if test "$STATE" != "BACKUP_FINISHED"
+then
+ exit_fail "Expected new state to be 'BACKUP_FINISHED', got '$STATE'"
+fi
+
+jq -r -e .core_secret < $B1FILE > /dev/null && exit_fail "'core_secret' was not cleared upon success"
+
+echo " OK"
+
+
+echo -n "Running recovery basic logic ..."
+anastasis-reducer -r > $R1FILE
+anastasis-reducer -a \
+ '{"continent": "Demoworld"}' \
+ select_continent < $R1FILE > $R2FILE
+anastasis-reducer -a \
+ '{"country_code": "xx" }' \
+ select_country < $R2FILE > $R1FILE
+anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < $R1FILE > $R2FILE
+
+
+STATE=`jq -r -e .recovery_state < $R2FILE`
+if test "$STATE" != "SECRET_SELECTING"
+then
+ exit_fail "Expected new state to be 'SECRET_SELECTING', got '$STATE'"
+fi
+echo " OK"
+
+echo -n "Adding provider (to ensure it is loaded)"
+anastasis-reducer -a '{"provider_url" : "http://localhost:8086/" }' add_provider < $R2FILE > $R1FILE
+echo " OK"
+
+echo -n "Selecting secret to recover"
+anastasis-reducer -a '{"attribute_mask": 0, "providers" : [ { "version": 1, "url" : "http://localhost:8086/" } ] }' select_version < $R1FILE > $R2FILE
+
+STATE=`jq -r -e .recovery_state < $R2FILE`
+if test "$STATE" != "CHALLENGE_SELECTING"
+then
+ exit_fail "Expected new state to be 'CHALLENGE_SELECTING', got '$STATE'"
+fi
+echo " OK"
+
+cat $R2FILE > $R1FILE
+sync_providers $R1FILE $R2FILE
+
+echo -n "Running challenge logic ..."
+
+cat $R2FILE | jq .
+
+UUID0=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
+UUID1=`jq -r -e .recovery_information.challenges[1].uuid < $R2FILE`
+UUID2=`jq -r -e .recovery_information.challenges[2].uuid < $R2FILE`
+UUID0Q=`jq -r -e .recovery_information.challenges[0].instructions < $R2FILE`
+UUID1Q=`jq -r -e .recovery_information.challenges[1].instructions < $R2FILE`
+UUID2Q=`jq -r -e .recovery_information.challenges[2].instructions < $R2FILE`
+
+if test "$UUID2Q" = 'How old are you?'
+then
+ AGE_UUID=$UUID2
+elif test "$UUID1Q" = 'How old are you?'
+then
+ AGE_UUID=$UUID1
+else
+ AGE_UUID=$UUID0
+fi
+
+if test "$UUID2Q" = 'What is your name?'
+then
+ NAME_UUID=$UUID2
+elif test "$UUID1Q" = 'What is your name?'
+then
+ NAME_UUID=$UUID1
+else
+ NAME_UUID=$UUID0
+fi
+
+anastasis-reducer -a \
+ "$(jq -n '
+ {
+ uuid: $UUID
+ }' \
+ --arg UUID "$NAME_UUID"
+ )" \
+ select_challenge < $R2FILE > $R1FILE
+
+anastasis-reducer -a '{"answer": "Hans"}' \
+ solve_challenge < $R1FILE > $R2FILE
+
+anastasis-reducer -a \
+ "$(jq -n '
+ {
+ uuid: $UUID
+ }' \
+ --arg UUID "$AGE_UUID"
+ )" \
+ select_challenge < $R2FILE > $R1FILE
+
+anastasis-reducer -a '{"answer": "123"}' \
+ solve_challenge < $R1FILE > $R2FILE
+
+echo " OK"
+
+echo -n "Checking recovered secret ..."
+# finally: check here that we recovered the secret...
+
+STATE=`jq -r -e .recovery_state < $R2FILE`
+if test "$STATE" != "RECOVERY_FINISHED"
+then
+ jq -e . $R2FILE
+ exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
+fi
+
+SECRET=`jq -r -e .core_secret.value < $R2FILE`
+if test "$SECRET" != "VERYHARDT0GVESSSECRET"
+then
+ jq -e . $R2FILE
+ exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got '$SECRET'"
+fi
+
+MIME=`jq -r -e .core_secret.mime < $R2FILE`
+if test "$MIME" != "text/plain"
+then
+ jq -e . $R2FILE
+ exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
+fi
+
+echo " OK"
+
+exit 0
diff --git a/src/cli/test_anastasis_reducer_select_continent.sh b/src/cli/test_anastasis_reducer_select_continent.sh
index 4cd8a84..bd1ce95 100755
--- a/src/cli/test_anastasis_reducer_select_continent.sh
+++ b/src/cli/test_anastasis_reducer_select_continent.sh
@@ -41,7 +41,7 @@ echo " FOUND"
# Test continent selection in a backup state
echo -n "Test continent selection in a backup state ..."
-anastasis-reducer -a '{"continent": "Testcontinent"}' select_continent resources/00-backup.json $TFILE
+anastasis-reducer -a '{"continent": "Demoworld"}' select_continent resources/00-backup.json $TFILE
STATE=`jq -r -e .backup_state < $TFILE`
if test "$STATE" != "COUNTRY_SELECTING"
@@ -49,9 +49,9 @@ then
exit_fail "Expected new state to be COUNTRY_SELECTING, got $STATE"
fi
SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
-if test "$SELECTED_CONTINENT" != "Testcontinent"
+if test "$SELECTED_CONTINENT" != "Demoworld"
then
- exit_fail "Expected selected continent to be Testcontinent, got $SELECTED_CONTINENT"
+ exit_fail "Expected selected continent to be Demoworld, got $SELECTED_CONTINENT"
fi
COUNTRIES=`jq -r -e .countries < $TFILE`
if test "$COUNTRIES" == NULL
@@ -68,7 +68,7 @@ anastasis-reducer -a '{"continent": "Pangaia"}' select_continent resources/00-re
echo " OK"
echo -n "Test continent selection in a recovery state ..."
-anastasis-reducer -a '{"continent": "Testcontinent"}' select_continent resources/00-recovery.json $TFILE
+anastasis-reducer -a '{"continent": "Demoworld"}' select_continent resources/00-recovery.json $TFILE
STATE=`jq -r -e .recovery_state < $TFILE`
if test "$STATE" != "COUNTRY_SELECTING"
@@ -79,12 +79,11 @@ jq -e .countries[0] < $TFILE > /dev/null || exit_fail "Expected new state to inc
jq -e .countries[0].code < $TFILE > /dev/null || exit_fail "Expected new state to include countries with code"
jq -e .countries[0].continent < $TFILE > /dev/null || exit_fail "Expected new state to include countries with continent"
jq -e .countries[0].name < $TFILE > /dev/null || exit_fail "Expected new state to include countries with name"
-jq -e .countries[0].currency < $TFILE > /dev/null || exit_fail "Expected new state to include countries with currency"
SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
-if test "$SELECTED_CONTINENT" != "Testcontinent"
+if test "$SELECTED_CONTINENT" != "Demoworld"
then
- exit_fail "Expected selected continent to be 'Testcontinent', got $SELECTED_CONTINENT"
+ exit_fail "Expected selected continent to be 'Demoworld', got $SELECTED_CONTINENT"
fi
COUNTRIES=`jq -r -e .countries < $TFILE`
@@ -96,7 +95,6 @@ jq -e .countries[0] < $TFILE > /dev/null || exit_fail "Expected new state to inc
jq -e .countries[0].code < $TFILE > /dev/null || exit_fail "Expected new state to include countries with code"
jq -e .countries[0].continent < $TFILE > /dev/null || exit_fail "Expected new state to include countries with continent"
jq -e .countries[0].name < $TFILE > /dev/null || exit_fail "Expected new state to include countries with name"
-jq -e .countries[0].currency < $TFILE > /dev/null || exit_fail "Expected new state to include countries with currency"
echo " OK"
diff --git a/src/cli/test_anastasis_reducer_select_country.sh b/src/cli/test_anastasis_reducer_select_country.sh
index c02f61f..2e18f44 100755
--- a/src/cli/test_anastasis_reducer_select_country.sh
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -63,12 +63,11 @@ jq -e .countries[0] < $TFILE > /dev/null || exit_fail "Expected new state to inc
jq -e .countries[0].code < $TFILE > /dev/null || exit_fail "Expected new state to include countries with code"
jq -e .countries[0].continent < $TFILE > /dev/null || exit_fail "Expected new state to include countries with continent"
jq -e .countries[0].name < $TFILE > /dev/null || exit_fail "Expected new state to include countries with name"
-jq -e .countries[0].currency < $TFILE > /dev/null || exit_fail "Expected new state to include countries with currency"
SELECTED_CONTINENT=`jq -r -e .selected_continent < $TFILE`
if test "$SELECTED_CONTINENT" != "Europe"
then
- exit_fail "Expected selected continent to be 'Testcontinent', got $SELECTED_CONTINENT"
+ exit_fail "Expected selected continent to be 'Europe', got $SELECTED_CONTINENT"
fi
echo " OK"
@@ -84,8 +83,7 @@ echo " OK"
echo -n "Test NX country selection ..."
anastasis-reducer -a \
- '{"country_code": "zz",
- "currencies": ["EUR" ]}' \
+ '{"country_code": "zz"}' \
select_country \
resources/01-backup.json $TFILE 2> /dev/null \
&& exit_fail "Expected selection to fail. Check '$TFILE'"
@@ -95,8 +93,7 @@ echo " OK"
echo -n "Test invalid country selection for continent ..."
anastasis-reducer -a \
- '{"country_code": "de",
- "currencies":["EUR"]}' \
+ '{"country_code": "de"}' \
select_country \
resources/01-backup.json $TFILE 2> /dev/null \
&& exit_fail "Expected selection to fail. Check '$TFILE'"
@@ -106,8 +103,7 @@ echo " OK"
echo -n "Test country selection ..."
anastasis-reducer -a \
- '{"country_code": "xx",
- "currencies":["TESTKUDOS"]}' \
+ '{"country_code": "xx"}' \
select_country resources/01-backup.json $TFILE
STATE=`jq -r -e .backup_state < $TFILE`
@@ -122,12 +118,6 @@ then
exit_fail "Expected selected country to be 'xx', got '$SELECTED_COUNTRY'"
fi
echo -n "."
-SELECTED_CURRENCY=`jq -r -e .currencies[0] < $TFILE`
-if test "$SELECTED_CURRENCY" != "TESTKUDOS"
-then
- exit_fail "Expected selected currency to be 'TESTKUDOS', got '$SELECTED_CURRENCY'"
-fi
-echo -n "."
REQ_ATTRIBUTES=`jq -r -e .required_attributes < $TFILE`
if test "$REQ_ATTRIBUTES" == NULL
then
diff --git a/src/cli/test_free_reducer.conf b/src/cli/test_free_reducer.conf
index 74954cd..8308537 100644
--- a/src/cli/test_free_reducer.conf
+++ b/src/cli/test_free_reducer.conf
@@ -11,7 +11,7 @@ UPLOAD_LIMIT_MB = 1
ANNUAL_POLICY_UPLOAD_LIMIT = 128
INSURANCE = EUR:0
PORT = 8086
-SERVER_SALT = BUfO1KGOKYIFlFQg
+PROVIDER_SALT = BUfO1KGOKYIFlFQg
BUSINESS_NAME = "Data loss Inc."
[stasis]
diff --git a/src/cli/test_iban.sh b/src/cli/test_iban.sh
index c3e858c..207d2d5 100755
--- a/src/cli/test_iban.sh
+++ b/src/cli/test_iban.sh
@@ -1,6 +1,8 @@
#!/bin/bash
+# This file is in the public domain.
set -eu
+#set -x
# Exit, with status code "skip" (no 'real' failure)
function exit_skip() {
@@ -17,38 +19,66 @@ function exit_fail() {
# Cleanup to run whenever we exit
function cleanup()
{
- for n in `jobs -p`
+ for n in $(jobs -p)
do
- kill $n 2> /dev/null || true
+ kill "$n" 2> /dev/null || true
done
- rm -rf $CONF $R1FILE $R2FILE $B1FILE $B2FILE
+ rm -rf "$CONF" "$R1FILE" "$R2FILE" "$B1FILE" "$B2FILE"
wait
}
# $1=ebics username, $2=ebics partner name, $3=person name, $4=sandbox bank account name, $5=iban
function prepare_sandbox_account() {
- echo -n "Activating ebics subscriber $1 at the sandbox ..."
- libeufin-cli \
- sandbox --sandbox-url=$SANDBOX_URL \
- ebicssubscriber create \
- --host-id=$EBICS_HOST \
- --partner-id=$2 \
- --user-id=$1
+ echo -n "Registering $4 to the Sandbox..."
+ export LIBEUFIN_SANDBOX_USERNAME="$4"
+ export LIBEUFIN_SANDBOX_PASSWORD=unused
+ libeufin-cli sandbox --sandbox-url="$SANDBOX_URL" \
+ demobank register --name "$3" --iban "$5"
echo " OK"
- echo -n "Giving a bank account ($4) to $1 ..."
- libeufin-cli \
- sandbox --sandbox-url=$SANDBOX_URL \
- ebicsbankaccount create \
- --iban=$5 \
- --bic="BCMAESM1XXX"\
- --person-name="$3" \
- --account-name=$4 \
- --ebics-user-id=$1 \
- --ebics-host-id=$EBICS_HOST \
- --ebics-partner-id=$2 \
- --currency=$CURRENCY
+ echo -n "Associating a EBICS subscriber to $4..."
+ export LIBEUFIN_SANDBOX_USERNAME=admin
+ libeufin-cli sandbox --sandbox-url="$SANDBOX_URL" demobank new-ebicssubscriber \
+ --host-id "$EBICS_HOST" \
+ --user-id "$1" --partner-id "$2" \
+ --bank-account "$4" # that's a username _and_ a bank account name
echo " OK"
+
+ unset LIBEUFIN_SANDBOX_USERNAME
+ unset LIBEUFIN_SANDBOX_PASSWORD
+}
+
+function sync_providers() {
+ infile="$1"
+ outfile="$2"
+ echo "Synchronizing providers"
+ # Sync with providers (up to 3 providers aren't synced here)
+ for x in 1 2 3; do
+ echo "Synchronizing providers (round $x)"
+ anastasis-reducer sync_providers < "$infile" > "$outfile" 2> /dev/null || true
+ CODE=$(jq -r -e ".code // 0" < $outfile)
+ # ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED
+ # FIXME: Temporary workaround for C reducer. See #7227.
+ if [ "$CODE" = "8420" ]
+ then
+ # restore previous non-error state
+ cp "$infile" "$outfile"
+ break
+ fi
+ # ANASTASIS_REDUCER_ACTION_INVALID
+ if [ "$CODE" = "8400" ]
+ then
+ # restore previous non-error state
+ cp "$infile" "$outfile"
+ break
+ fi
+ if [ "$CODE" != "0" ]
+ then
+ exit_fail "Expected no error or 8420/8400, got $CODE"
+ fi
+ cp "$outfile" "$infile"
+ done
+ echo "Providers synced."
}
@@ -61,13 +91,19 @@ trap cleanup EXIT
# to pass through the Nexus+Ebics layer to issue the payment
# $1 = amount ($CURRENCY:X.Y), $2 = subject.
function wire_transfer_to_anastasis() {
+ echo -n "Initiating wire transfer ..."
libeufin-sandbox make-transaction \
--debit-account=sandbox-account-debit \
- --credit-account=sandbox-account-credit "$1" "$2"
- # Sync nexus with sandbox
- export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME
- export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD
- libeufin-cli accounts fetch-transactions nexus-bankaccount-credit > /dev/null
+ --credit-account=sandbox-account-credit "$1" "$2" &> libeufin-transfer-initiate.out
+ echo " OK"
+ # FIXME-MS: the following command reports that it did not
+ # sync any transactions, even though presumably we just
+ # made one in the one above (which succeeded...)
+ echo -n "Syncing nexus with sandbox ..."
+ export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME"
+ export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD"
+ libeufin-cli accounts fetch-transactions nexus-bankaccount-credit &> libeufin-transfer-fetch.out
+ echo " OK"
}
# $1 = facade base URL. Merely a debug utility.
@@ -82,43 +118,33 @@ function prepare_nexus_account() {
echo -n "Making bank connection $3 ..."
libeufin-cli connections new-ebics-connection \
--ebics-url="${SANDBOX_URL}ebicsweb" \
- --host-id=$EBICS_HOST \
- --partner-id=$2 \
- --ebics-user-id=$1 \
+ --host-id="$EBICS_HOST" \
+ --partner-id="$2" \
+ --ebics-user-id="$1" \
$3 > /dev/null
echo " OK"
echo -n "Connecting $3 ..."
- libeufin-cli connections connect $3 > /dev/null
+ libeufin-cli connections connect "$3" > /dev/null
echo " OK"
echo -n "Importing Sandbox bank account ($5) to Nexus ($4) ..."
- libeufin-cli connections download-bank-accounts $3 > /dev/null
+ libeufin-cli connections download-bank-accounts "$3" > /dev/null
libeufin-cli connections import-bank-account \
- --offered-account-id=$5 --nexus-bank-account-id=$4 $3 > /dev/null
+ --offered-account-id="$5" --nexus-bank-account-id="$4" "$3" > /dev/null
echo " OK"
}
-# $1 = facade name, $2 = bank connection to use, $3 = bank account name
-# local to Nexus
-function prepare_anastasis_facade() {
- echo -n "Creating facade ..."
- libeufin-cli facades new-anastasis-facade \
- --currency=$CURRENCY \
- --facade-name=$1 \
- $2 $3
- echo " OK"
- # No need to setup facade permissions, as the anastasis client
- # is superuser at Nexus.
-}
# Configuration file will be edited, so we create one
# from the template.
-CONF=`mktemp test_free_reducerXXXXXX.conf`
-cp test_free_reducer.conf $CONF
+CONF=$(mktemp test_free_reducerXXXXXX.conf)
+cp test_free_reducer.conf "$CONF"
-B1FILE=`mktemp test_reducer_stateB1XXXXXX`
-B2FILE=`mktemp test_reducer_stateB2XXXXXX`
-R1FILE=`mktemp test_reducer_stateR1XXXXXX`
-R2FILE=`mktemp test_reducer_stateR2XXXXXX`
+
+
+B1FILE=$(mktemp test_reducer_stateB1XXXXXX)
+B2FILE=$(mktemp test_reducer_stateB2XXXXXX)
+R1FILE=$(mktemp test_reducer_stateR1XXXXXX)
+R2FILE=$(mktemp test_reducer_stateR2XXXXXX)
export CONF
export B2FILE
@@ -146,23 +172,40 @@ echo -n "Testing for anastasis-reducer ..."
anastasis-reducer -h > /dev/null || exit_skip "anastasis-reducer required"
echo " FOUND"
-export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/nexus-db-XXXXXX.sqlite)"
-export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/sandbox-db-XXXXXX.sqlite)"
+echo -n "Initialize Anastasis database ..."
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+
+TARGET_DB=$(anastasis-config -c "$CONF" -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///")
+
+dropdb "$TARGET_DB" >/dev/null 2>/dev/null || true
+createdb "$TARGET_DB" || exit_skip "Could not create database $TARGET_DB"
+anastasis-dbinit -c "$CONF" 2> anastasis-dbinit.log
+
+echo " OK"
+
+
+export LIBEUFIN_NEXUS_DB_CONNECTION="postgres:///anastasischeck"
+export LIBEUFIN_SANDBOX_DB_CONNECTION="postgres:///anastasischeck"
NEXUS_URL="http://localhost:5001/"
SANDBOX_URL="http://localhost:5000/"
echo -n "Starting Nexus ..."
libeufin-nexus serve &> nexus.log &
nexus_pid=$!
-if ! curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null; then
+if ! curl -s --retry 5 --retry-connrefused "$NEXUS_URL" > /dev/null; then
exit_skip "Could not launch Nexus"
fi
echo " OK"
+echo -n "Configuring Sandbox..."
+libeufin-sandbox config default &> sandbox-config.log
+echo " OK"
echo -n "Starting Sandbox ..."
-libeufin-sandbox serve &> sandbox.log &
+libeufin-sandbox serve --no-auth &> sandbox-serve.log &
sandbox_pid=$!
-if ! curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null; then
+if ! curl -s --retry 5 --retry-connrefused "$SANDBOX_URL" > /dev/null; then
exit_skip "Could not launch Sandbox"
fi
echo " OK"
@@ -174,11 +217,11 @@ EBICS_HOST="ebicstesthost"
export IBAN_CREDIT="DE89370400440532013000"
export IBAN_DEBIT="FR1420041010050500013M02606"
-echo -n "Preparing Sandbox ..."
+echo -n "Preparing Sandbox (creating the EBICS host) ..."
libeufin-cli \
- sandbox --sandbox-url=$SANDBOX_URL \
+ sandbox --sandbox-url="$SANDBOX_URL" \
ebicshost create \
- --host-id=$EBICS_HOST
+ --host-id="$EBICS_HOST"
echo " OK"
PERSON_CREDIT_NAME="Person Credit"
@@ -189,32 +232,32 @@ prepare_sandbox_account \
ebicspartnerCredit \
"${PERSON_CREDIT_NAME}" \
sandbox-account-credit \
- $IBAN_CREDIT
+ "$IBAN_CREDIT"
prepare_sandbox_account \
ebicsuserDebit \
ebicspartnerDebit \
"Person Debit" \
sandbox-account-debit \
- $IBAN_DEBIT
+ "$IBAN_DEBIT"
echo "Sandbox preparation done"
echo -n "Preparing Nexus ..."
-export LIBEUFIN_NEXUS_URL=$NEXUS_URL
+export LIBEUFIN_NEXUS_URL="$NEXUS_URL"
# Make debit user, will buy Anastasis services.
DEBIT_USERNAME=anastasis-debit-user
DEBIT_PASSWORD=anastasis-debit-password
-libeufin-nexus superuser $DEBIT_USERNAME --password=$DEBIT_PASSWORD
+libeufin-nexus superuser "$DEBIT_USERNAME" --password="$DEBIT_PASSWORD"
echo " OK"
-export LIBEUFIN_NEXUS_USERNAME=$DEBIT_USERNAME
-export LIBEUFIN_NEXUS_PASSWORD=$DEBIT_PASSWORD
+export LIBEUFIN_NEXUS_USERNAME="$DEBIT_USERNAME"
+export LIBEUFIN_NEXUS_PASSWORD="$DEBIT_PASSWORD"
# Make credit user, will be Anastasis client.
CREDIT_USERNAME=anastasis-credit-user
CREDIT_PASSWORD=anastasis-credit-password
echo -n "Create credit user (for anastasis) at Nexus ..."
-libeufin-nexus superuser $CREDIT_USERNAME --password=$CREDIT_PASSWORD
+libeufin-nexus superuser "$CREDIT_USERNAME" --password="$CREDIT_PASSWORD"
echo " OK"
-export LIBEUFIN_NEXUS_USERNAME=$CREDIT_USERNAME
-export LIBEUFIN_NEXUS_PASSWORD=$CREDIT_PASSWORD
+export LIBEUFIN_NEXUS_USERNAME="$CREDIT_USERNAME"
+export LIBEUFIN_NEXUS_PASSWORD="$CREDIT_PASSWORD"
prepare_nexus_account \
ebicsuserCredit \
@@ -225,7 +268,7 @@ prepare_nexus_account \
echo -n "Create facade ..."
libeufin-cli facades new-anastasis-facade \
- --currency=$CURRENCY \
+ --currency="$CURRENCY" \
--facade-name=facade-credit \
bankconnection-credit nexus-bankaccount-credit
echo " OK"
@@ -233,41 +276,29 @@ FACADE_URL=$(libeufin-cli facades list | jq .facades[0].baseUrl | tr -d \")
## Reach facade with: $FACADE_URL + $CREDIT_USERNAME + $CREDIT_PASSWORD
-echo -n "Initialize Anastasis database ..."
-# Name of the Postgres database we will use for the script.
-# Will be dropped, do NOT use anything that might be used
-# elsewhere
-
-TARGET_DB=`anastasis-config -c $CONF -s stasis-postgres -o CONFIG | sed -e "s/^postgres:\/\/\///"`
-
-dropdb $TARGET_DB >/dev/null 2>/dev/null || true
-createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
-anastasis-dbinit -c $CONF 2> anastasis-dbinit.log
-
-echo " OK"
echo -n "Configuring Anastasis IBAN account ..."
-anastasis-config -c $CONF \
+anastasis-config -c "$CONF" \
-s authorization-iban \
-o CREDIT_IBAN \
-V "${IBAN_CREDIT}"
-anastasis-config -c $CONF \
+anastasis-config -c "$CONF" \
-s authorization-iban \
-o BUSINESS_NAME \
-V "${PERSON_CREDIT_NAME}"
-anastasis-config -c $CONF \
+anastasis-config -c "$CONF" \
-s authorization-iban \
-o WIRE_GATEWAY_URL \
-V "${FACADE_URL}"
-anastasis-config -c $CONF \
+anastasis-config -c "$CONF" \
-s authorization-iban \
-o WIRE_GATEWAY_AUTH_METHOD \
-V "basic"
-anastasis-config -c $CONF \
+anastasis-config -c "$CONF" \
-s authorization-iban \
-o USERNAME \
-V "${LIBEUFIN_NEXUS_USERNAME}"
-anastasis-config -c $CONF \
+anastasis-config -c "$CONF" \
-s authorization-iban \
-o PASSWORD \
-V "${LIBEUFIN_NEXUS_PASSWORD}"
@@ -275,12 +306,12 @@ echo " OK"
echo -n "Launching Anastasis service ..."
PREFIX="" #valgrind
-$PREFIX anastasis-httpd -c $CONF -L INFO 2> anastasis-httpd_1.log &
+$PREFIX anastasis-httpd -c "$CONF" -L INFO 2> anastasis-httpd_1.log &
echo " OK"
echo -n "Waiting for Anastasis service ..."
# Wait for Anastasis service to be available
-for n in `seq 1 50`
+for n in $(seq 1 50)
do
echo -n "."
sleep 0.1
@@ -297,16 +328,15 @@ fi
echo "OK"
echo -n "Running backup logic ...,"
-anastasis-reducer -b > $B1FILE
+anastasis-reducer -b > "$B1FILE"
echo -n "."
anastasis-reducer -a \
- '{"continent": "Testcontinent"}' \
- select_continent < $B1FILE > $B2FILE
+ '{"continent": "Demoworld"}' \
+ select_continent < "$B1FILE" > "$B2FILE"
echo -n "."
anastasis-reducer -a \
- '{"country_code": "xx",
- "currencies":["TESTKUDOS"]}' \
- select_country < $B2FILE > $B1FILE 2>> test_reducer.err
+ '{"country_code": "xx" }' \
+ select_country < "$B2FILE" > "$B1FILE" 2>> test_reducer.err
echo -n "."
anastasis-reducer -a \
@@ -314,9 +344,12 @@ anastasis-reducer -a \
"full_name": "Max Musterman",
"sq_number": "4",
"birthdate": "2000-01-01"}}' \
- enter_user_attributes < $B1FILE > $B2FILE 2>> test_reducer.err
+ enter_user_attributes < "$B1FILE" > "$B2FILE" 2>> test_reducer.err
echo -n ","
-BASEIBAN=`echo -n $IBAN_DEBIT | gnunet-base32`
+cat "$B2FILE" > "$B1FILE"
+sync_providers "$B1FILE" "$B2FILE"
+echo -n ","
+BASEIBAN=$(echo -n $IBAN_DEBIT | gnunet-base32)
anastasis-reducer -a \
"$(jq -n '{ authentication_method: {
type: "iban",
@@ -325,67 +358,102 @@ anastasis-reducer -a \
} }' \
--arg CHALLENGE "$BASEIBAN"
)" \
- add_authentication < $B2FILE > $B1FILE 2>> test_reducer.err
+ add_authentication < "$B2FILE" > "$B1FILE" 2>> test_reducer.err
+echo -n "."
+
+# "91GPWWR" encodes "Hans"
+anastasis-reducer -a \
+ '{"authentication_method": {
+ "type": "question",
+ "instructions": "What is your name?",
+ "challenge": "91GPWWR"
+ } }' \
+ add_authentication < "$B1FILE" > "$B2FILE" 2>> test_reducer.err
echo -n "."
+
+mv "$B2FILE" "$B1FILE"
+
# Finished adding authentication methods
anastasis-reducer \
- next < $B1FILE > $B2FILE 2>> test_reducer.err
+ next < "$B1FILE" > "$B2FILE" 2>> test_reducer.err
echo -n ","
# Finished policy review
anastasis-reducer \
- next < $B2FILE > $B1FILE 2>> test_reducer.err
+ next < "$B2FILE" > "$B1FILE" 2>> test_reducer.err
echo -n "."
# Note: 'secret' must here be a Crockford base32-encoded value
anastasis-reducer -a \
'{"secret": { "value" : "VERYHARDT0GVESSSECRET", "mime" : "text/plain" }}' \
- enter_secret < $B1FILE > $B2FILE 2>> test_reducer.err
-mv $B2FILE $B1FILE
-anastasis-reducer next < $B1FILE > $B2FILE 2>> test_reducer.err
+ enter_secret < "$B1FILE" > "$B2FILE" 2>> test_reducer.err
+mv "$B2FILE" "$B1FILE"
+anastasis-reducer next < "$B1FILE" > "$B2FILE" 2>> test_reducer.err
echo " OK"
echo -n "Final backup checks ..."
-STATE=`jq -r -e .backup_state < $B2FILE`
-if test "$STATE" != "BACKUP_FINISHED"
+STATE=$(jq -r -e .backup_state < "$B2FILE")
+if [ "$STATE" != "BACKUP_FINISHED" ]
then
exit_fail "Expected new state to be 'BACKUP_FINISHED', got '$STATE'"
fi
-jq -r -e .core_secret < $B2FILE > /dev/null && exit_fail "'core_secret' was not cleared upon success"
+jq -r -e .core_secret < "$B2FILE" > /dev/null && exit_fail "'core_secret' was not cleared upon success"
echo " OK"
echo -n "Running recovery basic logic ..."
-anastasis-reducer -r > $R1FILE
+anastasis-reducer -r > "$R1FILE"
anastasis-reducer -a \
- '{"continent": "Testcontinent"}' \
- select_continent < $R1FILE > $R2FILE
+ '{"continent": "Demoworld"}' \
+ select_continent < "$R1FILE" > "$R2FILE"
anastasis-reducer -a \
'{"country_code": "xx",
"currencies":["TESTKUDOS"]}' \
- select_country < $R2FILE > $R1FILE 2>> test_reducer.err
-anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < $R1FILE > $R2FILE 2>> test_reducer.err
+ select_country < "$R2FILE" > "$R1FILE" 2>> test_reducer.err
+anastasis-reducer -a '{"identity_attributes": { "full_name": "Max Musterman", "sq_number": "4", "birthdate": "2000-01-01" }}' enter_user_attributes < "$R1FILE" > "$R2FILE" 2>> test_reducer.err
-STATE=`jq -r -e .recovery_state < $R2FILE`
-if test "$STATE" != "SECRET_SELECTING"
+STATE=$(jq -r -e .recovery_state < "$R2FILE")
+if [ "$STATE" != "SECRET_SELECTING" ]
then
exit_fail "Expected new state to be 'SECRET_SELECTING', got '$STATE'"
fi
echo " OK"
-echo -n "Selecting default secret"
-mv $R2FILE $R1FILE
-anastasis-reducer next < $R1FILE > $R2FILE 2>> test_reducer.err
+echo -n "Adding provider (to ensure it is loaded)"
+anastasis-reducer -a '{"provider_url" : "http://localhost:8086/" }' add_provider < "$R2FILE" > "$R1FILE"
+echo " OK"
+
+echo -n "Selecting secret to recover"
+anastasis-reducer -a '{"attribute_mask": 0, "providers" : [ { "version": 1, "url" : "http://localhost:8086/" } ] }' \
+ select_version < "$R1FILE" > "$R2FILE" 2>> test_reducer.err
-STATE=`jq -r -e .recovery_state < $R2FILE`
-if test "$STATE" != "CHALLENGE_SELECTING"
+STATE=$(jq -r -e .recovery_state < "$R2FILE")
+if [ "$STATE" != "CHALLENGE_SELECTING" ]
then
exit_fail "Expected new state to be 'CHALLENGE_SELECTING', got '$STATE'"
fi
echo " OK"
+cp "$R2FILE" "$R1FILE"
+sync_providers "$R1FILE" "$R2FILE"
+
echo -n "Running challenge selection logic ..."
-NAME_UUID=`jq -r -e .recovery_information.challenges[0].uuid < $R2FILE`
+UUID0=$(jq -r -e .recovery_information.challenges[0].uuid < "$R2FILE")
+UUID1=$(jq -r -e .recovery_information.challenges[1].uuid < "$R2FILE")
+UUID0Q=$(jq -r -e .recovery_information.challenges[0].instructions < "$R2FILE")
+UUID1Q=$(jq -r -e .recovery_information.challenges[1].instructions < "$R2FILE")
+
+if [ "$UUID1Q" = 'What is your name?' ]
+then
+ NAME_UUID=$UUID1
+ IBAN_UUID=$UUID0
+else
+ NAME_UUID=$UUID0
+ IBAN_UUID=$UUID1
+fi
+
+echo "OK"
+echo -n "Solving first challenge ..."
anastasis-reducer -a \
"$(jq -n '
{
@@ -393,64 +461,79 @@ anastasis-reducer -a \
}' \
--arg UUID "$NAME_UUID"
)" \
- select_challenge < $R2FILE > $R1FILE 2>> test_reducer.err
+ select_challenge < "$R2FILE" > "$R1FILE" 2>> test_reducer.err
+
+anastasis-reducer -a '{"answer": "Hans"}' \
+ solve_challenge < "$R1FILE" > "$R2FILE"
echo "OK"
+echo -n "Solving IBAN challenge ..."
+
+anastasis-reducer -a \
+ "$(jq -n '
+ {
+ uuid: $UUID
+ }' \
+ --arg UUID "$IBAN_UUID"
+ )" \
+ select_challenge < "$R2FILE" > "$R1FILE" 2>> test_reducer.err
+echo "OK"
+
-METHOD=`jq -r -e .challenge_feedback.\"$NAME_UUID\".method < $R1FILE`
-if test "$METHOD" != "iban"
+METHOD=$(jq -r -e .challenge_feedback.\"$IBAN_UUID\".state < "$R1FILE")
+if [ "$METHOD" != "iban-instructions" ]
then
- exit_fail "Expected method to be 'iban', got ${METHOD}"
+ exit_fail "Expected method to be 'iban-instructions', got ${METHOD}"
fi
-ACC=`jq -r -e .challenge_feedback.\"$NAME_UUID\".details.credit_iban < $R1FILE`
-if test "$ACC" != ${IBAN_CREDIT}
+ACC=$(jq -r -e .challenge_feedback.\"$IBAN_UUID\".target_iban < "$R1FILE")
+if [ "$ACC" != "${IBAN_CREDIT}" ]
then
exit_fail "Expected account to be ${IBAN_CREDIT}, got ${ACC}"
fi
anastasis-reducer \
- back < $R1FILE > $R2FILE 2>> test_reducer.err
+ back < "$R1FILE" > "$R2FILE" 2>> test_reducer.err
-AMOUNT=`jq -r -e .challenge_feedback.\"$NAME_UUID\".details.challenge_amount < $R1FILE`
-SUBJECT=`jq -r -e .challenge_feedback.\"$NAME_UUID\".details.wire_transfer_subject < $R1FILE`
+AMOUNT=$(jq -r -e .challenge_feedback.\"$IBAN_UUID\".challenge_amount < "$R1FILE")
+SUBJECT=$(jq -r -e .challenge_feedback.\"$IBAN_UUID\".wire_transfer_subject < "$R1FILE")
-echo -n "Performing authorization wire transfer ..."
+echo -n "Performing authorization wire transfer ${SUBJECT} ..."
wire_transfer_to_anastasis "${AMOUNT}" "${SUBJECT}"
echo " OK"
echo -n "Triggering inbound check ..."
-anastasis-helper-authorization-iban -c $CONF -t
+anastasis-helper-authorization-iban -c "$CONF" -t -L INFO
echo " OK"
# Now we should get the secret...
echo -n "Polling for recovery ..."
-anastasis-reducer poll < $R2FILE > $R1FILE
+anastasis-reducer poll -L INFO < "$R2FILE" > "$R1FILE"
echo " OK"
echo -n "Checking recovered secret ..."
# finally: check here that we recovered the secret...
-STATE=`jq -r -e .recovery_state < $R1FILE`
-if test "$STATE" != "RECOVERY_FINISHED"
+STATE=$(jq -r -e .recovery_state < "$R1FILE")
+if [ "$STATE" != "RECOVERY_FINISHED" ]
then
- jq -e . $R1FILE
+ jq -e . "$R1FILE"
exit_fail "Expected new state to be 'RECOVERY_FINISHED', got '$STATE'"
fi
-SECRET=`jq -r -e .core_secret.value < $R1FILE`
-if test "$SECRET" != "VERYHARDT0GVESSSECRET"
+SECRET=$(jq -r -e .core_secret.value < "$R1FILE")
+if [ "$SECRET" != "VERYHARDT0GVESSSECRET" ]
then
- jq -e . $R1FILE
+ jq -e . "$R1FILE"
exit_fail "Expected recovered secret to be 'VERYHARDT0GVESSSECRET', got '$SECRET'"
fi
-MIME=`jq -r -e .core_secret.mime < $R1FILE`
-if test "$MIME" != "text/plain"
+MIME=$(jq -r -e .core_secret.mime < "$R1FILE")
+if [ "$MIME" != "text/plain" ]
then
- jq -e . $R1FILE
+ jq -e . "$R1FILE"
exit_fail "Expected recovered mime to be 'text/plain', got '$MIME'"
fi
diff --git a/src/cli/test_reducer.conf b/src/cli/test_reducer.conf
index df68b14..4f26a79 100644
--- a/src/cli/test_reducer.conf
+++ b/src/cli/test_reducer.conf
@@ -26,9 +26,10 @@ COST = TESTKUDOS:0.0
[exchange]
+MASTER_PUBLIC_KEY = 3NX5DJDBD8XVGZYHV3PBF8C3Z4GK48XD59YY5GF3CZE8AJM04WSG
+AML_THRESHOLD = TESTKUDOS:1000000
MAX_KEYS_CACHING = forever
DB = postgres
-MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
SERVE = tcp
UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
UNIXPATH_MODE = 660
@@ -39,26 +40,40 @@ SIGNKEY_LEGAL_DURATION = 2 years
LEGAL_DURATION = 2 years
LOOKAHEAD_SIGN = 3 weeks 1 day
LOOKAHEAD_PROVIDE = 2 weeks 1 day
-KEYDIR = ${TALER_DATA_HOME}/exchange/live-keys/
-REVOCATION_DIR = ${TALER_DATA_HOME}/exchange/revocations/
TERMS_ETAG = 0
PRIVACY_ETAG = 0
+STEFAN_ABS = "TESTKUDOS:5"
+
+# Account of the EXCHANGE
+[exchange-account-1]
+# What is the exchange's bank account (with the "Taler Bank" demo system)?
+PAYTO_URI = payto://iban/SANDBOXX/DE989651?receiver-name=Exchange+Company
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+
+[exchange-accountcredentials-1]
+WIRE_GATEWAY_URL = http://localhost:18082/accounts/exchange/taler-wire-gateway/
+WIRE_GATEWAY_AUTH_METHOD = basic
+USERNAME = exchange
+PASSWORD = x
+
+
+[exchange-account-2]
+PAYTO_URI = "payto://x-taler-bank/localhost/exchange?receiver-name=exchange"
+ENABLE_DEBIT = YES
+ENABLE_CREDIT = YES
+
+[exchange-accountcredentials-2]
+WIRE_GATEWAY_AUTH_METHOD = none
+WIRE_GATEWAY_URL = "http://localhost:18082/accounts/exchange/taler-wire-gateway/"
[merchant]
SERVE = tcp
PORT = 9966
UNIXPATH = ${TALER_RUNTIME_DIR}/merchant.http
UNIXPATH_MODE = 660
-DEFAULT_WIRE_FEE_AMORTIZATION = 1
DB = postgres
-WIREFORMAT = default
-# Set very low, so we can be sure that the database generated
-# will contain wire transfers "ready" for the aggregator.
-WIRE_TRANSFER_DELAY = 1 minute
-DEFAULT_PAY_DEADLINE = 1 day
-DEFAULT_MAX_DEPOSIT_FEE = TESTKUDOS:0.1
KEYFILE = ${TALER_DATA_HOME}/merchant/merchant.priv
-DEFAULT_MAX_WIRE_FEE = TESTKUDOS:0.10
# Ensure that merchant reports EVERY deposit confirmation to auditor
FORCE_AUDIT = YES
@@ -79,30 +94,41 @@ BASE_URL = "http://localhost:8083/"
DATABASE = postgres:///taler-auditor-basedb
MAX_DEBT = TESTKUDOS:50.0
MAX_DEBT_BANK = TESTKUDOS:100000.0
-HTTP_PORT = 8082
+HTTP_PORT = 18082
SUGGESTED_EXCHANGE = http://localhost:8081/
SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost/2
ALLOW_REGISTRATIONS = YES
SERVE = http
+[libeufin-bank]
+CURRENCY = TESTKUDOS
+WIRE_TYPE = iban
+IBAN_PAYTO_BIC = SANDBOXX
+DEFAULT_CUSTOMER_DEBT_LIMIT = TESTKUDOS:200
+DEFAULT_ADMIN_DEBT_LIMIT = TESTKUDOS:2000
+REGISTRATION_BONUS_ENABLED = yes
+REGISTRATION_BONUS = TESTKUDOS:100
+SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/
+SERVE = tcp
+PORT = 18082
+
[exchangedb]
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
LEGAL_RESERVE_EXPIRATION_TIME = 7 years
-[exchange-account-1]
-PAYTO_URI = payto://x-taler-bank/localhost/Exchange
-enable_debit = yes
-enable_credit = yes
+[auditordb-postgres]
+CONFIG = "postgres:///talercheck"
-[exchange-accountcredentials-1]
-WIRE_GATEWAY_URL = "http://localhost:8082/taler-wire-gateway/Exchange/"
-WIRE_GATEWAY_AUTH_METHOD = basic
-USERNAME = Exchange
-PASSWORD = x
+[exchangedb-postgres]
+CONFIG = "postgres:///talercheck"
+
+[merchantdb-postgres]
+CONFIG = "postgres:///talercheck"
[merchant-exchange-default]
EXCHANGE_BASE_URL = http://localhost:8081/
CURRENCY = TESTKUDOS
+MASTER_KEY = 3NX5DJDBD8XVGZYHV3PBF8C3Z4GK48XD59YY5GF3CZE8AJM04WSG
[payments-generator]
currency = TESTKUDOS
@@ -123,6 +149,7 @@ fee_deposit = TESTKUDOS:0.01
fee_refresh = TESTKUDOS:0.01
fee_refund = TESTKUDOS:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_ct_10]
value = TESTKUDOS:0.10
@@ -134,6 +161,7 @@ fee_deposit = TESTKUDOS:0.01
fee_refresh = TESTKUDOS:0.03
fee_refund = TESTKUDOS:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_1]
value = TESTKUDOS:1
@@ -145,6 +173,7 @@ fee_deposit = TESTKUDOS:0.02
fee_refresh = TESTKUDOS:0.03
fee_refund = TESTKUDOS:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_2]
value = TESTKUDOS:2
@@ -156,6 +185,7 @@ fee_deposit = TESTKUDOS:0.03
fee_refresh = TESTKUDOS:0.04
fee_refund = TESTKUDOS:0.02
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_4]
value = TESTKUDOS:4
@@ -167,6 +197,7 @@ fee_deposit = TESTKUDOS:0.03
fee_refresh = TESTKUDOS:0.04
fee_refund = TESTKUDOS:0.02
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_5]
value = TESTKUDOS:5
@@ -178,6 +209,7 @@ fee_deposit = TESTKUDOS:0.01
fee_refresh = TESTKUDOS:0.03
fee_refund = TESTKUDOS:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_8]
value = TESTKUDOS:8
@@ -189,6 +221,7 @@ fee_deposit = TESTKUDOS:0.02
fee_refresh = TESTKUDOS:0.03
fee_refund = TESTKUDOS:0.04
rsa_keysize = 1024
+CIPHER = RSA
[coin_kudos_10]
value = TESTKUDOS:10
@@ -200,3 +233,4 @@ fee_deposit = TESTKUDOS:0.01
fee_refresh = TESTKUDOS:0.03
fee_refund = TESTKUDOS:0.01
rsa_keysize = 1024
+CIPHER = RSA
diff --git a/src/cli/test_reducer_free.conf b/src/cli/test_reducer_free.conf
new file mode 100644
index 0000000..4e46929
--- /dev/null
+++ b/src/cli/test_reducer_free.conf
@@ -0,0 +1,210 @@
+# This file is in the public domain.
+[PATHS]
+TALER_HOME = ${PWD}/test_reducer_home/
+TALER_DATA_HOME = $TALER_HOME/.local/share/taler/
+TALER_CONFIG_HOME = $TALER_HOME/.config/taler/
+TALER_CACHE_HOME = $TALER_HOME/.cache/taler/
+TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
+
+[taler]
+CURRENCY = TESTKUDOS
+CURRENCY_ROUND_UNIT = TESTKUDOS:0.01
+
+[anastasis]
+DB = postgres
+ANNUAL_FEE = TESTKUDOS:0
+TRUTH_UPLOAD_FEE = TESTKUDOS:0.0
+UPLOAD_LIMIT_MB = 1
+ANNUAL_POLICY_UPLOAD_LIMIT = 128
+INSURANCE = TESTKUDOS:0
+
+[anastasis-merchant-backend]
+PAYMENT_BACKEND_URL = http://localhost:9966/
+
+[authorization-question]
+COST = TESTKUDOS:0.0
+
+
+[exchange]
+MAX_KEYS_CACHING = forever
+DB = postgres
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
+SERVE = tcp
+UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
+UNIXPATH_MODE = 660
+PORT = 8081
+BASE_URL = http://localhost:8081/
+SIGNKEY_DURATION = 2 weeks
+SIGNKEY_LEGAL_DURATION = 2 years
+LEGAL_DURATION = 2 years
+LOOKAHEAD_SIGN = 3 weeks 1 day
+LOOKAHEAD_PROVIDE = 2 weeks 1 day
+KEYDIR = ${TALER_DATA_HOME}/exchange/live-keys/
+REVOCATION_DIR = ${TALER_DATA_HOME}/exchange/revocations/
+TERMS_ETAG = 0
+PRIVACY_ETAG = 0
+
+[merchant]
+SERVE = tcp
+PORT = 9966
+UNIXPATH = ${TALER_RUNTIME_DIR}/merchant.http
+UNIXPATH_MODE = 660
+DEFAULT_WIRE_FEE_AMORTIZATION = 1
+DB = postgres
+WIREFORMAT = default
+# Set very low, so we can be sure that the database generated
+# will contain wire transfers "ready" for the aggregator.
+WIRE_TRANSFER_DELAY = 1 minute
+DEFAULT_PAY_DEADLINE = 1 day
+DEFAULT_MAX_DEPOSIT_FEE = TESTKUDOS:0.1
+KEYFILE = ${TALER_DATA_HOME}/merchant/merchant.priv
+DEFAULT_MAX_WIRE_FEE = TESTKUDOS:0.10
+
+# Ensure that merchant reports EVERY deposit confirmation to auditor
+FORCE_AUDIT = YES
+
+[auditor]
+DB = postgres
+AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
+SERVE = tcp
+UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
+UNIXPATH_MODE = 660
+PORT = 8083
+AUDITOR_URL = http://localhost:8083/
+TINY_AMOUNT = TESTKUDOS:0.01
+AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
+BASE_URL = "http://localhost:8083/"
+
+[bank]
+DATABASE = postgres:///taler-auditor-basedb
+MAX_DEBT = TESTKUDOS:50.0
+MAX_DEBT_BANK = TESTKUDOS:100000.0
+HTTP_PORT = 8082
+SUGGESTED_EXCHANGE = http://localhost:8081/
+SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost/2
+ALLOW_REGISTRATIONS = YES
+SERVE = http
+
+[exchangedb]
+IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
+LEGAL_RESERVE_EXPIRATION_TIME = 7 years
+
+[exchange-account-1]
+PAYTO_URI = payto://x-taler-bank/localhost/Exchange
+enable_debit = yes
+enable_credit = yes
+
+[exchange-accountcredentials-1]
+WIRE_GATEWAY_URL = "http://localhost:8082/accounts/Exchange/taler-wire-gateway/"
+WIRE_GATEWAY_AUTH_METHOD = basic
+USERNAME = Exchange
+PASSWORD = x
+
+[merchant-exchange-default]
+EXCHANGE_BASE_URL = http://localhost:8081/
+CURRENCY = TESTKUDOS
+
+[payments-generator]
+currency = TESTKUDOS
+instance = default
+bank = http://localhost:8082/
+merchant = http://localhost:9966/
+exchange_admin = http://localhost:18080/
+exchange-admin = http://localhost:18080/
+exchange = http://localhost:8081/
+
+[coin_kudos_ct_1]
+value = TESTKUDOS:0.01
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.01
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_ct_10]
+value = TESTKUDOS:0.10
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_1]
+value = TESTKUDOS:1
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.02
+fee_deposit = TESTKUDOS:0.02
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_2]
+value = TESTKUDOS:2
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.03
+fee_deposit = TESTKUDOS:0.03
+fee_refresh = TESTKUDOS:0.04
+fee_refund = TESTKUDOS:0.02
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_4]
+value = TESTKUDOS:4
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.03
+fee_deposit = TESTKUDOS:0.03
+fee_refresh = TESTKUDOS:0.04
+fee_refund = TESTKUDOS:0.02
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_5]
+value = TESTKUDOS:5
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_8]
+value = TESTKUDOS:8
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.05
+fee_deposit = TESTKUDOS:0.02
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.04
+rsa_keysize = 1024
+CIPHER = RSA
+
+[coin_kudos_10]
+value = TESTKUDOS:10
+duration_withdraw = 7 days
+duration_spend = 2 years
+duration_legal = 3 years
+fee_withdraw = TESTKUDOS:0.01
+fee_deposit = TESTKUDOS:0.01
+fee_refresh = TESTKUDOS:0.03
+fee_refund = TESTKUDOS:0.01
+rsa_keysize = 1024
+CIPHER = RSA
diff --git a/src/cli/test_reducer_home/.local/share/taler/exchange-offline/master.priv b/src/cli/test_reducer_home/.local/share/taler/exchange-offline/master.priv
new file mode 100644
index 0000000..d990a05
--- /dev/null
+++ b/src/cli/test_reducer_home/.local/share/taler/exchange-offline/master.priv
@@ -0,0 +1 @@
+ý>eÍ”nƒÍ™[˜ùz3‘ÔÜpwTj?cÉn21 \ No newline at end of file
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index b13d44c..fd1275c 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -97,61 +97,43 @@ ANASTASIS_challenge_get_details (struct ANASTASIS_Challenge *challenge);
/**
* Possible outcomes of trying to start a challenge operation.
*/
-enum ANASTASIS_ChallengeStatus
+enum ANASTASIS_ChallengeStartStatus
{
/**
- * The challenge has been solved.
- */
- ANASTASIS_CHALLENGE_STATUS_SOLVED,
-
- /**
- * Instructions for how to solve the challenge are provided. Also
- * used if the answer we provided was wrong (or if no answer was
- * provided, but one is needed).
- */
- ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS,
-
- /**
- * A redirection URL needed to solve the challenge is provided. Also
- * used if the answer we provided was wrong (or if no answer was
- * provided, but one is needed).
+ * We encountered an error talking to the Anastasis service.
*/
- ANASTASIS_CHALLENGE_STATUS_REDIRECT_FOR_AUTHENTICATION,
+ ANASTASIS_CHALLENGE_START_STATUS_SERVER_FAILURE,
/**
* Payment is required before the challenge can be answered.
*/
- ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED,
+ ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED,
/**
- * We encountered an error talking to the Anastasis service.
+ * The server does not know this truth.
*/
- ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE,
+ ANASTASIS_CHALLENGE_START_STATUS_TRUTH_UNKNOWN,
/**
- * The server does not know this truth.
+ * A filename with the TAN has been provided.
*/
- ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN,
+ ANASTASIS_CHALLENGE_START_STATUS_FILENAME_PROVIDED,
/**
- * The rate limit for solving the challenge was exceeded.
+ * A TAN has been send, address hint is provided.
*/
- ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED,
+ ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED,
/**
- * The user did not satisfy the (external) authentication
- * challenge in time. The request should be repeated
- * later and may then succeed.
+ * A TAN has been sent before.
*/
- ANASTASIS_CHALLENGE_STATUS_AUTH_TIMEOUT,
+ ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT,
/**
- * Plugin-specific ("external") instructions for how to solve the
- * challenge are provided.
+ * Wire transfer required, banking details provided.
*/
- ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS
-
+ ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED
};
@@ -161,10 +143,21 @@ enum ANASTASIS_ChallengeStatus
*/
struct ANASTASIS_ChallengeStartResponse
{
+
+ /**
+ * HTTP status returned by the server.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler-specific error code.
+ */
+ enum TALER_ErrorCode ec;
+
/**
* What is our status on satisfying this challenge. Determines @e details.
*/
- enum ANASTASIS_ChallengeStatus cs;
+ enum ANASTASIS_ChallengeStartStatus cs;
/**
* Which challenge is this about?
@@ -179,50 +172,25 @@ struct ANASTASIS_ChallengeStartResponse
/**
* Challenge details provided if
- * @e cs is #ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS
+ * @e cs is #ANASTASIS_CHALLENGE_START_STATUS_FILENAME_PROVIDED.
*/
- struct
- {
-
- /**
- * Response with server-side instructions for the user.
- */
- const void *body;
-
- /**
- * Mime type of the data in @e body.
- */
- const char *content_type;
-
- /**
- * Number of bytes in @e body
- */
- size_t body_size;
-
- /**
- * HTTP status returned by the server. #MHD_HTTP_ALREADY_REPORTED
- * if the server did already send the challenge to the user,
- * #MHD_HTTP_FORBIDDEN if the answer was wrong (or missing).
- */
- unsigned int http_status;
- } open_challenge;
-
+ const char *tan_filename;
/**
- * Response with details if
- * @e cs is #ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS.
+ * Challenge details provided if
+ * @e cs is #ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED.
*/
- const json_t *external_challenge;
+ const char *tan_address_hint;
/**
- * Response with URL to redirect the user to, if
- * @e cs is #ANASTASIS_CHALLENGE_STATUS_REDIRECT_FOR_AUTHENTICATION.
+ * Challenge details provided if
+ * @e cs is #ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED.
*/
- const char *redirect_url;
+ struct ANASTASIS_WireFundsDetails bank_transfer_required;
/**
* Response with instructions for how to pay, if
- * @e cs is #ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED.
+ * @e cs is #ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED.
*/
struct
{
@@ -239,26 +207,6 @@ struct ANASTASIS_ChallengeStartResponse
} payment_required;
-
- /**
- * Response with details about a server-side failure, if
- * @e cs is #ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE.
- */
- struct
- {
-
- /**
- * HTTP status returned by the server.
- */
- unsigned int http_status;
-
- /**
- * Taler-specific error code.
- */
- enum TALER_ErrorCode ec;
-
- } server_failure;
-
} details;
};
@@ -271,7 +219,7 @@ struct ANASTASIS_ChallengeStartResponse
* @param csr response details
*/
typedef void
-(*ANASTASIS_AnswerFeedback)(
+(*ANASTASIS_ChallengeStartFeedback)(
void *cls,
const struct ANASTASIS_ChallengeStartResponse *csr);
@@ -285,8 +233,6 @@ typedef void
*
* @param c reference to the escrow challenge which is started
* @param psp payment secret, NULL if no payment was yet made
- * @param timeout how long to wait for payment
- * @param hashed_answer answer to the challenge, NULL if we have none yet
* @param af reference to the answerfeedback which is passed back to the user
* @param af_cls closure for @a af
* @return #GNUNET_OK if the challenge was successfully started
@@ -294,13 +240,137 @@ typedef void
enum GNUNET_GenericReturnValue
ANASTASIS_challenge_start (struct ANASTASIS_Challenge *c,
const struct ANASTASIS_PaymentSecretP *psp,
- struct GNUNET_TIME_Relative timeout,
- const struct GNUNET_HashCode *hashed_answer,
- ANASTASIS_AnswerFeedback af,
+ ANASTASIS_ChallengeStartFeedback af,
void *af_cls);
/**
+ * Possible outcomes of trying to start a challenge operation.
+ */
+enum ANASTASIS_ChallengeAnswerStatus
+{
+
+ /**
+ * The challenge has been solved.
+ */
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED,
+
+ /**
+ * Payment is required before the challenge can be answered.
+ */
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_PAYMENT_REQUIRED,
+
+ /**
+ * We encountered an error talking to the Anastasis service.
+ */
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_SERVER_FAILURE,
+
+ /**
+ * The server does not know this truth.
+ */
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_TRUTH_UNKNOWN,
+
+ /**
+ * The answer was wrong.
+ */
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_INVALID_ANSWER,
+
+ /**
+ * The rate limit for solving the challenge was exceeded.
+ */
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_RATE_LIMIT_EXCEEDED
+
+};
+
+
+/**
+ * Response from an #ANASTASIS_challenge_start() operation.
+ */
+struct ANASTASIS_ChallengeAnswerResponse
+{
+
+ /**
+ * HTTP status returned by the server.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler-specific error code.
+ */
+ enum TALER_ErrorCode ec;
+
+ /**
+ * What is our status on satisfying this challenge. Determines @e details.
+ */
+ enum ANASTASIS_ChallengeAnswerStatus cs;
+
+ /**
+ * Which challenge is this about?
+ */
+ struct ANASTASIS_Challenge *challenge;
+
+ /**
+ * Details depending on @e cs
+ */
+ union
+ {
+
+ /**
+ * Details for #ANASTASIS_CHALLENGE_ANSWER_STATUS_RATE_LIMIT_EXCEEDED.
+ */
+ struct
+ {
+
+ /**
+ * How many requests are allowed at most per @e request_frequency?
+ */
+ uint32_t request_limit;
+
+ /**
+ * Frequency at which requests are allowed / new challenges are
+ * created.
+ */
+ struct GNUNET_TIME_Relative request_frequency;
+
+ } rate_limit_exceeded;
+
+ /**
+ * Response with instructions for how to pay, if
+ * @e cs is #ANASTASIS_CHALLENGE_ANSWER_STATUS_PAYMENT_REQUIRED.
+ */
+ struct
+ {
+
+ /**
+ * "taler://pay" URI with details how to pay for the challenge.
+ */
+ const char *taler_pay_uri;
+
+ /**
+ * Payment secret from @e taler_pay_uri.
+ */
+ struct ANASTASIS_PaymentSecretP payment_secret;
+
+ } payment_required;
+
+ } details;
+};
+
+
+/**
+ * Defines a callback for the response status for a challenge start
+ * operation.
+ *
+ * @param cls closure
+ * @param car response details
+ */
+typedef void
+(*ANASTASIS_AnswerFeedback)(
+ void *cls,
+ const struct ANASTASIS_ChallengeAnswerResponse *car);
+
+
+/**
* Challenge answer for a security question. Is referenced to
* a challenge and sends back an AnswerFeedback. Convenience
* wrapper around #ANASTASIS_challenge_start that hashes @a answer
@@ -310,8 +380,8 @@ ANASTASIS_challenge_start (struct ANASTASIS_Challenge *c,
* @param psp information about payment made for the recovery
* @param timeout how long to wait for payment
* @param answer user input instruction defines which input is needed
- * @param af reference to the answerfeedback which is passed back to the user
- * @param af_cls closure for @a af
+ * @param csf function to call with the result
+ * @param csf_cls closure for @a csf
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
@@ -319,8 +389,8 @@ ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
const struct ANASTASIS_PaymentSecretP *psp,
struct GNUNET_TIME_Relative timeout,
const char *answer,
- ANASTASIS_AnswerFeedback af,
- void *af_cls);
+ ANASTASIS_AnswerFeedback csf,
+ void *csf_cls);
/**
@@ -347,6 +417,30 @@ ANASTASIS_challenge_answer2 (struct ANASTASIS_Challenge *c,
/**
+ * User starts a challenge which reponds out of bounds (E-Mail, SMS,
+ * Postal..) If the challenge is zero cost, the challenge
+ * instructions will be sent to the client. If the challenge needs
+ * payment a payment link is sent to the client. After payment the
+ * challenge start method has to be called again.
+ *
+ * @param c reference to the escrow challenge which is started
+ * @param psp payment secret, NULL if no payment was yet made
+ * @param timeout how long to wait for payment
+ * @param hashed_answer answer to the challenge
+ * @param af reference to the answerfeedback which is passed back to the user
+ * @param af_cls closure for @a af
+ * @return #GNUNET_OK if the challenge was successfully started
+ */
+enum GNUNET_GenericReturnValue
+ANASTASIS_challenge_answer3 (struct ANASTASIS_Challenge *c,
+ const struct ANASTASIS_PaymentSecretP *psp,
+ struct GNUNET_TIME_Relative timeout,
+ const struct GNUNET_HashCode *hashed_answer,
+ ANASTASIS_AnswerFeedback af,
+ void *af_cls);
+
+
+/**
* Abort answering challenge.
*
* @param c reference to the escrow challenge which was started
@@ -356,6 +450,67 @@ ANASTASIS_challenge_abort (struct ANASTASIS_Challenge *c);
/**
+ * Handle for an operation to get available recovery
+ * document versions.
+ */
+struct ANASTASIS_VersionCheck;
+
+
+/**
+ * Callback which passes back meta data about one of the
+ * recovery documents available at the provider.
+ *
+ * @param cls closure for the callback
+ * @param version version number of the policy document,
+ * 0 for the end of the list
+ * @param server_time time of the backup at the provider
+ * @param recdoc_id hash of the compressed recovery document, uniquely
+ * identifies the document; NULL for the end of the list
+ * @param secret_name name of the secret as chosen by the user,
+ * or NULL if the user did not provide a name
+ */
+typedef void
+(*ANASTASIS_MetaPolicyCallback)(void *cls,
+ uint32_t version,
+ struct GNUNET_TIME_Timestamp server_time,
+ const struct GNUNET_HashCode *recdoc_id,
+ const char *secret_name);
+
+
+/**
+ * Obtain an overview of available recovery policies from the
+ * specified provider.
+ *
+ * @param ctx context for making HTTP requests
+ * @param id_data contains the users identity, (user account on providers)
+ * @param version defines the version which will be downloaded, 0 for latest version
+ * @param anastasis_provider_url provider url
+ * @param provider_salt the server salt
+ * @param mpc function called with the available versions
+ * @param mpc_cls closure for @a mpc callback
+ * @return recovery operation handle
+ */
+struct ANASTASIS_VersionCheck *
+ANASTASIS_recovery_get_versions (
+ struct GNUNET_CURL_Context *ctx,
+ const json_t *id_data,
+ unsigned int max_version,
+ const char *anastasis_provider_url,
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt,
+ ANASTASIS_MetaPolicyCallback mpc,
+ void *mpc_cls);
+
+
+/**
+ * Cancel version check operation.
+ *
+ * @param vc operation to cancel
+ */
+void
+ANASTASIS_recovery_get_versions_cancel (struct ANASTASIS_VersionCheck *vc);
+
+
+/**
* Defines a Decryption Policy with multiple escrow methods
*/
struct ANASTASIS_DecryptionPolicy
@@ -510,9 +665,9 @@ struct ANASTASIS_Recovery;
*
* @param ctx context for making HTTP requests
* @param id_data contains the users identity, (user account on providers)
- * @param version defines the version which will be downloaded NULL for latest version
- * @param anastasis_provider_url NULL terminated list of possible provider urls
- * @param provider_salt the server salt
+ * @param version defines the version which will be downloaded, 0 for latest version
+ * @param anastasis_provider_url provider REST API endpoint url
+ * @param provider_salt the provider's salt
* @param pc opens the policy call back which holds the downloaded version and the policies
* @param pc_cls closure for callback
* @param csc core secret callback is opened, with this the core secert is passed to the client after the authentication
@@ -845,7 +1000,7 @@ struct ANASTASIS_ProviderSuccessStatus
/**
* When will the policy expire?
*/
- struct GNUNET_TIME_Absolute policy_expiration;
+ struct GNUNET_TIME_Timestamp policy_expiration;
/**
* Version number of the policy at the provider.
diff --git a/src/include/anastasis_authorization_lib.h b/src/include/anastasis_authorization_lib.h
index 975dd5f..bcbd2e6 100644
--- a/src/include/anastasis_authorization_lib.h
+++ b/src/include/anastasis_authorization_lib.h
@@ -3,7 +3,7 @@
Copyright (C) 2019, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
diff --git a/src/include/anastasis_authorization_plugin.h b/src/include/anastasis_authorization_plugin.h
index 48d8741..a9d993d 100644
--- a/src/include/anastasis_authorization_plugin.h
+++ b/src/include/anastasis_authorization_plugin.h
@@ -3,7 +3,7 @@
Copyright (C) 2019 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -33,21 +33,21 @@ struct ANASTASIS_AUTHORIZATION_State;
/**
* Enumeration values indicating the various possible
- * outcomes of the plugin's `process` function.
+ * outcomes of the plugin's `challenge` function.
*/
-enum ANASTASIS_AUTHORIZATION_Result
+enum ANASTASIS_AUTHORIZATION_ChallengeResult
{
/**
* We successfully sent the authorization challenge
* and queued a reply to MHD.
*/
- ANASTASIS_AUTHORIZATION_RES_SUCCESS = 0,
+ ANASTASIS_AUTHORIZATION_CRES_SUCCESS = 0,
/**
* We failed to transmit the authorization challenge,
* but successfully queued a failure response to MHD.
*/
- ANASTASIS_AUTHORIZATION_RES_FAILED = 1,
+ ANASTASIS_AUTHORIZATION_CRES_FAILED = 1,
/**
* The plugin suspended the MHD connection as it needs some more
@@ -55,7 +55,7 @@ enum ANASTASIS_AUTHORIZATION_Result
* plugin will resume the MHD connection when its work is done, and
* then the `process` function should be called again.
*/
- ANASTASIS_AUTHORIZATION_RES_SUSPENDED = 2,
+ ANASTASIS_AUTHORIZATION_CRES_SUSPENDED = 2,
/**
* The plugin tried to queue a reply on the MHD connection and
@@ -65,7 +65,7 @@ enum ANASTASIS_AUTHORIZATION_Result
* However, we were successful at transmitting the challenge,
* so the challenge should be marked as sent.
*/
- ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED = 4,
+ ANASTASIS_AUTHORIZATION_CRES_SUCCESS_REPLY_FAILED = 4,
/**
* The plugin tried to queue a reply on the MHD connection and
@@ -74,14 +74,45 @@ enum ANASTASIS_AUTHORIZATION_Result
*
* Additionally, we failed to transmit the challenge.
*/
- ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED = 5,
+ ANASTASIS_AUTHORIZATION_CRES_FAILED_REPLY_FAILED = 5
+};
+
+
+/**
+ * Enumeration values indicating the various possible
+ * outcomes of the plugin's `solve` function.
+ */
+enum ANASTASIS_AUTHORIZATION_SolveResult
+{
+ /**
+ * We failed to transmit the authorization challenge,
+ * but successfully queued a failure response to MHD.
+ */
+ ANASTASIS_AUTHORIZATION_SRES_FAILED = 0,
+
+ /**
+ * The plugin suspended the MHD connection as it needs some more
+ * time to do its (asynchronous) work before we can proceed. The
+ * plugin will resume the MHD connection when its work is done, and
+ * then the `process` function should be called again.
+ */
+ ANASTASIS_AUTHORIZATION_SRES_SUSPENDED = 1,
+
+ /**
+ * The plugin tried to queue a reply on the MHD connection and
+ * failed to do so. We should return #MHD_NO to MHD to cause the
+ * HTTP connection to be closed without any reply.
+ *
+ * Additionally, we failed to transmit the challenge.
+ */
+ ANASTASIS_AUTHORIZATION_SRES_FAILED_REPLY_FAILED = 2,
/**
* The authentication process completed successfully
* and we should signal success to the client by
* returning the truth.
*/
- ANASTASIS_AUTHORIZATION_RES_FINISHED = 6
+ ANASTASIS_AUTHORIZATION_SRES_FINISHED = 3
};
@@ -210,18 +241,31 @@ struct ANASTASIS_AuthorizationPlugin
/**
* Continue issuing authentication challenge to user based on @a data.
* I.e. check if the transmission of the challenge via SMS or e-mail
- * has completed and/or manipulate @a connection to redirect the client
- * to a video identification site.
+ * has completed and/or manipulate @a connection to direct the client towards solving the challenge.
+ *
+ * @param as authorization state
+ * @param connection HTTP client request (for queuing response, such as redirection to video portal)
+ * @return state of the request
+ */
+ enum ANASTASIS_AUTHORIZATION_ChallengeResult
+ (*challenge)(struct ANASTASIS_AUTHORIZATION_State *as,
+ struct MHD_Connection *connection);
+
+
+ /**
+ * Check if the client has solved the challenge.
*
* @param as authorization state
* @param timeout how long do we have to produce a reply
+ * @param challenge_response hash of the challenge response, or NULL
* @param connection HTTP client request (for queuing response, such as redirection to video portal)
* @return state of the request
*/
- enum ANASTASIS_AUTHORIZATION_Result
- (*process)(struct ANASTASIS_AUTHORIZATION_State *as,
- struct GNUNET_TIME_Absolute timeout,
- struct MHD_Connection *connection);
+ enum ANASTASIS_AUTHORIZATION_SolveResult
+ (*solve)(struct ANASTASIS_AUTHORIZATION_State *as,
+ struct GNUNET_TIME_Absolute timeout,
+ const struct GNUNET_HashCode *challenge_response,
+ struct MHD_Connection *connection);
/**
diff --git a/src/include/anastasis_crypto_lib.h b/src/include/anastasis_crypto_lib.h
index fbafcd6..8cbc954 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -21,7 +21,7 @@
* @author Dennis Neufeld
*/
#include <jansson.h>
-#include <gnunet/gnunet_crypto_lib.h>
+#include <gnunet/gnunet_util_lib.h>
/**
@@ -41,6 +41,12 @@
"Anastasis-Truth-Decryption-Key"
/**
+ * Client to server: please store this meta data.
+ */
+#define ANASTASIS_HTTP_HEADER_POLICY_META_DATA "Anastasis-Policy-Meta-Data"
+
+
+/**
* Client to server: I paid using this payment secret.
*/
#define ANASTASIS_HTTP_HEADER_PAYMENT_IDENTIFIER "Anastasis-Payment-Identifier"
@@ -295,13 +301,13 @@ ANASTASIS_hash_answer (uint64_t code,
* data.
*
* @param id_data JSON encoded data, which contains the raw user secret
- * @param server_salt salt from the server (escrow provider)
+ * @param provider_salt salt from the server (escrow provider)
* @param[out] id reference to the id which was created
*/
void
ANASTASIS_CRYPTO_user_identifier_derive (
const json_t *id_data,
- const struct ANASTASIS_CRYPTO_ProviderSaltP *server_salt,
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt,
struct ANASTASIS_CRYPTO_UserIdentifierP *id);
@@ -390,6 +396,44 @@ ANASTASIS_CRYPTO_recovery_document_decrypt (
/**
+ * Encrypt recovery document meta data.
+ *
+ * @param id Hashed User input, used for the generation of the encryption key
+ * @param meta_data contains the recovery document meta data
+ * @param meta_data_size number of bytes in @a meta_data
+ * @param[out] enc_meta_data set to the encrypted meta data
+ * @param[out] enc_meta_data_size size of the result
+ */
+void
+ANASTASIS_CRYPTO_recovery_metadata_encrypt (
+ const struct ANASTASIS_CRYPTO_UserIdentifierP *id,
+ const void *meta_data,
+ size_t meta_data_size,
+ void **enc_meta_data,
+ size_t *enc_meta_data_size);
+
+
+/**
+ * Decrypts the recovery meta data.
+ *
+ * @param id Hashed User input, used for the generation of the decryption key
+ * @param enc_meta_data encrypted meta data
+ * @param enc_meta_data_size number of bytes in @a enc_meta_data
+ * @param[out] meta_data decrypted meta data
+ * @param[out] meta_data_size size of the result in @a meta_data
+ * @return #GNUNET_OK on success, #GNUNET_NO if the authentication tag
+ * was wrong
+ */
+enum GNUNET_GenericReturnValue
+ANASTASIS_CRYPTO_recovery_metadata_decrypt (
+ const struct ANASTASIS_CRYPTO_UserIdentifierP *id,
+ const void *enc_meta_data,
+ size_t enc_meta_data_size,
+ void **meta_data,
+ size_t *meta_data_size);
+
+
+/**
* Encrypts a keyshare with a key generated with the user identification as entropy and the salt "eks".
*
* @param key_share the key share which is afterwards encrypted
@@ -543,3 +587,16 @@ ANASTASIS_CRYPTO_core_secret_recover (
size_t encrypted_core_secret_size,
void **core_secret,
size_t *core_secret_size);
+
+
+/**
+ * Convert a @a uuid to a shortened, human-readable string
+ * useful to show to users to identify the truth.
+ * Note that the return value is in a global variable and
+ * only valid until the next invocation of this function.
+ *
+ * @param uuid UUID to convert
+ * @return string representation
+ */
+const char *
+ANASTASIS_CRYPTO_uuid2s (const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid);
diff --git a/src/include/anastasis_database_lib.h b/src/include/anastasis_database_lib.h
index 7de1612..896b039 100644
--- a/src/include/anastasis_database_lib.h
+++ b/src/include/anastasis_database_lib.h
@@ -3,7 +3,7 @@
Copyright (C) 2019 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
diff --git a/src/include/anastasis_database_plugin.h b/src/include/anastasis_database_plugin.h
index cf5a69a..2082bf9 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -1,9 +1,9 @@
/*
This file is part of Anastasis
- Copyright (C) 2019-2021 Anastasis SARL
+ Copyright (C) 2019-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -136,7 +136,7 @@ enum ANASTASIS_DB_StoreStatus
typedef void
(*ANASTASIS_DB_PaymentPendingIterator)(
void *cls,
- struct GNUNET_TIME_Absolute timestamp,
+ struct GNUNET_TIME_Timestamp timestamp,
const struct ANASTASIS_PaymentSecretP *payment_secret,
const struct TALER_Amount *amount);
@@ -159,6 +159,26 @@ typedef bool
/**
+ * Function called on matching meta data. Note that if the client did
+ * not provide meta data for @a version, the function will be called
+ * with @a recovery_meta_data being NULL.
+ *
+ * @param cls closure
+ * @param version the version of the recovery document
+ * @param ts timestamp when the document was uploaded
+ * @param recovery_meta_data contains meta data about the encrypted recovery document
+ * @param recovery_meta_data_size size of @a recovery_meta_data blob
+ * @return #GNUNET_OK to continue to iterate, #GNUNET_NO to abort iteration
+ */
+typedef enum GNUNET_GenericReturnValue
+(*ANASTASIS_DB_RecoveryMetaCallback)(void *cls,
+ uint32_t version,
+ struct GNUNET_TIME_Timestamp ts,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size);
+
+
+/**
* Handle to interact with the database.
*
* Functions ending with "_TR" run their OWN transaction scope
@@ -329,6 +349,8 @@ struct ANASTASIS_DatabasePlugin
* @param recovery_data_hash hash of @a data
* @param recovery_data contains encrypted recovery document
* @param recovery_data_size size of @a recovery_data blob
+ * @param recovery_meta_data contains meta data about the encrypted recovery document
+ * @param recovery_meta_data_size size of @a recovery_meta_data blob
* @param payment_secret identifier for the payment, used to later charge on uploads
* @param[out] version set to the version assigned to the document by the database
* @return transaction status, 0 if upload could not be finished because @a payment_secret
@@ -342,11 +364,34 @@ struct ANASTASIS_DatabasePlugin
const struct GNUNET_HashCode *recovery_data_hash,
const void *recovery_data,
size_t recovery_data_size,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size,
const struct ANASTASIS_PaymentSecretP *payment_secret,
uint32_t *version);
/**
+ * Fetch recovery document meta data for user. Returns
+ * meta data in descending order from @a max_version.
+ * The size of the result set may be limited.
+ *
+ * @param cls closure
+ * @param account_pub public key of the user's account
+ * @param max_version the maximum version number the user requests
+ * @param cb function to call on each result
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*get_recovery_meta_data)(
+ void *cls,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
+ uint32_t max_version,
+ ANASTASIS_DB_RecoveryMetaCallback cb,
+ void *cb_cls);
+
+
+ /**
* Fetch recovery document for user according given version.
*
* @param cls closure
@@ -468,7 +513,7 @@ struct ANASTASIS_DatabasePlugin
(*lookup_account)(
void *cls,
const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
- struct GNUNET_TIME_Absolute *paid_until,
+ struct GNUNET_TIME_Timestamp *paid_until,
struct GNUNET_HashCode *recovery_data_hash,
uint32_t *version);
@@ -525,7 +570,7 @@ struct ANASTASIS_DatabasePlugin
const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
const struct ANASTASIS_PaymentSecretP *payment_identifier,
struct GNUNET_TIME_Relative lifetime,
- struct GNUNET_TIME_Absolute *paid_until);
+ struct GNUNET_TIME_Timestamp *paid_until);
/**
@@ -543,7 +588,7 @@ struct ANASTASIS_DatabasePlugin
void *cls,
const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
const struct ANASTASIS_PaymentSecretP *payment_identifier,
- struct GNUNET_TIME_Absolute eol);
+ struct GNUNET_TIME_Timestamp eol);
/**
@@ -596,7 +641,7 @@ struct ANASTASIS_DatabasePlugin
(*check_truth_upload_paid)(
void *cls,
const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid,
- struct GNUNET_TIME_Absolute *paid_until);
+ struct GNUNET_TIME_Timestamp *paid_until);
/**
@@ -653,7 +698,7 @@ struct ANASTASIS_DatabasePlugin
void *cls,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
const uint64_t code,
- struct GNUNET_TIME_Absolute after);
+ struct GNUNET_TIME_Timestamp after);
/**
@@ -679,7 +724,7 @@ struct ANASTASIS_DatabasePlugin
struct GNUNET_TIME_Relative rotation_period,
struct GNUNET_TIME_Relative validity_period,
uint32_t retry_counter,
- struct GNUNET_TIME_Absolute *retransmission_date,
+ struct GNUNET_TIME_Timestamp *retransmission_date,
uint64_t *code);
@@ -780,7 +825,7 @@ struct ANASTASIS_DatabasePlugin
const struct TALER_Amount *amount,
const char *debit_account,
const char *credit_account,
- struct GNUNET_TIME_Absolute execution_date);
+ struct GNUNET_TIME_Timestamp execution_date);
/**
@@ -802,7 +847,7 @@ struct ANASTASIS_DatabasePlugin
(*test_auth_iban_payment)(
void *cls,
const char *debit_account,
- struct GNUNET_TIME_Absolute earliest_date,
+ struct GNUNET_TIME_Timestamp earliest_date,
ANASTASIS_DB_AuthIbanTransfercheck cb,
void *cb_cls);
diff --git a/src/include/anastasis_eufin_lib.h b/src/include/anastasis_eufin_lib.h
index daff98a..91b9fe3 100644
--- a/src/include/anastasis_eufin_lib.h
+++ b/src/include/anastasis_eufin_lib.h
@@ -112,7 +112,7 @@ struct ANASTASIS_EUFIN_CreditDetails
/**
* Time of the the transfer
*/
- struct GNUNET_TIME_Absolute execution_date;
+ struct GNUNET_TIME_Timestamp execution_date;
/**
* The wire transfer subject.
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index dd28174..2adb74b 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -111,4 +111,111 @@ void
ANASTASIS_redux_action_cancel (struct ANASTASIS_ReduxAction *ra);
+/**
+ * Handle for a policy discovery operation.
+ */
+struct ANASTASIS_PolicyDiscovery;
+
+
+/**
+ * Function called on each discovered recovery policy.
+ *
+ * The client can then start a new policy discovery process, using the
+ * smallest (also most recent) @a version received per @a provider_url
+ * in the cursor to resume. Note that in this case, the application
+ * logic is responsible for de-duplication using @a hcpd, or it may show
+ * policies again if they are at different providers under versions not
+ * queried up to the cursor.
+ *
+ * @param cls closure
+ * @param hcpd hash of the compressed policy document (unique per policy)
+ * @param provider_url which provider claims to have this policy
+ * @param version version of the policy at this provider
+ * @param attribute_mask combination of optional identity attributes
+ * present in the state that was used to locate this version
+ * @param server_time when did the provider receive the upload
+ * @param secret_name name the user assigned to the backup
+ * @param providers json array of providers with this policy
+ */
+typedef void
+(*ANASTASIS_PolicyDiscoveryCallback)(void *cls,
+ const struct GNUNET_HashCode *hcpd,
+ const char *provider_url,
+ uint32_t version,
+ json_int_t attribute_mask,
+ struct GNUNET_TIME_Timestamp server_time,
+ const char *secret_name,
+ const json_t *providers);
+
+
+/**
+ * Start requesting providers for available policies for the
+ * recovery specified in @a state.
+ *
+ * @param state state to discover polices in
+ * @param cursor array containing "provider_url", attribute "mask",
+ * and "max_version" values (max_version is exclusive).
+ * Used for incremental discovery, NULL is allowed
+ * to begin from the latest version(s).
+ * @param cb function to call with results
+ * @param cb_cls closure for @a cb
+ * @return NULL on failure
+ */
+struct ANASTASIS_PolicyDiscovery *
+ANASTASIS_policy_discovery_start (const json_t *state,
+ const json_t *cursor,
+ ANASTASIS_PolicyDiscoveryCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Add another provider to the list of providers to do discovery
+ * on.
+ *
+ * @param[in,out] pd policy discovery to expand
+ * @param provider_url the provider to add to the set of providers
+ * @param provider_state configuration state for that provider
+ */
+void
+ANASTASIS_policy_discovery_more (struct ANASTASIS_PolicyDiscovery *pd,
+ const char *provider_url,
+ json_t *provider_state);
+
+/**
+ * Stop policy discovery.
+ *
+ * @param[in] pd operation to stop
+ */
+void
+ANASTASIS_policy_discovery_stop (struct ANASTASIS_PolicyDiscovery *pd);
+
+
+/**
+ * Compute a subset of @a master_id removing optional attributes
+ * based on the bits set in @a mask.
+ *
+ * @param state reducer state (tells us which attributes are optional)
+ * @param master_id set of identity attributes to mask
+ * @param mask bitmask to apply
+ * @return masked copy of the @a master_id
+ */
+json_t *
+ANASTASIS_mask_id_data (const json_t *state,
+ const json_t *master_id,
+ json_int_t mask);
+
+/**
+ * Lookup @a salt of @a provider_url in @a state.
+ *
+ * @param state the state to inspect
+ * @param provider_url provider to look into
+ * @param[out] salt value to extract
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+ANASTASIS_reducer_lookup_salt (const json_t *state,
+ const char *provider_url,
+ struct ANASTASIS_CRYPTO_ProviderSaltP *salt);
+
+
#endif /* _ANASTASIS_REDUX_H */
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index bec89d1..2f30a8b 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -1,16 +1,16 @@
/*
This file is part of Anastasis
- Copyright (C) 2019-2021 Anastasis SARL
+ Copyright (C) 2019-2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -51,56 +51,82 @@ struct ANASTASIS_AuthorizationMethodConfig
*/
struct ANASTASIS_Config
{
- /**
- * Protocol version supported by the server.
- */
- const char *version;
/**
- * Business name of the anastasis provider.
+ * HTTP status returned.
*/
- const char *business_name;
+ unsigned int http_status;
/**
- * Currency used for payments by the server.
+ * Taler-specific error code, #TALER_EC_NONE on success.
*/
- const char *currency;
+ enum TALER_ErrorCode ec;
/**
- * Array of authorization methods supported by the server.
+ * Full response in JSON, if provided.
*/
- const struct ANASTASIS_AuthorizationMethodConfig *methods;
+ const json_t *response;
/**
- * Length of the @e methods array.
+ * Details depending on @e http_status.
*/
- unsigned int methods_length;
+ union
+ {
- /**
- * Maximum size of an upload in megabytes.
- */
- uint32_t storage_limit_in_megabytes;
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
- /**
- * Annual fee for an account / policy upload.
- */
- struct TALER_Amount annual_fee;
+ /**
+ * Protocol version supported by the server.
+ */
+ const char *version;
- /**
- * Fee for a truth upload.
- */
- struct TALER_Amount truth_upload_fee;
+ /**
+ * Business name of the anastasis provider.
+ */
+ const char *business_name;
- /**
- * Maximum legal liability for data loss covered by the
- * provider.
- */
- struct TALER_Amount liability_limit;
+ /**
+ * Array of authorization methods supported by the server.
+ */
+ const struct ANASTASIS_AuthorizationMethodConfig *methods;
- /**
- * Server salt.
- */
- struct ANASTASIS_CRYPTO_ProviderSaltP salt;
+ /**
+ * Length of the @e methods array.
+ */
+ unsigned int methods_length;
+
+ /**
+ * Maximum size of an upload in megabytes.
+ */
+ uint32_t storage_limit_in_megabytes;
+
+ /**
+ * Annual fee for an account / policy upload.
+ */
+ struct TALER_Amount annual_fee;
+
+ /**
+ * Fee for a truth upload.
+ */
+ struct TALER_Amount truth_upload_fee;
+
+ /**
+ * Maximum legal liability for data loss covered by the
+ * provider.
+ */
+ struct TALER_Amount liability_limit;
+
+ /**
+ * Provider salt.
+ */
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
+ } ok;
+
+ } details;
};
@@ -112,12 +138,10 @@ struct ANASTASIS_Config
* the server provided an acceptable response.
*
* @param cls closure
- * @param http_status the HTTP status
* @param acfg configuration obtained, NULL if we could not parse it
*/
typedef void
(*ANASTASIS_ConfigCallback)(void *cls,
- unsigned int http_status,
const struct ANASTASIS_Config *acfg);
@@ -156,34 +180,181 @@ ANASTASIS_config_cancel (struct ANASTASIS_ConfigOperation *co);
/**
- * Detailed results from the successful download.
+ * Detailed meta data result.
*/
-struct ANASTASIS_DownloadDetails
+struct ANASTASIS_MetaDataEntry
{
+
+ /**
+ * Timestamp of the backup at the server.
+ */
+ struct GNUNET_TIME_Timestamp server_time;
+
/**
- * Signature (already verified).
+ * The encrypted meta data we downloaded.
*/
- struct ANASTASIS_AccountSignatureP sig;
+ const void *meta_data;
/**
- * Hash over @e policy and @e policy_size.
+ * Number of bytes in @e meta_data.
*/
- struct GNUNET_HashCode curr_policy_hash;
+ size_t meta_data_size;
/**
- * The backup we downloaded.
+ * Policy version this @e meta_data is for.
*/
- const void *policy;
+ uint32_t version;
+};
+
+
+/**
+ * Detailed results for meta data download.
+ */
+struct ANASTASIS_MetaDownloadDetails
+{
/**
- * Number of bytes in @e backup.
+ * HTTP status returned.
*/
- size_t policy_size;
+ unsigned int http_status;
/**
- * Policy version returned by the service.
+ * Taler-specific error code, #TALER_EC_NONE on success.
*/
- uint32_t version;
+ enum TALER_ErrorCode ec;
+
+ /**
+ * Full response in JSON, if provided.
+ */
+ const json_t *response;
+
+ /**
+ * Details depending on @e http_status.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Version-sorted array of meta data we downloaded.
+ */
+ const struct ANASTASIS_MetaDataEntry *metas;
+
+ /**
+ * Number of entries in @e metas.
+ */
+ size_t metas_length;
+
+ } ok;
+
+ } details;
+};
+
+
+/**
+ * Callback to process a GET /policy/$POL/meta request
+ *
+ * @param cls closure
+ * @param dd the response details
+ */
+typedef void
+(*ANASTASIS_PolicyMetaLookupCallback) (
+ void *cls,
+ const struct ANASTASIS_MetaDownloadDetails *dd);
+
+
+/**
+ * Does a GET /policy/$POL/meta.
+ *
+ * @param ctx execution context
+ * @param backend_url base URL of the merchant backend
+ * @param anastasis_pub public key of the user's account
+ * @param max_version maximum version number to fetch
+ * @param cb callback which will work the response gotten from the backend
+ * @param cb_cls closure to pass to the callback
+ * @return handle for this operation, NULL upon errors
+ */
+struct ANASTASIS_PolicyMetaLookupOperation *
+ANASTASIS_policy_meta_lookup (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
+ uint32_t max_version,
+ ANASTASIS_PolicyMetaLookupCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a GET /policy/$POL/meta request.
+ *
+ * @param plo cancel the policy lookup operation
+ */
+void
+ANASTASIS_policy_meta_lookup_cancel (
+ struct ANASTASIS_PolicyMetaLookupOperation *plo);
+
+
+/**
+ * Detailed results from the successful download.
+ */
+struct ANASTASIS_DownloadDetails
+{
+
+ /**
+ * HTTP status returned.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler-specific error code, #TALER_EC_NONE on success.
+ */
+ enum TALER_ErrorCode ec;
+
+ /**
+ * Details depending on @e http_status.
+ */
+ union
+ {
+
+ /**
+ * Details on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Signature (already verified).
+ */
+ struct ANASTASIS_AccountSignatureP sig;
+
+ /**
+ * Hash over @e policy and @e policy_size.
+ */
+ struct GNUNET_HashCode curr_policy_hash;
+
+ /**
+ * The backup we downloaded.
+ */
+ const void *policy;
+
+ /**
+ * Number of bytes in @e backup.
+ */
+ size_t policy_size;
+
+ /**
+ * Policy version returned by the service.
+ */
+ uint32_t version;
+ } ok;
+
+ } details;
+
};
@@ -197,13 +368,10 @@ struct ANASTASIS_PolicyLookupOperation;
* Callback to process a GET /policy request
*
* @param cls closure
- * @param http_status HTTP status code for this request
- * @param ec anastasis-specific error code
- * @param obj the response body
+ * @param dd the response details
*/
typedef void
(*ANASTASIS_PolicyLookupCallback) (void *cls,
- unsigned int http_status,
const struct ANASTASIS_DownloadDetails *dd);
@@ -337,7 +505,7 @@ struct ANASTASIS_UploadDetails
* At what time is the provider set to forget this
* policy (because the account expires)?
*/
- struct GNUNET_TIME_Absolute policy_expiration;
+ struct GNUNET_TIME_Timestamp policy_expiration;
/**
* Version number of the resulting policy.
@@ -371,8 +539,7 @@ struct ANASTASIS_UploadDetails
* Callback to process a POST /policy request
*
* @param cls closure
- * @param http_status HTTP status code for this request
- * @param obj the decoded response body
+ * @param up the decoded response body
*/
typedef void
(*ANASTASIS_PolicyStoreCallback) (void *cls,
@@ -387,6 +554,8 @@ typedef void
* @param anastasis_priv private key of the user's account
* @param recovery_data policy data to be stored
* @param recovery_data_size number of bytes in @a recovery_data
+ * @param recovery_meta_data policy meta data to be stored
+ * @param recovery_meta_data_size number of bytes in @a recovery_meta_data
* @param payment_years_requested for how many years would the client like the service to store the truth?
* @param payment_secret payment identifier of last payment
* @param payment_timeout how long to wait for the payment, use
@@ -402,6 +571,8 @@ ANASTASIS_policy_store (
const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
const void *recovery_data,
size_t recovery_data_size,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size,
uint32_t payment_years_requested,
const struct ANASTASIS_PaymentSecretP *payment_secret,
struct GNUNET_TIME_Relative payment_timeout,
@@ -423,299 +594,418 @@ ANASTASIS_policy_store_cancel (
/**
- * Operational status.
+ * Handle for a POST /truth operation.
+ */
+struct ANASTASIS_TruthStoreOperation;
+
+
+/**
+ * Callback to process a POST /truth request
+ *
+ * @param cls closure
+ * @param obj the response body
+ */
+typedef void
+(*ANASTASIS_TruthStoreCallback) (void *cls,
+ const struct ANASTASIS_UploadDetails *up);
+
+
+/**
+ * Store Truth, does a POST /truth/$UUID
+ *
+ * @param ctx the CURL context used to connect to the backend
+ * @param backend_url backend's base URL, including final "/"
+ * @param uuid unique identfication of the Truth Upload
+ * @param type type of the authorization method
+ * @param encrypted_keyshare key material to return to the client upon authorization
+ * @param truth_mime mime type of @e encrypted_truth (after decryption)
+ * @param encrypted_truth_size number of bytes in @e encrypted_truth
+ * @param encrypted_truth contains the @a type-specific authorization data
+ * @param payment_years_requested for how many years would the client like the service to store the truth?
+ * @param payment_timeout how long to wait for the payment, use
+ * #GNUNET_TIME_UNIT_ZERO to let the server pick
+ * @param cb callback processing the response from /truth
+ * @param cb_cls closure for cb
+ * @return handle for the operation
+ */
+struct ANASTASIS_TruthStoreOperation *
+ANASTASIS_truth_store (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid,
+ const char *type,
+ const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *encrypted_keyshare,
+ const char *truth_mime,
+ size_t encrypted_truth_size,
+ const void *encrypted_truth,
+ uint32_t payment_years_requested,
+ struct GNUNET_TIME_Relative payment_timeout,
+ ANASTASIS_TruthStoreCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel a POST /truth request.
+ *
+ * @param tso the truth store operation
+ */
+void
+ANASTASIS_truth_store_cancel (
+ struct ANASTASIS_TruthStoreOperation *tso);
+
+
+/**
+ * Possible ways how to proceed with a challenge.
*/
-enum ANASTASIS_KeyShareDownloadStatus
+enum ANASTASIS_ChallengeDetailType
{
- /**
- * We got the encrypted key share.
- */
- ANASTASIS_KSD_SUCCESS = 0,
/**
- * Payment is needed to proceed with the recovery.
+ * A challenge TAN was written to a file.
+ * The name of the file is provided.
*/
- ANASTASIS_KSD_PAYMENT_REQUIRED,
+ ANASTASIS_CS_FILE_WRITTEN,
/**
- * The provided answer was wrong or missing. Instructions for
- * getting a good answer may be provided.
+ * A challenge TAN was sent to the customer.
+ * A hint may be provided as to the address used.
*/
- ANASTASIS_KSD_INVALID_ANSWER,
+ ANASTASIS_CS_TAN_SENT,
/**
- * To answer the challenge, the client should be redirected to
- * the given URL.
+ * A challenge TAN was already recently sent to the customer.
+ * A hint may be provided as to the address used.
*/
- ANASTASIS_KSD_REDIRECT_FOR_AUTHENTICATION,
+ ANASTASIS_CS_TAN_ALREADY_SENT,
/**
- * The provider had an error.
+ * The customer should wire funds to the bank
+ * account address provided.
*/
- ANASTASIS_KSD_SERVER_ERROR,
+ ANASTASIS_CS_WIRE_FUNDS
+
+};
+
+
+/**
+ * This structure contains information about where to wire the funds
+ * to authenticate as well as a hint as to which bank account to send
+ * the funds from.
+ */
+struct ANASTASIS_WireFundsDetails
+{
/**
- * The provider claims we made an error.
+ * Answer code expected.
*/
- ANASTASIS_KSD_CLIENT_FAILURE,
+ uint64_t answer_code;
/**
- * The provider does not know this truth.
+ * How much should be sent.
*/
- ANASTASIS_KSD_TRUTH_UNKNOWN,
+ struct TALER_Amount amount;
/**
- * Too many attempts to solve the challenge were made in a short
- * time. Try again later.
+ * IBAN where to send the funds.
*/
- ANASTASIS_KSD_RATE_LIMIT_EXCEEDED,
+ const char *target_iban;
/**
- * The user did not satisfy the (external)
- * authentication check until the request timeout
- * was reached. The client should try again later.
+ * Name of the business receiving the funds.
*/
- ANASTASIS_KSD_AUTHENTICATION_TIMEOUT,
+ const char *target_business_name;
/**
- * The plugin provided external challenge instructions
- * that should be followed. They are method-specific.
+ * Wire transfer subject to use.
*/
- ANASTASIS_KSD_EXTERNAL_CHALLENGE_INSTRUCTIONS
+ const char *wire_transfer_subject;
};
/**
- * Detailed results from the successful download.
+ * Information returned for a POST /truth/$TID/challenge request.
*/
-struct ANASTASIS_KeyShareDownloadDetails
+struct ANASTASIS_TruthChallengeDetails
{
+ /**
+ * HTTP status returned by the server.
+ */
+ unsigned int http_status;
/**
- * Operational status.
+ * Taler-specific error code, #TALER_EC_NONE on success.
*/
- enum ANASTASIS_KeyShareDownloadStatus status;
+ enum TALER_ErrorCode ec;
/**
- * Anastasis URL that returned the @e status.
+ * Full response in JSON, if provided.
*/
- const char *server_url;
+ const json_t *response;
/**
- * Details depending on @e status.
+ * Details depending on @e http_status.
*/
union
{
/**
- * The encrypted key share (if @e status is #ANASTASIS_KSD_SUCCESS).
- */
- struct ANASTASIS_CRYPTO_EncryptedKeyShareP eks;
-
- /**
- * Response if the challenge still needs to be answered, and the
- * instructions are provided inline (no redirection).
+ * Information for @e http_status of #MHD_HTTP_OK.
*/
struct
{
-
- /**
- * HTTP status returned by the server. #MHD_HTTP_ALREADY_REPORTED
- * if the server did already send the challenge to the user,
- * #MHD_HTTP_FORBIDDEN if the answer was wrong (or missing).
- */
- unsigned int http_status;
-
- /**
- * Response with server-side reply containing instructions for the user
- */
- const char *body;
-
/**
- * Content-type: mime type of @e body, NULL if server did not provide any.
+ * Meta-state about how the challenge was
+ * initiated and what is to be done next.
*/
- const char *content_type;
+ enum ANASTASIS_ChallengeDetailType cs;
/**
- * Number of bytes in @e body.
+ * Details depending on @e cs.
*/
- size_t body_size;
-
- } open_challenge;
+ union
+ {
+
+ /**
+ * If @e cs is #ANASTASIS_CS_FILE_WRITTEN, this
+ * is the filename with the challenge code.
+ */
+ const char *challenge_filename;
+
+ /**
+ * If @e cs is #ANASTASIS_CS_TAN_SENT, this
+ * is human-readable information as to where
+ * the TAN was sent.
+ */
+ const char *tan_address_hint;
+
+ /**
+ * If @e cs is #ANASTASIS_CS_WIRE_FUNDS, this
+ * structure contains information about where
+ * to wire the funds to authenticate as well
+ * as a hint as to which bank account to send
+ * the funds from.
+ */
+ struct ANASTASIS_WireFundsDetails wire_funds;
+
+ } details;
- /**
- * URL with instructions for the user to satisfy the challenge, if
- * @e status is #ANASTASIS_KSD_REDIRECT_FOR_AUTHENTICATION.
- */
- const char *redirect_url;
+ } success;
/**
- * Response with instructions for how to pay, if
- * @e status is #ANASTASIS_KSD_PAYMENT_REQUIRED.
+ * Information returne if @e http_status is #MHD_HTTP_PAYMENT_REQUIRED
*/
struct
{
-
- /**
- * "taler://pay" URL with details how to pay for the challenge.
- */
- const char *taler_pay_uri;
-
/**
- * The order ID from @e taler_pay_uri.
+ * A taler://pay/-URI with a request to pay the annual fee for
+ * the service. Returned if @e us is #ANASTASIS_US_PAYMENT_REQUIRED.
*/
- struct ANASTASIS_PaymentSecretP payment_secret;
-
- } payment_required;
-
-
- /**
- * Response with details about a server-side failure, if
- * @e status is #ANASTASIS_KSD_SERVER_ERROR,
- * #ANASTASIS_KSD_CLIENT_FAILURE or #ANASTASIS_KSD_TRUTH_UNKNOWN.
- */
- struct
- {
+ const char *payment_request;
/**
- * HTTP status returned by the server.
+ * The payment secret (aka order ID) extracted from the @e payment_request.
*/
- unsigned int http_status;
+ struct ANASTASIS_PaymentSecretP ps;
/**
- * Taler-specific error code.
+ * Data extracted from the payto:// URI.
*/
- enum TALER_ErrorCode ec;
-
- } server_failure;
+ const struct TALER_MERCHANT_PayUriData *pd;
- /**
- * External challenge instructions, if @e status is
- * #ANASTASIS_KSD_EXTERNAL_CHALLENGE_INSTRUCTIONS.
- */
- const json_t *external_challenge;
+ } payment_required;
} details;
+
};
/**
- * Handle for a GET /truth operation.
+ * Handle for a POST /truth/$TID/challenge operation.
*/
-struct ANASTASIS_KeyShareLookupOperation;
+struct ANASTASIS_TruthChallengeOperation;
/**
- * Callback to process a GET /truth request
+ * Callback to process a POST /truth/$TID/challenge response.
*
* @param cls closure
- * @param http_status HTTP status code for this request
- * @param kdd details about the key share
+ * @param tcd details about the key share
*/
typedef void
-(*ANASTASIS_KeyShareLookupCallback) (
+(*ANASTASIS_TruthChallengeCallback) (
void *cls,
- const struct ANASTASIS_KeyShareDownloadDetails *kdd);
+ const struct ANASTASIS_TruthChallengeDetails *tcd);
/**
- * Does a GET /truth.
+ * Makes a POST /truth/$TID/challenge request.
*
* @param ctx execution context
* @param backend_url base URL of the merchant backend
* @param truth_uuid identification of the Truth
* @param truth_key Key used to Decrypt the Truth on the Server
* @param payment_secret secret from the previously done payment NULL to trigger payment
- * @param timeout how long to wait for the payment, use
- * #GNUNET_TIME_UNIT_ZERO to let the server pick
- * @param hashed_answer hashed answer to the challenge
* @param cb callback which will work the response gotten from the backend
* @param cb_cls closure to pass to the callback
* @return handle for this operation, NULL upon errors
*/
-struct ANASTASIS_KeyShareLookupOperation *
-ANASTASIS_keyshare_lookup (
+struct ANASTASIS_TruthChallengeOperation *
+ANASTASIS_truth_challenge (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
const struct ANASTASIS_PaymentSecretP *payment_secret,
- struct GNUNET_TIME_Relative timeout,
- const struct GNUNET_HashCode *hashed_answer,
- ANASTASIS_KeyShareLookupCallback cb,
+ ANASTASIS_TruthChallengeCallback cb,
void *cb_cls);
/**
- * Cancel a GET /truth request.
+ * Cancel a POST /truth/$TID/challenge request.
*
- * @param kslo cancel the key share lookup operation
+ * @param[in] tco operation to cancel
*/
void
-ANASTASIS_keyshare_lookup_cancel (
- struct ANASTASIS_KeyShareLookupOperation *kslo);
+ANASTASIS_truth_challenge_cancel (
+ struct ANASTASIS_TruthChallengeOperation *tco);
/**
- * Handle for a POST /truth operation.
+ * Information returned for a POST /truth/$TID/solve request.
*/
-struct ANASTASIS_TruthStoreOperation;
+struct ANASTASIS_TruthSolveReply
+{
+
+ /**
+ * HTTP status returned by the server.
+ */
+ unsigned int http_status;
+
+ /**
+ * Taler-specific error code, #TALER_EC_NONE on success.
+ */
+ enum TALER_ErrorCode ec;
+
+ /**
+ * Details depending on @e http_status.
+ */
+ union
+ {
+
+ /**
+ * Information returned if @e http_status is #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * The encrypted key share.
+ */
+ struct ANASTASIS_CRYPTO_EncryptedKeyShareP eks;
+
+ } success;
+
+ /**
+ * Information returne if @e http_status is #MHD_HTTP_PAYMENT_REQUIRED
+ */
+ struct
+ {
+ /**
+ * A taler://pay/-URI with a request to pay the annual fee for
+ * the service. Returned if @e us is #ANASTASIS_US_PAYMENT_REQUIRED.
+ */
+ const char *payment_request;
+
+ /**
+ * The payment secret (aka order ID) extracted from the @e payment_request.
+ */
+ struct ANASTASIS_PaymentSecretP ps;
+
+ /**
+ * Data extracted from the payto:// URI.
+ */
+ const struct TALER_MERCHANT_PayUriData *pd;
+
+ } payment_required;
+
+ /**
+ * Information returne if @e http_status is #MHD_HTTP_TOO_MANY_REQUESTS.
+ */
+ struct
+ {
+
+ /**
+ * How many requests are allowed at most per @e request_frequency?
+ */
+ uint32_t request_limit;
+
+ /**
+ * Frequency at which requests are allowed / new challenges are
+ * created.
+ */
+ struct GNUNET_TIME_Relative request_frequency;
+ } too_many_requests;
+
+ } details;
+
+};
/**
- * Callback to process a POST /truth request
+ * Handle for a POST /truth/$TID/solve operation.
+ */
+struct ANASTASIS_TruthSolveOperation;
+
+
+/**
+ * Callback to process a POST /truth/$TID/solve response.
*
* @param cls closure
- * @param obj the response body
+ * @param kdd details about the key share
*/
typedef void
-(*ANASTASIS_TruthStoreCallback) (void *cls,
- const struct ANASTASIS_UploadDetails *up);
+(*ANASTASIS_TruthSolveCallback) (
+ void *cls,
+ const struct ANASTASIS_TruthSolveReply *trs);
/**
- * Store Truth, does a POST /truth/$UUID
+ * Makes a POST /truth/$TID/solve request.
*
- * @param ctx the CURL context used to connect to the backend
- * @param backend_url backend's base URL, including final "/"
- * @param uuid unique identfication of the Truth Upload
- * @param type type of the authorization method
- * @param encrypted_keyshare key material to return to the client upon authorization
- * @param truth_mime mime type of @e encrypted_truth (after decryption)
- * @param encrypted_truth_size number of bytes in @e encrypted_truth
- * @param encrypted_truth contains the @a type-specific authorization data
- * @param payment_years_requested for how many years would the client like the service to store the truth?
- * @param payment_timeout how long to wait for the payment, use
+ * @param ctx execution context
+ * @param backend_url base URL of the merchant backend
+ * @param truth_uuid identification of the Truth
+ * @param truth_key Key used to Decrypt the Truth on the Server
+ * @param payment_secret secret from the previously done payment NULL to trigger payment
+ * @param timeout how long to wait for the payment, use
* #GNUNET_TIME_UNIT_ZERO to let the server pick
- * @param cb callback processing the response from /truth
- * @param cb_cls closure for cb
- * @return handle for the operation
+ * @param hashed_answer hashed answer to the challenge
+ * @param cb callback which will work the response gotten from the backend
+ * @param cb_cls closure to pass to the callback
+ * @return handle for this operation, NULL upon errors
*/
-struct ANASTASIS_TruthStoreOperation *
-ANASTASIS_truth_store (
+struct ANASTASIS_TruthSolveOperation *
+ANASTASIS_truth_solve (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid,
- const char *type,
- const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *encrypted_keyshare,
- const char *truth_mime,
- size_t encrypted_truth_size,
- const void *encrypted_truth,
- uint32_t payment_years_requested,
- struct GNUNET_TIME_Relative payment_timeout,
- ANASTASIS_TruthStoreCallback cb,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ struct GNUNET_TIME_Relative timeout,
+ const struct GNUNET_HashCode *hashed_answer,
+ ANASTASIS_TruthSolveCallback cb,
void *cb_cls);
/**
- * Cancel a POST /truth request.
+ * Cancel a POST /truth/$TID/solve request.
*
- * @param tso the truth store operation
+ * @param[in] tso handle of the operation to cancel
*/
void
-ANASTASIS_truth_store_cancel (
- struct ANASTASIS_TruthStoreOperation *tso);
+ANASTASIS_truth_solve_cancel (
+ struct ANASTASIS_TruthSolveOperation *tso);
#endif /* _ANASTASIS_SERVICE_H */
diff --git a/src/include/anastasis_testing_lib.h b/src/include/anastasis_testing_lib.h
index a6c1fba..62cde06 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -32,231 +32,125 @@
#define ANASTASIS_FAIL() \
do {GNUNET_break (0); return NULL; } while (0)
-/**
- * Index used in #ANASTASIS_TESTING_get_trait_hash() for the current hash.
- */
-#define ANASTASIS_TESTING_TRAIT_HASH_CURRENT 0
-
-/**
- * Obtain a hash from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number, use #ANASTASIS_TESTING_TRAIT_HASH_CURRENT
- * @param[out] h set to the hash coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_hash (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct GNUNET_HashCode **h);
-
-
-/**
- * Offer a hash.
- *
- * @param index the number's index number.
- * @param h the hash to offer.
- * @return trait on success.
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_hash (unsigned int index,
- const struct GNUNET_HashCode *h);
-
-
-/**
- * Obtain a truth decryption key from @a cmd.
- *
- * @param cmd command to extract the public key from.
- * @param index usually 0
- * @param[out] key set to the account public key used in @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_truth_key (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthKeyP **key);
-
-
-/**
- * Offer an truth decryption key.
- *
- * @param index usually zero
- * @param h the account_pub to offer.
- * @return trait on success.
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth_key (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthKeyP *h);
-
-
-/**
- * Obtain an account public key from @a cmd.
- *
- * @param cmd command to extract the public key from.
- * @param index usually 0
- * @param[out] pub set to the account public key used in @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_account_pub (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPublicKeyP **pub);
-
-
-/**
- * Offer an account public key.
- *
- * @param index usually zero
- * @param h the account_pub to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_pub (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPublicKeyP *h);
-
-
-/**
- * Obtain an account private key from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index must be 0
- * @param[out] priv set to the account private key used in @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_account_priv (
- const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPrivateKeyP **priv);
-
/**
- * Offer an account private key.
- *
- * @param index usually zero
- * @param priv the account_priv to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_priv (
- unsigned int index,
- const struct
- ANASTASIS_CRYPTO_AccountPrivateKeyP *priv);
-
-/**
- * Obtain an account public key from @a cmd.
- *
- * @param cmd command to extract the payment identifier from.
- * @param index the payment identifier's index number.
- * @param[out] payment_secret set to the payment secret coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_payment_secret (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_PaymentSecretP **payment_secret);
-
-
-/**
- * Offer a payment secret.
- *
- * @param index usually zero
- * @param h the payment secret to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_payment_secret (
- unsigned int index,
- const struct ANASTASIS_PaymentSecretP *h);
+ * Create headers for a trait with name @a name for
+ * statically allocated data of type @a type.
+ */
+#define ANASTASIS_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ ANASTASIS_TESTING_get_trait_ ## name ( \
+ const struct TALER_TESTING_Command *cmd, \
+ type **ret); \
+ struct TALER_TESTING_Trait \
+ ANASTASIS_TESTING_make_trait_ ## name ( \
+ type * value);
+
+
+/**
+ * Create C implementation for a trait with name @a name for statically
+ * allocated data of type @a type.
+ */
+#define ANASTASIS_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ ANASTASIS_TESTING_get_trait_ ## name ( \
+ const struct TALER_TESTING_Command *cmd, \
+ type **ret) \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
+ TALER_S (name), \
+ 0); \
+ } \
+ struct TALER_TESTING_Trait \
+ ANASTASIS_TESTING_make_trait_ ## name ( \
+ type * value) \
+ { \
+ struct TALER_TESTING_Trait ret = { \
+ .trait_name = TALER_S (name), \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
+ }
/**
- * Obtain an truth UUID from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] tpk set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
+ * Create headers for a trait with name @a name for
+ * statically allocated data of type @a type.
*/
-int
-ANASTASIS_TESTING_get_trait_truth_uuid (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthUUIDP **tpk);
+#define ANASTASIS_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ ANASTASIS_TESTING_get_trait_ ## name ( \
+ const struct TALER_TESTING_Command *cmd, \
+ unsigned int index, \
+ type **ret); \
+ struct TALER_TESTING_Trait \
+ ANASTASIS_TESTING_make_trait_ ## name ( \
+ unsigned int index, \
+ type * value);
/**
- * Offer a truth UUID.
- *
- * @param index the number's index number.
- * @param tpk the UUID to offer.
- * @return trait on success
+ * Create C implementation for a trait with name @a name for statically
+ * allocated data of type @a type.
*/
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth_uuid (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *tpk);
+#define ANASTASIS_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \
+ enum GNUNET_GenericReturnValue \
+ ANASTASIS_TESTING_get_trait_ ## name ( \
+ const struct TALER_TESTING_Command *cmd, \
+ unsigned int index, \
+ type **ret) \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
+ TALER_S (name), \
+ index); \
+ } \
+ struct TALER_TESTING_Trait \
+ ANASTASIS_TESTING_make_trait_ ## name ( \
+ unsigned int index, \
+ type * value) \
+ { \
+ struct TALER_TESTING_Trait ret = { \
+ .index = index, \
+ .trait_name = TALER_S (name), \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
+ }
/**
- * Obtain an encrypted key share from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] eks set to the key share coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_eks (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_EncryptedKeyShareP **eks);
-
-
-/**
- * Offer an encrypted key share.
- *
- * @param index the number's index number.
- * @param eks the encrypted key share to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_eks (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *eks);
-
-
-/**
- * Obtain a code from @a cmd.
- *
- * @param cmd command to extract the number from.
- * @param index the number's index number.
- * @param[out] code set to the number coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_code (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **code);
-
-
-/**
- * Offer an authentication code.
- *
- * @param index the number's index number.
- * @param code the code to offer.
- * @return trait on success
+ * Call #op on all simple traits.
*/
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_code (unsigned int index,
- const char *code);
+#define ANASTASIS_TESTING_SIMPLE_TRAITS(op) \
+ op (hash, const struct GNUNET_HashCode) \
+ op (truth, const struct ANASTASIS_Truth *) \
+ op (policy, const struct ANASTASIS_Policy *) \
+ op (provider_salt, const struct ANASTASIS_CRYPTO_ProviderSaltP) \
+ op (core_secret, const void) \
+ op (truth_key, const struct ANASTASIS_CRYPTO_TruthKeyP) \
+ op (account_pub, const struct ANASTASIS_CRYPTO_AccountPublicKeyP) \
+ op (account_priv, const struct ANASTASIS_CRYPTO_AccountPrivateKeyP) \
+ op (payment_secret, const struct ANASTASIS_PaymentSecretP) \
+ op (truth_uuid, const struct ANASTASIS_CRYPTO_TruthUUIDP) \
+ op (eks, const struct ANASTASIS_CRYPTO_EncryptedKeyShareP) \
+ op (code, const char) \
+ op (filename, const char)
+
+
+/**
+ * Call #op on all indexed traits.
+ */
+#define ANASTASIS_TESTING_INDEXED_TRAITS(op) \
+ op (challenges, const struct ANASTASIS_Challenge *)
+
+
+ANASTASIS_TESTING_SIMPLE_TRAITS (ANASTASIS_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+
+ANASTASIS_TESTING_INDEXED_TRAITS (ANASTASIS_TESTING_MAKE_DECL_INDEXED_TRAIT)
/**
@@ -480,7 +374,7 @@ ANASTASIS_TESTING_cmd_truth_question (
/**
- * Make the "keyshare lookup" command.
+ * Make a "truth challenge" command.
*
* @param label command label
* @param anastasis_url base URL of the ANASTASIS serving
@@ -488,48 +382,41 @@ ANASTASIS_TESTING_cmd_truth_question (
* @param answer (response to challenge)
* @param payment_ref reference to the payment request
* @param upload_ref reference to upload command
- * @param lookup_mode 0 for security question, 1 for
- * code-based
- * @param ksdd expected status
+ * @param http_status expected HTTP status
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_keyshare_lookup (
+ANASTASIS_TESTING_cmd_truth_challenge (
const char *label,
const char *anastasis_url,
- const char *answer,
const char *payment_ref,
const char *upload_ref,
- int lookup_mode,
- enum ANASTASIS_KeyShareDownloadStatus ksdd);
-
-
-/**
- * Obtain a salt from @a cmd.
- *
- * @param cmd command to extract the salt from.
- * @param index the salt's index number.
- * @param[out] s set to the salt coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_salt (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_ProviderSaltP **s);
+ unsigned int http_status);
/**
- * Offer an salt.
+ * Make a "truth solve" command.
*
- * @param index the salt's index number.
- * @param s the salt to offer.
- * @return trait on success
+ * @param label command label
+ * @param anastasis_url base URL of the ANASTASIS serving
+ * the keyshare lookup request.
+ * @param answer (response to challenge)
+ * @param payment_ref reference to the payment request
+ * @param upload_ref reference to upload command
+ * @param lookup_mode 0 for security question, 1 for
+ * code-based
+ * @param http_status expected HTTP status
+ * @return the command
*/
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_salt (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_ProviderSaltP *s);
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_truth_solve (
+ const char *label,
+ const char *anastasis_url,
+ const char *answer,
+ const char *payment_ref,
+ const char *upload_ref,
+ int lookup_mode,
+ unsigned int http_status);
/**
@@ -549,31 +436,6 @@ ANASTASIS_TESTING_cmd_config (const char *label,
/* ********************* test truth upload ********************* */
/**
- * Obtain a truth from @a cmd.
- *
- * @param cmd command to extract the truth from.
- * @param index the index of the truth
- * @param[out] t set to the truth coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_truth (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_Truth **t);
-
-
-/**
- * Offer a truth.
- *
- * @param index the truth's index number.
- * @param t the truth to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth (unsigned int index,
- const struct ANASTASIS_Truth *t);
-
-/**
* Creates a sample of id_data.
*
* @param id_data some sample data (e.g. AHV, name, surname, ...)
@@ -642,31 +504,6 @@ ANASTASIS_TESTING_cmd_truth_upload_question (
/* ********************* test policy create ********************* */
-/**
- * Obtain a policy from @a cmd.
- *
- * @param cmd command to extract the policy from.
- * @param index the index of the policy
- * @param[out] p set to the policy coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_policy (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_Policy **p);
-
-
-/**
- * Offer a policy.
- *
- * @param index the policy's index number.
- * @param p the policy to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_policy (unsigned int index,
- const struct ANASTASIS_Policy *p);
-
/**
* Make the "policy create" command.
@@ -682,31 +519,6 @@ ANASTASIS_TESTING_cmd_policy_create (const char *label,
/* ********************* test secret share ********************* */
-/**
- * Obtain the core secret from @a cmd.
- *
- * @param cmd command to extract the core secret from.
- * @param index the index of the core secret (usually 0)
- * @param[out] s set to the core secret coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_core_secret (const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const void **s);
-
-
-/**
- * Offer the core secret.
- *
- * @param index the core secret's index number (usually 0).
- * @param s the core secret to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_core_secret (unsigned int index,
- const void *s);
/**
* Types of options for performing the secret sharing. Used as a bitmask.
@@ -740,7 +552,7 @@ enum ANASTASIS_TESTING_SecretShareOption
* @param id_data ID data to generate user identifier
* @param core_secret core secret to backup/recover
* @param core_secret_size size of @a core_secret
- * @param http_status expected HTTP status.
+ * @param want_status expected status.
* @param sso secret share options
* @param ... NULL-terminated list of policy create commands
* @return the command
@@ -754,7 +566,7 @@ ANASTASIS_TESTING_cmd_secret_share (
const json_t *id_data,
const void *core_secret,
size_t core_secret_size,
- unsigned int http_status,
+ enum ANASTASIS_ShareStatus want_status,
enum ANASTASIS_TESTING_SecretShareOption sso,
...);
@@ -824,30 +636,6 @@ ANASTASIS_TESTING_cmd_recover_secret_finish (
/* ********************* test challenge answer ********************* */
-/**
- * Obtain a challenge from @a cmd.
- *
- * @param cmd command to extract the challenge from.
- * @param index the index of the challenge
- * @param[out] c set to the challenge coming from @a cmd.
- * @return #GNUNET_OK on success.
- */
-int
-ANASTASIS_TESTING_get_trait_challenge (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_Challenge **c);
-
-/**
- * Offer a challenge.
- *
- * @param index the challenge index number.
- * @param r the challenge to offer.
- * @return trait on success
- */
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_challenge (unsigned int index,
- const struct ANASTASIS_Challenge *r);
-
/**
* Create a "challenge start" command. Suitable for the "file"
@@ -866,7 +654,7 @@ ANASTASIS_TESTING_cmd_challenge_start (
const char *payment_ref,
const char *challenge_ref,
unsigned int challenge_index,
- enum ANASTASIS_ChallengeStatus expected_cs);
+ enum ANASTASIS_ChallengeStartStatus expected_cs);
/**
@@ -890,7 +678,7 @@ ANASTASIS_TESTING_cmd_challenge_answer (
unsigned int challenge_index,
const char *answer,
unsigned int mode,
- enum ANASTASIS_ChallengeStatus expected_cs);
+ enum ANASTASIS_ChallengeAnswerStatus expected_cs);
#endif
diff --git a/src/include/anastasis_util_lib.h b/src/include/anastasis_util_lib.h
index e780d82..602e1cc 100644
--- a/src/include/anastasis_util_lib.h
+++ b/src/include/anastasis_util_lib.h
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -30,6 +30,17 @@
/**
+ * Maximum value allowed for PINs. Limited to 10^15 < 2^52 to ensure the
+ * numeric value survives a conversion to float by JavaScript.
+ *
+ * NOTE: Do not change this value, we map it to a string like
+ * 42353-256-6521-241 and that mapping fails if the number
+ * does not have exactly 15 digits!
+ */
+#define ANASTASIS_PIN_MAX_VALUE 1000000000000000
+
+
+/**
* Return default project data used by Anastasis.
*/
const struct GNUNET_OS_ProjectData *
@@ -86,4 +97,26 @@ void
ANASTASIS_wait_child_cancel (struct ANASTASIS_ChildWaitHandle *cwh);
+/**
+ * Convert input string @a as into @a pin.
+ *
+ * @param as input of the form 42355-256-2262-265
+ * @param[out] pin set to numeric pin
+ * @return false if @as is malformed
+ */
+bool
+ANASTASIS_scan_pin (const char *as,
+ unsigned long long *pin);
+
+
+/**
+ * Convert numeric pin to human-readable number for display.
+ *
+ * @param pin number to convert
+ * @return static (!) buffer with the text to show
+ */
+const char *
+ANASTASIS_pin2s (uint64_t pin);
+
+
#endif
diff --git a/src/include/gettext.h b/src/include/gettext.h
index 705487b..3929b11 100644
--- a/src/include/gettext.h
+++ b/src/include/gettext.h
@@ -73,8 +73,8 @@
# undef ngettext
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 \
- ? ((void) (Msgid2), (const char *) (Msgid1)) \
- : ((void) (Msgid1), (const char *) (Msgid2)))
+ ? ((void) (Msgid2), (const char *) (Msgid1)) \
+ : ((void) (Msgid1), (const char *) (Msgid2)))
# undef dngettext
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
diff --git a/src/include/platform.h b/src/include/platform.h
index 7667460..0fd6672 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -26,10 +26,10 @@
/* Include our configuration header */
#ifndef HAVE_USED_CONFIG_H
-# define HAVE_USED_CONFIG_H
-# ifdef HAVE_CONFIG_H
-# include "anastasis_config.h"
-# endif
+#define HAVE_USED_CONFIG_H
+#ifdef HAVE_CONFIG_H
+#include "anastasis_config.h"
+#endif
#endif
@@ -69,8 +69,210 @@
/* Include the features available for GNU source */
#define _GNU_SOURCE
-/* Include GNUnet's platform file */
-#include <gnunet/platform.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef __clang__
+#undef HAVE_STATIC_ASSERT
+#endif
+
+/**
+ * These may be expensive, but good for debugging...
+ */
+#define ALLOW_EXTRA_CHECKS GNUNET_YES
+
+/**
+ * For strptime (glibc2 needs this).
+ */
+#ifndef _XOPEN_SOURCE
+#define _XOPEN_SOURCE 499
+#endif
+
+#ifndef _REENTRANT
+#define _REENTRANT
+#endif
+
+/* configuration options */
+
+#define VERBOSE_STATS 0
+
+#include <netdb.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IP_H
+#include <netinet/ip.h> /* superset of previous */
+#endif
+#include <arpa/inet.h>
+#include <netinet/tcp.h>
+#include <pwd.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <grp.h>
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <signal.h>
+#include <libgen.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h> /* for mallinfo on GNU */
+#endif
+#include <unistd.h> /* KLB_FIX */
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h> /* KLB_FIX */
+#include <fcntl.h>
+#include <math.h>
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <time.h>
+#ifdef BSD
+#include <net/if.h>
+#endif
+#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
+#include <semaphore.h>
+#endif
+#ifdef DARWIN
+#include <dlfcn.h>
+#include <semaphore.h>
+#include <net/if.h>
+#endif
+#if defined(__linux__) || defined(GNU)
+#include <net/if.h>
+#endif
+#ifdef SOLARIS
+#include <sys/sockio.h>
+#include <sys/filio.h>
+#include <sys/loadavg.h>
+#include <semaphore.h>
+#endif
+#if HAVE_UCRED_H
+#include <ucred.h>
+#endif
+#if HAVE_SYS_UCRED_H
+#include <sys/ucred.h>
+#endif
+#if HAVE_IFADDRS_H
+#include <ifaddrs.h>
+#endif
+#include <errno.h>
+#include <limits.h>
+
+#if HAVE_VFORK_H
+#include <vfork.h>
+#endif
+
+#include <ctype.h>
+#if HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#if HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+#if HAVE_SYS_ENDIAN_H
+#include <sys/endian.h>
+#endif
+
+#define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_STR "/"
+#define PATH_SEPARATOR ':'
+#define PATH_SEPARATOR_STR ":"
+#define NEWLINE "\n"
+
+#include <locale.h>
+#include "gettext.h"
+/**
+ * GNU gettext support macro.
+ */
+#define _(String) dgettext (PACKAGE, String)
+#define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
+
+#include <sys/mman.h>
+
+/* FreeBSD_kernel is not defined on the now discontinued kFreeBSD */
+#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
+#define __BYTE_ORDER BYTE_ORDER
+#define __BIG_ENDIAN BIG_ENDIAN
+#endif
+
+#ifdef DARWIN
+#define __BYTE_ORDER BYTE_ORDER
+#define __BIG_ENDIAN BIG_ENDIAN
+/* not available on darwin, override configure */
+#undef HAVE_STAT64
+#undef HAVE_MREMAP
+#endif
+
+#if ! HAVE_ATOLL
+long long
+atoll (const char *nptr);
+
+#endif
+
+#if ENABLE_NLS
+#include "langinfo.h"
+#endif
+
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t) (-1))
+#endif
+
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
+/**
+ * AI_NUMERICSERV not defined in windows. Then we just do without.
+ */
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV 0
+#endif
+
+
+#if defined(__sparc__)
+#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
+ sizeof((val))); \
+ __tmp; })
+#else
+#define MAKE_UNALIGNED(val) val
+#endif
+
+/**
+ * The termination signal
+ */
+#define GNUNET_TERM_SIG SIGTERM
+
+
+#ifndef PATH_MAX
+/**
+ * Assumed maximum path length.
+ */
+#define PATH_MAX 4096
+#endif
+
+#if HAVE_THREAD_LOCAL_GCC
+#define ANASTASIS_THREAD_LOCAL __thread
+#else
+#define ANASTASIS_THREAD_LOCAL
+#endif
+
/* Do not use shortcuts for gcrypt mpi */
#define GCRYPT_NO_MPI_MACROS 1
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 07460d4..6f71418 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -14,6 +14,7 @@ libanastasis_la_LDFLAGS = \
-no-undefined
libanastasis_la_SOURCES = \
anastasis_backup.c \
+ anastasis_meta.c \
anastasis_recovery.c
libanastasis_la_LIBADD = \
$(top_builddir)/src/util/libanastasisutil.la \
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 95e9ee9..24d9643 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -55,7 +55,7 @@ struct ANASTASIS_Truth
/**
* Server salt used to derive hash from security answer
*/
- struct ANASTASIS_CRYPTO_QuestionSaltP salt;
+ struct ANASTASIS_CRYPTO_QuestionSaltP question_salt;
/**
* Url of the server
@@ -97,7 +97,8 @@ ANASTASIS_truth_from_json (const json_t *json)
&instructions),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("mime_type",
- &mime_type)),
+ &mime_type),
+ NULL),
GNUNET_JSON_spec_fixed_auto ("uuid",
&t->uuid),
GNUNET_JSON_spec_fixed_auto ("nonce",
@@ -106,8 +107,8 @@ ANASTASIS_truth_from_json (const json_t *json)
&t->key_share),
GNUNET_JSON_spec_fixed_auto ("truth_key",
&t->truth_key),
- GNUNET_JSON_spec_fixed_auto ("salt",
- &t->salt),
+ GNUNET_JSON_spec_fixed_auto ("question_salt",
+ &t->question_salt),
GNUNET_JSON_spec_fixed_auto ("provider_salt",
&t->provider_salt),
GNUNET_JSON_spec_end ()
@@ -141,8 +142,8 @@ ANASTASIS_truth_to_json (const struct ANASTASIS_Truth *t)
&t->key_share),
GNUNET_JSON_pack_data_auto ("truth_key",
&t->truth_key),
- GNUNET_JSON_pack_data_auto ("salt",
- &t->salt),
+ GNUNET_JSON_pack_data_auto ("question_salt",
+ &t->question_salt),
GNUNET_JSON_pack_data_auto ("nonce",
&t->nonce),
GNUNET_JSON_pack_data_auto ("provider_salt",
@@ -251,7 +252,7 @@ ANASTASIS_truth_upload3 (struct GNUNET_CURL_Context *ctx,
truth_data_size);
ANASTASIS_CRYPTO_secure_answer_hash (answer,
&t->uuid,
- &t->salt,
+ &t->question_salt,
&nt);
ANASTASIS_CRYPTO_keyshare_encrypt (&t->key_share,
&tu->id,
@@ -313,7 +314,7 @@ ANASTASIS_truth_upload2 (
struct GNUNET_TIME_Relative pay_timeout,
const struct ANASTASIS_CRYPTO_NonceP *nonce,
const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid,
- const struct ANASTASIS_CRYPTO_QuestionSaltP *salt,
+ const struct ANASTASIS_CRYPTO_QuestionSaltP *question_salt,
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
const struct ANASTASIS_CRYPTO_KeyShareP *key_share,
ANASTASIS_TruthCallback tc,
@@ -325,13 +326,13 @@ ANASTASIS_truth_upload2 (
t->url = GNUNET_strdup (provider_url);
t->type = GNUNET_strdup (type);
t->instructions = (NULL != instructions)
- ? GNUNET_strdup (instructions)
- : NULL;
+ ? GNUNET_strdup (instructions)
+ : NULL;
t->mime_type = (NULL != mime_type)
- ? GNUNET_strdup (mime_type)
- : NULL;
+ ? GNUNET_strdup (mime_type)
+ : NULL;
t->provider_salt = *provider_salt;
- t->salt = *salt;
+ t->question_salt = *question_salt;
t->nonce = *nonce;
t->uuid = *uuid;
t->truth_key = *truth_key;
@@ -442,7 +443,7 @@ struct ANASTASIS_Policy
/**
* Salt used to encrypt the master key
*/
- struct ANASTASIS_CRYPTO_MasterSaltP salt;
+ struct ANASTASIS_CRYPTO_MasterSaltP master_salt;
/**
* Array of truths
@@ -486,8 +487,8 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth *truths[],
p = GNUNET_new (struct ANASTASIS_Policy);
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
- &p->salt,
- sizeof (p->salt));
+ &p->master_salt,
+ sizeof (p->master_salt));
{
struct ANASTASIS_CRYPTO_KeyShareP key_shares[truths_len];
@@ -495,7 +496,7 @@ ANASTASIS_policy_create (const struct ANASTASIS_Truth *truths[],
key_shares[i] = truths[i]->key_share;
ANASTASIS_CRYPTO_policy_key_derive (key_shares,
truths_len,
- &p->salt,
+ &p->master_salt,
&p->policy_key);
}
p->truths = GNUNET_new_array (truths_len,
@@ -541,7 +542,7 @@ struct PolicyStoreState
* Server salt. Points into a truth object from which we got the
* salt.
*/
- struct ANASTASIS_CRYPTO_ProviderSaltP server_salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
/**
* The /policy POST operation handle.
@@ -571,7 +572,7 @@ struct PolicyStoreState
/**
* When will the policy expire at the provider.
*/
- struct GNUNET_TIME_Absolute policy_expiration;
+ struct GNUNET_TIME_Timestamp policy_expiration;
};
@@ -734,6 +735,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
json_t *esc_methods;
size_t recovery_document_size;
char *recovery_document_str;
+ size_t meta_size;
+ void *meta;
if (0 == pss_length)
{
@@ -782,11 +785,12 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
[k]),
GNUNET_JSON_pack_array_steal ("uuids",
uuids),
- GNUNET_JSON_pack_data_auto ("salt",
- &policy->salt))));
+ GNUNET_JSON_pack_data_auto ("master_salt",
+ &policy->master_salt))));
}
esc_methods = json_array ();
+ GNUNET_assert (NULL != esc_methods);
for (unsigned int k = 0; k < policies_len; k++)
{
const struct ANASTASIS_Policy *policy = policies[k];
@@ -826,8 +830,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
pt->instructions),
GNUNET_JSON_pack_data_auto ("truth_key",
&pt->truth_key),
- GNUNET_JSON_pack_data_auto ("truth_salt",
- &pt->salt),
+ GNUNET_JSON_pack_data_auto ("question_salt",
+ &pt->question_salt),
GNUNET_JSON_pack_data_auto ("provider_salt",
&pt->provider_salt),
GNUNET_JSON_pack_string ("escrow_type",
@@ -888,20 +892,39 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
recovery_document_str = (char *) cbuf;
}
+ meta_size = sizeof (struct GNUNET_HashCode);
+ if (NULL != secret_name)
+ meta_size += strlen (secret_name) + 1;
+ meta = GNUNET_malloc (meta_size);
+ GNUNET_CRYPTO_hash (recovery_document_str,
+ recovery_document_size,
+ (struct GNUNET_HashCode *) meta);
+ if (NULL != secret_name)
+ memcpy (meta + sizeof (struct GNUNET_HashCode),
+ secret_name,
+ strlen (secret_name) + 1);
+
for (unsigned int l = 0; l < ss->pss_length; l++)
{
struct PolicyStoreState *pss = &ss->pss[l];
void *recovery_data;
size_t recovery_data_size;
struct ANASTASIS_CRYPTO_AccountPrivateKeyP anastasis_priv;
+ size_t enc_meta_size = 0;
+ void *enc_meta = NULL;
pss->ss = ss;
pss->anastasis_url = GNUNET_strdup (providers[l].provider_url);
- pss->server_salt = providers[l].provider_salt;
+ pss->provider_salt = providers[l].provider_salt;
pss->payment_secret = providers[l].payment_secret;
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- &pss->server_salt,
+ &pss->provider_salt,
&pss->id);
+ ANASTASIS_CRYPTO_recovery_metadata_encrypt (&pss->id,
+ meta,
+ meta_size,
+ &enc_meta,
+ &enc_meta_size);
ANASTASIS_CRYPTO_account_private_key_derive (&pss->id,
&anastasis_priv);
ANASTASIS_CRYPTO_recovery_document_encrypt (&pss->id,
@@ -918,6 +941,8 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
&anastasis_priv,
recovery_data,
recovery_data_size,
+ enc_meta,
+ enc_meta_size,
payment_years_requested,
(! GNUNET_is_zero (&pss->payment_secret))
? &pss->payment_secret
@@ -926,14 +951,17 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
&policy_store_cb,
pss);
GNUNET_free (recovery_data);
+ GNUNET_free (enc_meta);
if (NULL == pss->pso)
{
GNUNET_break (0);
ANASTASIS_secret_share_cancel (ss);
GNUNET_free (recovery_document_str);
+ GNUNET_free (meta);
return NULL;
}
}
+ GNUNET_free (meta);
GNUNET_free (recovery_document_str);
return ss;
}
diff --git a/src/lib/anastasis_meta.c b/src/lib/anastasis_meta.c
new file mode 100644
index 0000000..ae20db5
--- /dev/null
+++ b/src/lib/anastasis_meta.c
@@ -0,0 +1,178 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @brief anastasis client api to get recovery document meta data
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "anastasis.h"
+#include <taler/taler_json_lib.h>
+#include <gnunet/gnunet_util_lib.h>
+#include <taler/taler_merchant_service.h>
+
+
+/**
+ * Handle for a version check operation.
+ */
+struct ANASTASIS_VersionCheck
+{
+ /**
+ * Function to call with results.
+ */
+ ANASTASIS_MetaPolicyCallback mpc;
+
+ /**
+ * Closure for @e mpc.
+ */
+ void *mpc_cls;
+
+ /**
+ * Handle for the actual REST operation.
+ */
+ struct ANASTASIS_PolicyMetaLookupOperation *plm;
+
+ /**
+ * User identifier (needed to decrypt).
+ */
+ struct ANASTASIS_CRYPTO_UserIdentifierP id;
+};
+
+
+/**
+ * Function called with results from a GET /policy/$POL/meta request
+ *
+ * @param cls closure with the `struct ANASTASIS_VersionCheck *`
+ * @param dd the response details
+ */
+static void
+meta_cb (
+ void *cls,
+ const struct ANASTASIS_MetaDownloadDetails *dd)
+{
+ struct ANASTASIS_VersionCheck *vc = cls;
+
+ vc->plm = NULL;
+ if (MHD_HTTP_OK != dd->http_status)
+ {
+ vc->mpc (vc->mpc_cls,
+ 0,
+ GNUNET_TIME_UNIT_ZERO_TS,
+ NULL,
+ NULL);
+ ANASTASIS_recovery_get_versions_cancel (vc);
+ return;
+ }
+ for (size_t i = 0; i<dd->details.ok.metas_length; i++)
+ {
+ const struct ANASTASIS_MetaDataEntry *meta
+ = &dd->details.ok.metas[i];
+ const char *secret_name = NULL;
+ const struct GNUNET_HashCode *eph;
+ void *dec;
+ size_t dec_len;
+
+ if (GNUNET_OK !=
+ ANASTASIS_CRYPTO_recovery_metadata_decrypt (
+ &vc->id,
+ meta->meta_data,
+ meta->meta_data_size,
+ &dec,
+ &dec_len))
+ {
+ GNUNET_break_op (0);
+ continue;
+ }
+ if (sizeof (*eph) > dec_len)
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (dec);
+ continue;
+ }
+ eph = dec;
+ if (sizeof (*eph) < dec_len)
+ {
+ secret_name = (const char *) &eph[1];
+ dec_len -= sizeof (*eph);
+ if ('\0' != secret_name[dec_len - 1])
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (dec);
+ continue;
+ }
+ }
+ vc->mpc (vc->mpc_cls,
+ meta->version,
+ meta->server_time,
+ eph,
+ secret_name);
+ GNUNET_free (dec);
+ }
+ vc->mpc (vc->mpc_cls,
+ 0,
+ GNUNET_TIME_UNIT_ZERO_TS,
+ NULL,
+ NULL);
+ ANASTASIS_recovery_get_versions_cancel (vc);
+}
+
+
+struct ANASTASIS_VersionCheck *
+ANASTASIS_recovery_get_versions (
+ struct GNUNET_CURL_Context *ctx,
+ const json_t *id_data,
+ unsigned int max_version,
+ const char *anastasis_provider_url,
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt,
+ ANASTASIS_MetaPolicyCallback mpc,
+ void *mpc_cls)
+{
+ struct ANASTASIS_VersionCheck *vc;
+ struct ANASTASIS_CRYPTO_AccountPublicKeyP account_pub;
+
+ vc = GNUNET_new (struct ANASTASIS_VersionCheck);
+ vc->mpc = mpc;
+ vc->mpc_cls = mpc_cls;
+ ANASTASIS_CRYPTO_user_identifier_derive (id_data,
+ provider_salt,
+ &vc->id);
+ ANASTASIS_CRYPTO_account_public_key_derive (&vc->id,
+ &account_pub);
+ vc->plm = ANASTASIS_policy_meta_lookup (ctx,
+ anastasis_provider_url,
+ &account_pub,
+ max_version,
+ &meta_cb,
+ vc);
+ if (NULL == vc->plm)
+ {
+ GNUNET_break (0);
+ GNUNET_free (vc);
+ return NULL;
+ }
+ return vc;
+}
+
+
+void
+ANASTASIS_recovery_get_versions_cancel (struct ANASTASIS_VersionCheck *vc)
+{
+ if (NULL != vc->plm)
+ {
+ ANASTASIS_policy_meta_lookup_cancel (vc->plm);
+ vc->plm = NULL;
+ }
+ GNUNET_free (vc);
+}
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index ef2ccd0..f164c93 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -47,7 +47,7 @@ struct ANASTASIS_Challenge
/**
* Salt; used to derive hash from security question answers.
*/
- struct ANASTASIS_CRYPTO_QuestionSaltP salt;
+ struct ANASTASIS_CRYPTO_QuestionSaltP question_salt;
/**
* Provider salt; used to derive our key material from our identity
@@ -63,16 +63,27 @@ struct ANASTASIS_Challenge
/**
* Callback which gives back the instructions and a status code of
- * the request to the user when answering a challenge was initiated.
+ * the request to the user when answering a challenge.
*/
ANASTASIS_AnswerFeedback af;
/**
- * Closure for the challenge callback
+ * Closure for @e af.
*/
void *af_cls;
/**
+ * Callback which gives back the instructions and a status code of
+ * the request to the user when initiating a challenge.
+ */
+ ANASTASIS_ChallengeStartFeedback csf;
+
+ /**
+ * Closure for @e csf.
+ */
+ void *csf_cls;
+
+ /**
* Defines the base URL of the Anastasis provider used for the challenge.
*/
char *url;
@@ -99,9 +110,14 @@ struct ANASTASIS_Challenge
struct ANASTASIS_Recovery *recovery;
/**
- * keyshare lookup operation
+ * Handle for the /truth/$TID/challenge request.
+ */
+ struct ANASTASIS_TruthChallengeOperation *tco;
+
+ /**
+ * Handle for the /truth/$TID/solve request.
*/
- struct ANASTASIS_KeyShareLookupOperation *kslo;
+ struct ANASTASIS_TruthSolveOperation *tso;
};
@@ -130,7 +146,7 @@ struct DecryptionPolicy
/**
* Salt used to decrypt master key.
*/
- struct ANASTASIS_CRYPTO_MasterSaltP salt;
+ struct ANASTASIS_CRYPTO_MasterSaltP master_salt;
};
@@ -238,161 +254,140 @@ struct ANASTASIS_Recovery
/**
- * Function called with the results of a #ANASTASIS_keyshare_lookup().
+ * Function called with the results of a #ANASTASIS_challenge_start().
*
* @param cls closure
* @param dd details about the lookup operation
*/
static void
-keyshare_lookup_cb (void *cls,
- const struct ANASTASIS_KeyShareDownloadDetails *dd)
+truth_challenge_cb (void *cls,
+ const struct ANASTASIS_TruthChallengeDetails *tcd)
{
struct ANASTASIS_Challenge *c = cls;
- struct ANASTASIS_Recovery *recovery = c->recovery;
- struct ANASTASIS_CRYPTO_UserIdentifierP id;
- struct DecryptionPolicy *rdps;
-
- c->kslo = NULL;
- switch (dd->status)
+ struct ANASTASIS_ChallengeStartResponse csr = {
+ .challenge = c,
+ .ec = tcd->ec,
+ .http_status = tcd->http_status
+ };
+
+ c->tco = NULL;
+ switch (tcd->http_status)
{
- case ANASTASIS_KSD_SUCCESS:
- break;
- case ANASTASIS_KSD_PAYMENT_REQUIRED:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED,
- .challenge = c,
- .details.payment_required.taler_pay_uri
- = dd->details.payment_required.taler_pay_uri,
- .details.payment_required.payment_secret
- = dd->details.payment_required.payment_secret
- };
-
- c->af (c->af_cls,
- &csr);
- return;
- }
- case ANASTASIS_KSD_INVALID_ANSWER:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS,
- .challenge = c,
- .details.open_challenge.body
- = dd->details.open_challenge.body,
- .details.open_challenge.content_type
- = dd->details.open_challenge.content_type,
- .details.open_challenge.body_size
- = dd->details.open_challenge.body_size,
- .details.open_challenge.http_status
- = dd->details.open_challenge.http_status
- };
-
- c->af (c->af_cls,
- &csr);
- return;
- }
- case ANASTASIS_KSD_REDIRECT_FOR_AUTHENTICATION:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_REDIRECT_FOR_AUTHENTICATION,
- .challenge = c,
- .details.redirect_url
- = dd->details.redirect_url
- };
-
- c->af (c->af_cls,
- &csr);
- return;
- }
- case ANASTASIS_KSD_TRUTH_UNKNOWN:
+ case MHD_HTTP_OK:
+ switch (tcd->details.success.cs)
{
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN,
- .challenge = c
- };
-
- c->af (c->af_cls,
- &csr);
- return;
+ case ANASTASIS_CS_FILE_WRITTEN:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_FILENAME_PROVIDED;
+ csr.details.tan_filename
+ = tcd->details.success.details.challenge_filename;
+ break;
+ case ANASTASIS_CS_TAN_SENT:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED;
+ csr.details.tan_address_hint
+ = tcd->details.success.details.tan_address_hint;
+ break;
+ case ANASTASIS_CS_TAN_ALREADY_SENT:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT;
+ break;
+ case ANASTASIS_CS_WIRE_FUNDS:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED;
+ csr.details.bank_transfer_required
+ = tcd->details.success.details.wire_funds;
+ break;
}
- case ANASTASIS_KSD_RATE_LIMIT_EXCEEDED:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED,
- .challenge = c
- };
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED;
+ csr.details.payment_required.taler_pay_uri
+ = tcd->details.payment_required.payment_request;
+ csr.details.payment_required.payment_secret
+ = tcd->details.payment_required.ps;
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_TRUTH_UNKNOWN;
+ break;
+ default:
+ csr.cs = ANASTASIS_CHALLENGE_START_STATUS_SERVER_FAILURE;
+ break;
+ }
+ c->csf (c->csf_cls,
+ &csr);
+}
- c->af (c->af_cls,
- &csr);
- return;
- }
- case ANASTASIS_KSD_SERVER_ERROR:
- case ANASTASIS_KSD_CLIENT_FAILURE:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE,
- .challenge = c,
- .details.server_failure.ec
- = dd->details.server_failure.ec,
- .details.server_failure.http_status
- = dd->details.server_failure.http_status
- };
- c->af (c->af_cls,
- &csr);
- return;
- }
- case ANASTASIS_KSD_AUTHENTICATION_TIMEOUT:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_AUTH_TIMEOUT,
- .challenge = c,
- .details.server_failure.ec
- = dd->details.server_failure.ec,
- .details.server_failure.http_status
- = dd->details.server_failure.http_status
- };
+/**
+ * Function called with the results of a #ANASTASIS_truth_solve().
+ *
+ * @param cls closure
+ * @param tsr details about the solution response
+ */
+static void
+truth_solve_cb (void *cls,
+ const struct ANASTASIS_TruthSolveReply *tsr)
+{
+ struct ANASTASIS_Challenge *c = cls;
+ struct ANASTASIS_Recovery *recovery = c->recovery;
+ struct ANASTASIS_CRYPTO_UserIdentifierP id;
+ struct DecryptionPolicy *rdps;
+ struct ANASTASIS_ChallengeAnswerResponse csr = {
+ .challenge = c,
+ .ec = tsr->ec,
+ .http_status = tsr->http_status
+ };
- c->ci.async = true;
- c->af (c->af_cls,
- &csr);
- return;
- }
- case ANASTASIS_KSD_EXTERNAL_CHALLENGE_INSTRUCTIONS:
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS,
- .challenge = c,
- .details.external_challenge = dd->details.external_challenge
- };
- c->af (c->af_cls,
- &csr);
- return;
- }
+ c->tso = NULL;
+ switch (tsr->http_status)
+ {
+ case MHD_HTTP_OK:
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ csr.cs = ANASTASIS_CHALLENGE_ANSWER_STATUS_PAYMENT_REQUIRED;
+ csr.details.payment_required.taler_pay_uri
+ = tsr->details.payment_required.payment_request;
+ csr.details.payment_required.payment_secret
+ = tsr->details.payment_required.ps;
+ c->af (c->af_cls,
+ &csr);
+ return;
+ case MHD_HTTP_FORBIDDEN:
+ csr.cs = ANASTASIS_CHALLENGE_ANSWER_STATUS_INVALID_ANSWER;
+ c->af (c->af_cls,
+ &csr);
+ return;
+ case MHD_HTTP_NOT_FOUND:
+ csr.cs = ANASTASIS_CHALLENGE_ANSWER_STATUS_TRUTH_UNKNOWN;
+ c->af (c->af_cls,
+ &csr);
+ return;
+ case MHD_HTTP_TOO_MANY_REQUESTS:
+ csr.cs = ANASTASIS_CHALLENGE_ANSWER_STATUS_RATE_LIMIT_EXCEEDED;
+ csr.details.rate_limit_exceeded.request_limit
+ = tsr->details.too_many_requests.request_limit;
+ csr.details.rate_limit_exceeded.request_frequency
+ = tsr->details.too_many_requests.request_frequency;
+ c->af (c->af_cls,
+ &csr);
+ return;
+ default:
+ csr.cs = ANASTASIS_CHALLENGE_ANSWER_STATUS_SERVER_FAILURE;
+ c->af (c->af_cls,
+ &csr);
+ return;
}
- GNUNET_assert (NULL != dd);
ANASTASIS_CRYPTO_user_identifier_derive (recovery->id_data,
&c->provider_salt,
&id);
- ANASTASIS_CRYPTO_keyshare_decrypt (&dd->details.eks,
+ ANASTASIS_CRYPTO_keyshare_decrypt (&tsr->details.success.eks,
&id,
c->answer,
&c->key_share);
recovery->solved_challenges[recovery->solved_challenge_pos++] = c;
-
- {
- struct ANASTASIS_ChallengeStartResponse csr = {
- .cs = ANASTASIS_CHALLENGE_STATUS_SOLVED,
- .challenge = c
- };
-
- c->ci.solved = true;
- c->af (c->af_cls,
- &csr);
- }
-
+ c->ci.solved = true;
+ csr.cs = ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED;
+ c->af (c->af_cls,
+ &csr);
/* Check if there is a policy for which all challenges have
been satisfied, if so, store it in 'rdps'. */
@@ -442,7 +437,7 @@ keyshare_lookup_cb (void *cls,
key_shares[l] = recovery->solved_challenges[m]->key_share;
ANASTASIS_CRYPTO_policy_key_derive (key_shares,
rdps->pub_details.challenges_length,
- &rdps->salt,
+ &rdps->master_salt,
&policy_key);
GNUNET_assert (NULL != rdps->emk);
GNUNET_assert (rdps->emk_size > 0);
@@ -473,33 +468,67 @@ ANASTASIS_challenge_get_details (struct ANASTASIS_Challenge *challenge)
enum GNUNET_GenericReturnValue
ANASTASIS_challenge_start (struct ANASTASIS_Challenge *c,
const struct ANASTASIS_PaymentSecretP *psp,
- struct GNUNET_TIME_Relative timeout,
- const struct GNUNET_HashCode *hashed_answer,
- ANASTASIS_AnswerFeedback af,
- void *af_cls)
+ ANASTASIS_ChallengeStartFeedback csf,
+ void *csf_cls)
{
if (c->ci.solved)
{
GNUNET_break (0);
return GNUNET_NO; /* already solved */
}
- if (NULL != c->kslo)
+ if (NULL != c->tco)
+ {
+ GNUNET_break (0);
+ return GNUNET_NO; /* already solving */
+ }
+ c->csf = csf;
+ c->csf_cls = csf_cls;
+ c->tco = ANASTASIS_truth_challenge (c->recovery->ctx,
+ c->url,
+ &c->ci.uuid,
+ &c->truth_key,
+ psp,
+ &truth_challenge_cb,
+ c);
+ if (NULL == c->tco)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+enum GNUNET_GenericReturnValue
+ANASTASIS_challenge_answer3 (struct ANASTASIS_Challenge *c,
+ const struct ANASTASIS_PaymentSecretP *psp,
+ struct GNUNET_TIME_Relative timeout,
+ const struct GNUNET_HashCode *hashed_answer,
+ ANASTASIS_AnswerFeedback af,
+ void *af_cls)
+{
+ if (c->ci.solved)
+ {
+ GNUNET_break (0);
+ return GNUNET_NO; /* already solved */
+ }
+ if (NULL != c->tso)
{
GNUNET_break (0);
return GNUNET_NO; /* already solving */
}
c->af = af;
c->af_cls = af_cls;
- c->kslo = ANASTASIS_keyshare_lookup (c->recovery->ctx,
- c->url,
- &c->ci.uuid,
- &c->truth_key,
- psp,
- timeout,
- hashed_answer,
- &keyshare_lookup_cb,
- c);
- if (NULL == c->kslo)
+ c->tso = ANASTASIS_truth_solve (c->recovery->ctx,
+ c->url,
+ &c->ci.uuid,
+ &c->truth_key,
+ psp,
+ timeout,
+ hashed_answer,
+ &truth_solve_cb,
+ c);
+ if (NULL == c->tso)
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -520,17 +549,20 @@ ANASTASIS_challenge_answer (
struct GNUNET_HashCode hashed_answer;
GNUNET_free (c->answer);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Answer to challenge is `%s'\n",
+ answer_str);
c->answer = GNUNET_strdup (answer_str);
ANASTASIS_CRYPTO_secure_answer_hash (answer_str,
&c->ci.uuid,
- &c->salt,
+ &c->question_salt,
&hashed_answer);
- return ANASTASIS_challenge_start (c,
- psp,
- timeout,
- &hashed_answer,
- af,
- af_cls);
+ return ANASTASIS_challenge_answer3 (c,
+ psp,
+ timeout,
+ &hashed_answer,
+ af,
+ af_cls);
}
@@ -544,27 +576,33 @@ ANASTASIS_challenge_answer2 (struct ANASTASIS_Challenge *c,
{
struct GNUNET_HashCode answer_s;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Answer to challenge is %llu\n",
+ (unsigned long long) answer);
ANASTASIS_hash_answer (answer,
&answer_s);
- return ANASTASIS_challenge_start (c,
- psp,
- timeout,
- &answer_s,
- af,
- af_cls);
+ return ANASTASIS_challenge_answer3 (c,
+ psp,
+ timeout,
+ &answer_s,
+ af,
+ af_cls);
}
void
ANASTASIS_challenge_abort (struct ANASTASIS_Challenge *c)
{
- if (NULL == c->kslo)
+ if (NULL != c->tso)
{
- GNUNET_break (0);
- return;
+ ANASTASIS_truth_solve_cancel (c->tso);
+ c->tso = NULL;
+ }
+ if (NULL != c->tco)
+ {
+ ANASTASIS_truth_challenge_cancel (c->tco);
+ c->tco = NULL;
}
- ANASTASIS_keyshare_lookup_cancel (c->kslo);
- c->kslo = NULL;
c->af = NULL;
c->af_cls = NULL;
}
@@ -574,23 +612,22 @@ ANASTASIS_challenge_abort (struct ANASTASIS_Challenge *c)
* Function called with the results of a #ANASTASIS_policy_lookup()
*
* @param cls closure
- * @param http_status HTTp status code.
* @param dd details about the lookup operation
*/
static void
policy_lookup_cb (void *cls,
- unsigned int http_status,
const struct ANASTASIS_DownloadDetails *dd)
{
struct ANASTASIS_Recovery *r = cls;
void *plaintext;
size_t size_plaintext;
json_error_t json_error;
- json_t *dec_policies;
- json_t *esc_methods;
+ const json_t *dec_policies;
+ const json_t *esc_methods;
+ json_t *recovery_document;
r->plo = NULL;
- switch (http_status)
+ switch (dd->http_status)
{
case MHD_HTTP_OK:
break;
@@ -622,7 +659,7 @@ policy_lookup_cb (void *cls,
default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u in %s:%u\n",
- http_status,
+ dd->http_status,
__FILE__,
__LINE__);
r->csc (r->csc_cls,
@@ -632,7 +669,7 @@ policy_lookup_cb (void *cls,
ANASTASIS_recovery_abort (r);
return;
}
- if (NULL == dd->policy)
+ if (NULL == dd->details.ok.policy)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No recovery data available");
@@ -644,8 +681,8 @@ policy_lookup_cb (void *cls,
return;
}
ANASTASIS_CRYPTO_recovery_document_decrypt (&r->id,
- dd->policy,
- dd->policy_size,
+ dd->details.ok.policy,
+ dd->details.ok.policy_size,
&plaintext,
&size_plaintext);
if (size_plaintext < sizeof (uint32_t))
@@ -660,7 +697,6 @@ policy_lookup_cb (void *cls,
return;
}
{
- json_t *recovery_document;
uint32_t be_size;
uLongf pt_size;
char *pt;
@@ -723,13 +759,14 @@ policy_lookup_cb (void *cls,
{
const char *secret_name = NULL;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("policies",
- &dec_policies),
- GNUNET_JSON_spec_json ("escrow_methods",
- &esc_methods),
+ GNUNET_JSON_spec_array_const ("policies",
+ &dec_policies),
+ GNUNET_JSON_spec_array_const ("escrow_methods",
+ &esc_methods),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("secret_name",
- &secret_name)),
+ &secret_name),
+ NULL),
GNUNET_JSON_spec_varsize ("encrypted_core_secret",
&r->enc_core_secret,
&r->enc_core_secret_size),
@@ -760,10 +797,9 @@ policy_lookup_cb (void *cls,
r->ri.secret_name = r->secret_name;
}
}
- json_decref (recovery_document);
}
- r->ri.version = dd->version;
+ r->ri.version = dd->details.ok.version;
r->ri.cs_len = json_array_size (esc_methods);
r->ri.dps_len = json_array_size (dec_policies);
r->ri.dps = GNUNET_new_array (r->ri.dps_len,
@@ -785,14 +821,14 @@ policy_lookup_cb (void *cls,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("uuid",
&cs->ci.uuid),
- GNUNET_JSON_spec_string ("url",
+ TALER_JSON_spec_web_url ("url",
&url),
GNUNET_JSON_spec_string ("instructions",
&instructions),
GNUNET_JSON_spec_fixed_auto ("truth_key",
&cs->truth_key),
- GNUNET_JSON_spec_fixed_auto ("truth_salt",
- &cs->salt),
+ GNUNET_JSON_spec_fixed_auto ("question_salt",
+ &cs->question_salt),
GNUNET_JSON_spec_fixed_auto ("provider_salt",
&cs->provider_salt),
GNUNET_JSON_spec_string ("escrow_type",
@@ -809,13 +845,12 @@ policy_lookup_cb (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
- json_decref (esc_methods);
- json_decref (dec_policies);
r->csc (r->csc_cls,
ANASTASIS_RS_POLICY_MALFORMED_JSON,
NULL,
0);
ANASTASIS_recovery_abort (r);
+ json_decref (recovery_document);
return;
}
cs->url = GNUNET_strdup (url);
@@ -825,42 +860,38 @@ policy_lookup_cb (void *cls,
cs->instructions = GNUNET_strdup (instructions);
cs->ci.instructions = cs->instructions;
}
- json_decref (esc_methods);
for (unsigned int j = 0; j < r->ri.dps_len; j++)
{
struct DecryptionPolicy *dp = &r->dps[j];
-
- json_t *uuids = NULL;
+ const json_t *uuids;
json_t *uuid;
size_t n_index;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_varsize ("master_key",
&dp->emk,
&dp->emk_size),
- GNUNET_JSON_spec_fixed_auto ("salt",
- &dp->salt),
- GNUNET_JSON_spec_json ("uuids",
- &uuids),
+ GNUNET_JSON_spec_fixed_auto ("master_salt",
+ &dp->master_salt),
+ GNUNET_JSON_spec_array_const ("uuids",
+ &uuids),
GNUNET_JSON_spec_end ()
};
r->ri.dps[j] = &r->dps[j].pub_details;
- if ( (GNUNET_OK !=
- GNUNET_JSON_parse (json_array_get (dec_policies,
- j),
- spec,
- NULL, NULL)) ||
- (! json_is_array (uuids)) )
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json_array_get (dec_policies,
+ j),
+ spec,
+ NULL, NULL))
{
GNUNET_break_op (0);
- json_decref (uuids);
- json_decref (dec_policies);
r->csc (r->csc_cls,
ANASTASIS_RS_POLICY_MALFORMED_JSON,
NULL,
0);
ANASTASIS_recovery_abort (r);
+ json_decref (recovery_document);
return;
}
@@ -886,13 +917,12 @@ policy_lookup_cb (void *cls,
sizeof (uuid))) )
{
GNUNET_break_op (0);
- json_decref (dec_policies);
- json_decref (uuids);
r->csc (r->csc_cls,
ANASTASIS_RS_POLICY_MALFORMED_JSON,
NULL,
0);
ANASTASIS_recovery_abort (r);
+ json_decref (recovery_document);
return;
}
for (unsigned int i = 0; i<r->ri.cs_len; i++)
@@ -908,21 +938,19 @@ policy_lookup_cb (void *cls,
if (! found)
{
GNUNET_break_op (0);
- json_decref (dec_policies);
- json_decref (uuids);
r->csc (r->csc_cls,
ANASTASIS_RS_POLICY_MALFORMED_JSON,
NULL,
0);
ANASTASIS_recovery_abort (r);
+ json_decref (recovery_document);
return;
}
}
- json_decref (uuids);
}
- json_decref (dec_policies);
r->pc (r->pc_cls,
&r->ri);
+ json_decref (recovery_document);
}
@@ -1012,11 +1040,11 @@ ANASTASIS_recovery_serialize (const struct ANASTASIS_Recovery *r)
}
GNUNET_assert (NULL != dp->emk);
dps = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_varsize ("emk",
+ GNUNET_JSON_pack_data_varsize ("encrypted_master_key",
dp->emk,
dp->emk_size),
- GNUNET_JSON_pack_data_auto ("salt",
- &dp->salt),
+ GNUNET_JSON_pack_data_auto ("master_salt",
+ &dp->master_salt),
GNUNET_JSON_pack_array_steal ("challenges",
c_arr));
GNUNET_assert (0 ==
@@ -1033,10 +1061,12 @@ ANASTASIS_recovery_serialize (const struct ANASTASIS_Recovery *r)
cs = GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("uuid",
&c->ci.uuid),
+ GNUNET_JSON_pack_string ("uuid-display",
+ ANASTASIS_CRYPTO_uuid2s (&c->ci.uuid)),
GNUNET_JSON_pack_data_auto ("truth_key",
&c->truth_key),
- GNUNET_JSON_pack_data_auto ("salt",
- &c->salt),
+ GNUNET_JSON_pack_data_auto ("question_salt",
+ &c->question_salt),
GNUNET_JSON_pack_data_auto ("provider_salt",
&c->provider_salt),
GNUNET_JSON_pack_allow_null (
@@ -1063,9 +1093,9 @@ ANASTASIS_recovery_serialize (const struct ANASTASIS_Recovery *r)
return GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("id",
&r->id),
- GNUNET_JSON_pack_array_steal ("dps",
+ GNUNET_JSON_pack_array_steal ("decryption_policies",
dps_arr),
- GNUNET_JSON_pack_array_steal ("cs",
+ GNUNET_JSON_pack_array_steal ("challenges",
cs_arr),
GNUNET_JSON_pack_uint64 ("version",
r->ri.version),
@@ -1076,22 +1106,24 @@ ANASTASIS_recovery_serialize (const struct ANASTASIS_Recovery *r)
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string ("secret_name",
r->secret_name)),
- GNUNET_JSON_pack_data_varsize ("core_secret",
+ GNUNET_JSON_pack_data_varsize ("encrypted_core_secret",
r->enc_core_secret,
r->enc_core_secret_size));
}
/**
- * Parse the @a cs_array and update @a r accordingly
+ * Parse the @a cs_array with information about
+ * the various challenges and their solution state
+ * and update @a r accordingly
*
* @param[in,out] r recovery information to update
* @param cs_arr serialized data to parse
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
parse_cs_array (struct ANASTASIS_Recovery *r,
- json_t *cs_arr)
+ const json_t *cs_arr)
{
json_t *cs;
unsigned int n_index;
@@ -1114,27 +1146,30 @@ parse_cs_array (struct ANASTASIS_Recovery *r,
const char *instructions;
const char *url;
const char *escrow_type;
+ bool no_key_share;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("uuid",
&c->ci.uuid),
- GNUNET_JSON_spec_string ("url",
+ TALER_JSON_spec_web_url ("url",
&url),
GNUNET_JSON_spec_string ("instructions",
&instructions),
GNUNET_JSON_spec_fixed_auto ("truth_key",
&c->truth_key),
- GNUNET_JSON_spec_fixed_auto ("salt",
- &c->salt),
+ GNUNET_JSON_spec_fixed_auto ("question_salt",
+ &c->question_salt),
GNUNET_JSON_spec_fixed_auto ("provider_salt",
&c->provider_salt),
GNUNET_JSON_spec_string ("type",
&escrow_type),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_bool ("async",
- &c->ci.async)),
+ &c->ci.async),
+ NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto ("key_share",
- &c->key_share)),
+ &c->key_share),
+ &no_key_share),
GNUNET_JSON_spec_end ()
};
@@ -1154,34 +1189,27 @@ parse_cs_array (struct ANASTASIS_Recovery *r,
c->instructions = GNUNET_strdup (instructions);
c->ci.instructions = c->instructions;
c->ci.provider_url = c->url;
+ if (! no_key_share)
{
- json_t *ks;
-
- ks = json_object_get (cs,
- "key_share");
- if ( (NULL != ks) &&
- (! json_is_null (ks)) )
- {
- c->ci.solved = true;
- r->solved_challenges[r->solved_challenge_pos++] = c;
- }
+ c->ci.solved = true;
+ r->solved_challenges[r->solved_challenge_pos++] = c;
}
}
-
return GNUNET_OK;
}
/**
- * Parse the @a dps_array and update @a r accordingly
+ * Parse the @a dps_array with our decryption policies
+ * and update @a r accordingly
*
* @param[in,out] r recovery information to update
* @param dps_arr serialized data to parse
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
parse_dps_array (struct ANASTASIS_Recovery *r,
- json_t *dps_arr)
+ const json_t *dps_arr)
{
json_t *dps;
unsigned int n_index;
@@ -1200,15 +1228,15 @@ parse_dps_array (struct ANASTASIS_Recovery *r,
json_array_foreach (dps_arr, n_index, dps)
{
struct DecryptionPolicy *dp = &r->dps[n_index];
- json_t *challenges;
+ const json_t *challenges;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_varsize ("emk",
+ GNUNET_JSON_spec_varsize ("encrypted_master_key",
&dp->emk,
&dp->emk_size),
- GNUNET_JSON_spec_fixed_auto ("salt",
- &dp->salt),
- GNUNET_JSON_spec_json ("challenges",
- &challenges),
+ GNUNET_JSON_spec_fixed_auto ("master_salt",
+ &dp->master_salt),
+ GNUNET_JSON_spec_array_const ("challenges",
+ &challenges),
GNUNET_JSON_spec_end ()
};
const char *err_json_name;
@@ -1231,12 +1259,6 @@ parse_dps_array (struct ANASTASIS_Recovery *r,
}
GNUNET_assert (NULL != dp->emk);
GNUNET_assert (dp->emk_size > 0);
- if (! json_is_array (challenges))
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- return GNUNET_SYSERR;
- }
dp->pub_details.challenges_length = json_array_size (challenges);
dp->pub_details.challenges = GNUNET_new_array (
dp->pub_details.challenges_length,
@@ -1281,8 +1303,7 @@ parse_dps_array (struct ANASTASIS_Recovery *r,
}
}
}
- /* We don't free the spec, since we're still using dp->ems. */
- json_decref (challenges);
+ /* Do NOT free the spec: we are still using dp->ems. */
}
return GNUNET_OK;
}
@@ -1324,9 +1345,9 @@ ANASTASIS_recovery_deserialize (struct GNUNET_CURL_Context *ctx,
const char *err_json_name;
unsigned int err_line;
uint32_t version;
- json_t *dps_arr;
- json_t *cs_arr;
- json_t *id_data;
+ const json_t *dps_arr;
+ const json_t *cs_arr;
+ const json_t *id_data;
const char *provider_url;
const char *secret_name;
void *ecs;
@@ -1334,20 +1355,21 @@ ANASTASIS_recovery_deserialize (struct GNUNET_CURL_Context *ctx,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("id",
&r->id),
- GNUNET_JSON_spec_string ("provider_url",
+ TALER_JSON_spec_web_url ("provider_url",
&provider_url),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("secret_name",
- &secret_name)),
+ &secret_name),
+ NULL),
GNUNET_JSON_spec_uint32 ("version",
&version),
- GNUNET_JSON_spec_json ("dps",
- &dps_arr),
- GNUNET_JSON_spec_json ("cs",
- &cs_arr),
- GNUNET_JSON_spec_json ("id_data",
- &id_data),
- GNUNET_JSON_spec_varsize ("core_secret",
+ GNUNET_JSON_spec_array_const ("decryption_policies",
+ &dps_arr),
+ GNUNET_JSON_spec_array_const ("challenges",
+ &cs_arr),
+ GNUNET_JSON_spec_object_const ("id_data",
+ &id_data),
+ GNUNET_JSON_spec_varsize ("encrypted_core_secret",
&ecs,
&ecs_size),
GNUNET_JSON_spec_end ()
@@ -1380,7 +1402,7 @@ ANASTASIS_recovery_deserialize (struct GNUNET_CURL_Context *ctx,
GNUNET_JSON_parse_free (spec);
return NULL;
}
- r->id_data = json_incref (id_data);
+ r->id_data = json_incref ((json_t *) id_data);
r->provider_url = GNUNET_strdup (provider_url);
if (NULL != secret_name)
r->secret_name = GNUNET_strdup (secret_name);
@@ -1454,12 +1476,12 @@ ANASTASIS_recovery_abort (struct ANASTASIS_Recovery *r)
GNUNET_free (r->ri.dps);
for (unsigned int i = 0; i < r->ri.cs_len; i++)
{
- struct ANASTASIS_Challenge *cs = r->ri.cs[i];
+ struct ANASTASIS_Challenge *cs = &r->cs[i];
- if (NULL != cs->kslo)
+ if (NULL != cs->tso)
{
- ANASTASIS_keyshare_lookup_cancel (cs->kslo);
- cs->kslo = NULL;
+ ANASTASIS_truth_solve_cancel (cs->tso);
+ cs->tso = NULL;
}
GNUNET_free (cs->url);
GNUNET_free (cs->type);
diff --git a/src/reducer/Makefile.am b/src/reducer/Makefile.am
index 3b7edb6..1536d21 100644
--- a/src/reducer/Makefile.am
+++ b/src/reducer/Makefile.am
@@ -15,6 +15,8 @@ libanastasisredux_la_LDFLAGS = \
-version-info 0:0:0 \
-no-undefined
libanastasisredux_la_SOURCES = \
+ anastasis_api_discovery.c \
+ anastasis_api_providers.c \
anastasis_api_redux.c anastasis_api_redux.h \
anastasis_api_recovery_redux.c \
anastasis_api_backup_redux.c \
@@ -23,8 +25,10 @@ libanastasisredux_la_SOURCES = \
validation_DE_SVN.c \
validation_DE_TIN.c \
validation_ES_DNI.c \
+ validation_FR_INSEE.c \
validation_IN_AADHAR.c \
validation_IT_CF.c \
+ validation_NL_BSN.c \
validation_XX_SQUARE.c \
validation_XY_PRIME.c
libanastasisredux_la_LIBADD = \
diff --git a/src/reducer/anastasis_api_backup_redux.c b/src/reducer/anastasis_api_backup_redux.c
index dba6b0b..13b1dd6 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -1,16 +1,16 @@
/*
This file is part of Anastasis
- Copyright (C) 2020, 2021 Anastasis SARL
+ Copyright (C) 2020-2023 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -244,6 +244,11 @@ ANASTASIS_backup_start (const struct GNUNET_CONFIGURATION_Handle *cfg)
initial_state = ANASTASIS_REDUX_load_continents_ ();
if (NULL == initial_state)
return NULL;
+ GNUNET_assert (
+ 0 ==
+ json_object_set_new (initial_state,
+ "reducer_type",
+ json_string ("backup")));
set_state (initial_state,
ANASTASIS_BACKUP_STATE_CONTINENT_SELECTING);
return initial_state;
@@ -348,25 +353,27 @@ add_authentication (json_t *state,
json_object_foreach (auth_providers, url, details)
{
- json_t *methods = NULL;
+ const json_t *methods = NULL;
json_t *method;
size_t index;
uint32_t size_limit_in_mb = 0;
- bool disabled = false;
+ const char *status;
uint32_t http_status = 0;
struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
- &size_limit_in_mb)),
+ &size_limit_in_mb),
+ NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ &http_status),
+ NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("methods",
- &methods)),
+ GNUNET_JSON_spec_array_const ("methods",
+ &methods),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -378,7 +385,8 @@ add_authentication (json_t *state,
GNUNET_break (0);
continue;
}
- if (disabled)
+ if (0 != strcmp (status,
+ "ok"))
continue;
if (MHD_HTTP_OK != http_status)
continue; /* skip providers that are down */
@@ -403,7 +411,6 @@ add_authentication (json_t *state,
break;
}
}
- GNUNET_JSON_parse_free (ispec);
if (! challenge_size_ok (size_limit_in_mb,
challenge_size))
{
@@ -759,17 +766,20 @@ free_costs (struct Costs *costs)
* Check if providers @a p1 and @a p2 have equivalent
* methods and cost structures.
*
+ * @param pb policy builder with list of providers
+ * @param p1 name of provider to compare
+ * @param p2 name of provider to compare
* @return true if the providers are fully equivalent
*/
static bool
-equiv_provider (struct PolicyBuilder *pb,
+equiv_provider (const struct PolicyBuilder *pb,
const char *p1,
const char *p2)
{
- json_t *j1;
- json_t *j2;
- json_t *m1;
- json_t *m2;
+ const json_t *j1;
+ const json_t *j2;
+ const json_t *m1;
+ const json_t *m2;
struct TALER_Amount uc1;
struct TALER_Amount uc2;
@@ -786,8 +796,8 @@ equiv_provider (struct PolicyBuilder *pb,
{
struct GNUNET_JSON_Specification s1[] = {
- GNUNET_JSON_spec_json ("methods",
- &m1),
+ GNUNET_JSON_spec_array_const ("methods",
+ &m1),
TALER_JSON_spec_amount_any ("truth_upload_fee",
&uc1),
GNUNET_JSON_spec_end ()
@@ -805,8 +815,8 @@ equiv_provider (struct PolicyBuilder *pb,
{
struct GNUNET_JSON_Specification s2[] = {
- GNUNET_JSON_spec_json ("methods",
- &m2),
+ GNUNET_JSON_spec_array_const ("methods",
+ &m2),
TALER_JSON_spec_amount_any ("truth_upload_fee",
&uc2),
GNUNET_JSON_spec_end ()
@@ -925,7 +935,7 @@ eval_provider_selection (struct PolicyBuilder *pb,
pb->m_idx[i]);
const json_t *provider_cfg = json_object_get (pb->providers,
prov_sel[i]);
- json_t *provider_methods;
+ const json_t *provider_methods;
const char *method_type;
json_t *md;
size_t index;
@@ -935,8 +945,8 @@ eval_provider_selection (struct PolicyBuilder *pb,
struct GNUNET_JSON_Specification pspec[] = {
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
&size_limit_in_mb),
- GNUNET_JSON_spec_json ("methods",
- &provider_methods),
+ GNUNET_JSON_spec_array_const ("methods",
+ &provider_methods),
TALER_JSON_spec_amount_any ("truth_upload_fee",
&upload_cost),
GNUNET_JSON_spec_end ()
@@ -1008,7 +1018,6 @@ eval_provider_selection (struct PolicyBuilder *pb,
GNUNET_break (0);
pb->ec = TALER_EC_ANASTASIS_REDUCER_STATE_INVALID;
pb->hint = "'methods' of provider";
- GNUNET_JSON_parse_free (pspec);
for (unsigned int i = 0; i<pb->req_methods; i++)
free_costs (policy_ent[i].usage_fee);
return;
@@ -1030,14 +1039,12 @@ eval_provider_selection (struct PolicyBuilder *pb,
{
/* Provider does not OFFER this method, combination not possible.
Cost is basically 'infinite', but we simply then skip this. */
- GNUNET_JSON_parse_free (pspec);
GNUNET_JSON_parse_free (mspec);
for (unsigned int i = 0; i<pb->req_methods; i++)
free_costs (policy_ent[i].usage_fee);
return;
}
GNUNET_JSON_parse_free (mspec);
- GNUNET_JSON_parse_free (pspec);
}
/* calculate provider diversity by counting number of different
@@ -1160,15 +1167,15 @@ provider_candidate (struct PolicyBuilder *pb,
json_object_foreach (pb->providers, url, pconfig)
{
- bool disabled = false;
+ const char *status;
uint32_t http_status = 0;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
+ &http_status),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -1181,7 +1188,8 @@ provider_candidate (struct PolicyBuilder *pb,
continue;
}
if ( (MHD_HTTP_OK != http_status) ||
- disabled)
+ (0 == strcmp (status,
+ "disabled")) )
{
GNUNET_JSON_parse_free (spec);
continue;
@@ -1276,69 +1284,6 @@ method_candidate (struct PolicyBuilder *pb,
/**
- * Lookup @a salt of @a provider_url in @a state.
- *
- * @param state the state to inspect
- * @param provider_url provider to look into
- * @param[out] salt value to extract
- * @return #GNUNET_OK on success
- */
-static enum GNUNET_GenericReturnValue
-lookup_salt (const json_t *state,
- const char *provider_url,
- struct ANASTASIS_CRYPTO_ProviderSaltP *salt)
-{
- const json_t *aps;
- const json_t *cfg;
- uint32_t http_status = 0;
- bool disabled = false;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_fixed_auto ("salt",
- salt)),
- GNUNET_JSON_spec_end ()
- };
-
- aps = json_object_get (state,
- "authentication_providers");
- if (NULL == aps)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- cfg = json_object_get (aps,
- provider_url);
- if (NULL == cfg)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_JSON_parse (cfg,
- spec,
- NULL, NULL))
- {
- /* provider not working */
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
- if (disabled)
- return GNUNET_NO;
- if (NULL ==
- json_object_get (cfg,
- "salt"))
- return GNUNET_NO;
- return GNUNET_OK;
-}
-
-
-/**
* Compare two cost lists.
*
* @param my cost to compare
@@ -1738,6 +1683,11 @@ done_authentication (json_t *state,
"'authentication_methods' must not be empty");
return NULL;
case 1:
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "Two factor authentication (2-FA) is required");
+ return NULL;
case 2:
pb.req_methods = pb.num_methods;
break;
@@ -1801,9 +1751,9 @@ done_authentication (json_t *state,
struct ANASTASIS_CRYPTO_ProviderSaltP salt;
if (GNUNET_OK !=
- lookup_salt (state,
- url,
- &salt))
+ ANASTASIS_reducer_lookup_salt (state,
+ url,
+ &salt))
continue; /* skip providers that are down */
provider = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("provider_url",
@@ -1830,9 +1780,9 @@ done_authentication (json_t *state,
url_str = json_string_value (url);
if ( (NULL == url_str) ||
(GNUNET_OK !=
- lookup_salt (state,
- url_str,
- &salt)) )
+ ANASTASIS_reducer_lookup_salt (state,
+ url_str,
+ &salt)) )
{
GNUNET_break (0);
ANASTASIS_redux_fail_ (cb,
@@ -1993,8 +1943,8 @@ add_policy (json_t *state,
{
const char *provider_url;
uint32_t method_idx;
- json_t *prov_methods;
const char *method_type;
+ const json_t *prov_methods;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("provider",
&provider_url),
@@ -2020,19 +1970,19 @@ add_policy (json_t *state,
{
const json_t *prov_cfg;
uint32_t limit;
- bool disabled = false;
+ const char *status;
uint32_t http_status = 0;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
+ &http_status),
+ NULL),
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
&limit),
- GNUNET_JSON_spec_json ("methods",
- &prov_methods),
+ GNUNET_JSON_spec_array_const ("methods",
+ &prov_methods),
GNUNET_JSON_spec_end ()
};
@@ -2058,23 +2008,13 @@ add_policy (json_t *state,
continue;
}
if ( (MHD_HTTP_OK != http_status) ||
- disabled)
+ (0 != strcmp (status,
+ "ok")) )
{
/* skip provider, disabled or down */
json_decref (methods);
continue;
}
- if (! json_is_array (prov_methods))
- {
- GNUNET_break (0);
- json_decref (methods);
- json_decref (prov_methods);
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "provider lacks authentication methods");
- return NULL;
- }
}
{
@@ -2086,7 +2026,6 @@ add_policy (json_t *state,
{
GNUNET_break (0);
json_decref (methods);
- json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
@@ -2099,7 +2038,6 @@ add_policy (json_t *state,
{
GNUNET_break (0);
json_decref (methods);
- json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
@@ -2131,7 +2069,6 @@ add_policy (json_t *state,
{
GNUNET_break (0);
json_decref (methods);
- json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
@@ -2148,7 +2085,6 @@ add_policy (json_t *state,
{
GNUNET_break (0);
json_decref (methods);
- json_decref (prov_methods);
ANASTASIS_redux_fail_ (cb,
cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
@@ -2159,7 +2095,6 @@ add_policy (json_t *state,
GNUNET_assert (0 ==
json_array_append (methods,
method));
- json_decref (prov_methods);
} /* end of json_array_foreach (arg_array, index, method) */
}
@@ -2450,12 +2385,12 @@ del_challenge (json_t *state,
* @return number of years of service to pay for
*/
static unsigned int
-expiration_to_years (struct GNUNET_TIME_Absolute expiration)
+expiration_to_years (struct GNUNET_TIME_Timestamp expiration)
{
struct GNUNET_TIME_Relative rem;
unsigned int years;
- rem = GNUNET_TIME_absolute_get_remaining (expiration);
+ rem = GNUNET_TIME_absolute_get_remaining (expiration.abs_time);
years = rem.rel_value_us / GNUNET_TIME_UNIT_YEARS.rel_value_us;
if (0 != rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)
years++;
@@ -2475,7 +2410,7 @@ expiration_to_years (struct GNUNET_TIME_Absolute expiration)
*/
static enum GNUNET_GenericReturnValue
update_expiration_cost (json_t *state,
- struct GNUNET_TIME_Absolute expiration)
+ struct GNUNET_TIME_Timestamp expiration)
{
struct Costs *costs = NULL;
unsigned int years;
@@ -2500,15 +2435,15 @@ update_expiration_cost (json_t *state,
json_object_foreach (providers, url, provider)
{
struct TALER_Amount annual_fee;
- bool disabled = false;
+ const char *status;
uint32_t http_status = 0;
struct GNUNET_JSON_Specification pspec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
+ &http_status),
+ NULL),
TALER_JSON_spec_amount_any ("annual_fee",
&annual_fee),
GNUNET_JSON_spec_end ()
@@ -2520,12 +2455,12 @@ update_expiration_cost (json_t *state,
pspec,
NULL, NULL))
{
- /* strange, skip as well */
- GNUNET_break_op (0);
+ /* likely down, skip */
continue;
}
if ( (MHD_HTTP_OK != http_status) ||
- disabled)
+ (0 != strcmp (status,
+ "ok")) )
continue; /* skip providers that are down or disabled */
if (0 >
TALER_amount_multiply (&fee,
@@ -2607,15 +2542,15 @@ update_expiration_cost (json_t *state,
off++;
{
struct TALER_Amount upload_cost;
- bool disabled = false;
+ const char *status;
uint32_t http_status = 0;
struct GNUNET_JSON_Specification pspec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
+ &http_status),
+ NULL),
TALER_JSON_spec_amount_any ("truth_upload_fee",
&upload_cost),
GNUNET_JSON_spec_end ()
@@ -2634,7 +2569,8 @@ update_expiration_cost (json_t *state,
return GNUNET_SYSERR;
}
if ( (MHD_HTTP_OK != http_status) ||
- disabled)
+ (0 != strcmp (status,
+ "ok")) )
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -2667,8 +2603,7 @@ update_expiration_cost (json_t *state,
{
struct Costs *nxt = costs->next;
- if ( (0 != costs->cost.value) ||
- (0 != costs->cost.fraction) )
+ if (! TALER_amount_is_zero (&costs->cost))
{
json_t *ao;
@@ -2690,13 +2625,12 @@ update_expiration_cost (json_t *state,
}
if (is_free)
- expiration = GNUNET_TIME_relative_to_absolute (ANASTASIS_FREE_STORAGE);
+ expiration = GNUNET_TIME_relative_to_timestamp (ANASTASIS_FREE_STORAGE);
/* update 'expiration' in state */
{
json_t *eo;
- (void) GNUNET_TIME_round_abs (&expiration);
- eo = GNUNET_JSON_from_time_abs (expiration);
+ eo = GNUNET_JSON_from_timestamp (expiration);
GNUNET_assert (0 ==
json_object_set_new (state,
"expiration",
@@ -2737,11 +2671,13 @@ done_policy_review (json_t *state,
return NULL;
}
{
- struct GNUNET_TIME_Absolute exp = {0};
+ struct GNUNET_TIME_Timestamp exp
+ = GNUNET_TIME_UNIT_ZERO_TS;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_absolute_time ("expiration",
- &exp)),
+ GNUNET_JSON_spec_timestamp ("expiration",
+ &exp),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -2756,8 +2692,8 @@ done_policy_review (json_t *state,
"invalid expiration specified");
return NULL;
}
- if (0 == exp.abs_value_us)
- exp = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS);
+ if (GNUNET_TIME_absolute_is_zero (exp.abs_time))
+ exp = GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_YEARS);
if (GNUNET_OK !=
update_expiration_cost (state,
exp))
@@ -3049,8 +2985,8 @@ secret_share_result_cb (void *cls,
d = GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("policy_version",
pssi->policy_version),
- GNUNET_JSON_pack_time_abs ("policy_expiration",
- pssi->policy_expiration));
+ GNUNET_JSON_pack_timestamp ("policy_expiration",
+ pssi->policy_expiration));
GNUNET_assert (NULL != d);
GNUNET_assert (0 ==
json_object_set_new (sa,
@@ -3144,8 +3080,11 @@ secret_share_result_cb (void *cls,
details = GNUNET_JSON_PACK (
GNUNET_JSON_pack_uint64 ("http_status",
sr->details.provider_failure.http_status),
- GNUNET_JSON_pack_uint64 ("upload_status",
+ GNUNET_JSON_pack_uint64 ("code",
sr->details.provider_failure.ec),
+ GNUNET_JSON_pack_string ("hint",
+ TALER_ErrorCode_get_hint (
+ sr->details.provider_failure.ec)),
GNUNET_JSON_pack_string ("provider_url",
sr->details.provider_failure.provider_url));
uc->cb (uc->cb_cls,
@@ -3174,26 +3113,29 @@ secret_share_result_cb (void *cls,
static void
share_secret (struct UploadContext *uc)
{
- json_t *user_id;
- json_t *core_secret;
- json_t *jpolicies;
- json_t *providers = NULL;
+ const json_t *user_id;
+ const json_t *core_secret;
+ const json_t *jpolicies;
+ const json_t *providers = NULL;
size_t policies_len;
const char *secret_name = NULL;
unsigned int pds_len;
struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_ZERO;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("identity_attributes",
- &user_id),
- GNUNET_JSON_spec_json ("policies",
- &jpolicies),
- GNUNET_JSON_spec_json ("policy_providers",
- &providers),
- GNUNET_JSON_spec_json ("core_secret",
- &core_secret),
+ GNUNET_JSON_spec_object_const ("identity_attributes",
+ &user_id),
+ GNUNET_JSON_spec_array_const ("policies",
+ &jpolicies),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_array_const ("policy_providers",
+ &providers),
+ NULL),
+ GNUNET_JSON_spec_object_const ("core_secret",
+ &core_secret),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("secret_name",
- &secret_name)),
+ &secret_name),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -3215,12 +3157,13 @@ share_secret (struct UploadContext *uc)
struct GNUNET_JSON_Specification pspec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_relative_time ("timeout",
- &timeout)),
+ &timeout),
+ NULL),
GNUNET_JSON_spec_end ()
};
args = json_object_get (uc->state,
- "pay-arguments");
+ "pay_arguments");
if ( (NULL != args) &&
(GNUNET_OK !=
GNUNET_JSON_parse (args,
@@ -3240,40 +3183,32 @@ share_secret (struct UploadContext *uc)
}
}
- if ( (! json_is_object (user_id)) ||
- (! json_is_array (jpolicies)) ||
- (0 == json_array_size (jpolicies)) ||
- ( (NULL != providers) &&
- (! json_is_array (providers)) ) )
+ policies_len = json_array_size (jpolicies);
+ if (0 == policies_len)
{
ANASTASIS_redux_fail_ (uc->cb,
uc->cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
"State parsing failed checks when preparing to share secret");
- GNUNET_JSON_parse_free (spec);
upload_cancel_cb (uc);
return;
}
- policies_len = json_array_size (jpolicies);
pds_len = json_array_size (providers);
-
if (0 == pds_len)
{
ANASTASIS_redux_fail_ (uc->cb,
uc->cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
"no workable providers in state");
- GNUNET_JSON_parse_free (spec);
upload_cancel_cb (uc);
return;
}
-
{
struct ANASTASIS_Policy *vpolicies[policies_len];
const struct ANASTASIS_Policy *policies[policies_len];
- struct ANASTASIS_ProviderDetails pds[GNUNET_NZL (pds_len)];
+ struct ANASTASIS_ProviderDetails pds[pds_len];
/* initialize policies/vpolicies arrays */
memset (pds,
@@ -3295,7 +3230,6 @@ share_secret (struct UploadContext *uc)
uc->cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
"'methods' must be an array");
- GNUNET_JSON_parse_free (spec);
upload_cancel_cb (uc);
return;
}
@@ -3309,13 +3243,14 @@ share_secret (struct UploadContext *uc)
{
const json_t *jmethod = json_array_get (jmethods,
j);
- json_t *jtruth = NULL;
+ const json_t *jtruth = NULL;
uint32_t truth_index;
const char *provider_url;
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("truth",
- &jtruth)),
+ GNUNET_JSON_spec_object_const ("truth",
+ &jtruth),
+ NULL),
GNUNET_JSON_spec_string ("provider",
&provider_url),
GNUNET_JSON_spec_uint32 ("authentication_method",
@@ -3336,7 +3271,6 @@ share_secret (struct UploadContext *uc)
uc->cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
"'truth' failed to decode");
- GNUNET_JSON_parse_free (spec);
upload_cancel_cb (uc);
return;
}
@@ -3353,8 +3287,6 @@ share_secret (struct UploadContext *uc)
uc->cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
"'truth' failed to decode");
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
upload_cancel_cb (uc);
return;
}
@@ -3392,13 +3324,10 @@ share_secret (struct UploadContext *uc)
uc->cb_cls,
TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
"'truth' failed to decode");
- GNUNET_JSON_parse_free (ispec);
- GNUNET_JSON_parse_free (spec);
upload_cancel_cb (uc);
return;
}
}
- GNUNET_JSON_parse_free (ispec);
ctruths[j] = truths[j];
}
p = ANASTASIS_policy_create (ctruths,
@@ -3418,7 +3347,8 @@ share_secret (struct UploadContext *uc)
struct GNUNET_JSON_Specification ispec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto ("payment_secret",
- &pds[i].payment_secret)),
+ &pds[i].payment_secret),
+ NULL),
GNUNET_JSON_spec_string ("provider_url",
&pds[i].provider_url),
GNUNET_JSON_spec_end ()
@@ -3429,9 +3359,9 @@ share_secret (struct UploadContext *uc)
ispec,
NULL, NULL)) ||
(GNUNET_OK !=
- lookup_salt (uc->state,
- pds[i].provider_url,
- &pds[i].provider_salt)) )
+ ANASTASIS_reducer_lookup_salt (uc->state,
+ pds[i].provider_url,
+ &pds[i].provider_salt)) )
{
GNUNET_break (0);
ANASTASIS_redux_fail_ (uc->cb,
@@ -3441,7 +3371,6 @@ share_secret (struct UploadContext *uc)
for (unsigned int i = 0; i<policies_len; i++)
ANASTASIS_policy_destroy (vpolicies[i]);
upload_cancel_cb (uc);
- GNUNET_JSON_parse_free (spec);
return;
}
}
@@ -3472,7 +3401,6 @@ share_secret (struct UploadContext *uc)
for (unsigned int i = 0; i<policies_len; i++)
ANASTASIS_policy_destroy (vpolicies[i]);
}
- GNUNET_JSON_parse_free (spec);
if (NULL == uc->ss)
{
GNUNET_break (0);
@@ -3665,7 +3593,8 @@ add_truth_object (struct UploadContext *uc,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("upload_status",
- &status)),
+ &status),
+ NULL),
GNUNET_JSON_spec_end ()
};
if (GNUNET_OK !=
@@ -3714,9 +3643,9 @@ add_truth_object (struct UploadContext *uc,
};
if (GNUNET_OK !=
- lookup_salt (uc->state,
- provider_url,
- &salt))
+ ANASTASIS_reducer_lookup_salt (uc->state,
+ provider_url,
+ &salt))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -3849,10 +3778,12 @@ check_truth_upload (struct UploadContext *uc,
&type),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("mime_type",
- &mime_type)),
+ &mime_type),
+ NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("instructions",
- &instructions)),
+ &instructions),
+ NULL),
GNUNET_JSON_spec_varsize ("challenge",
&truth_data,
&truth_data_size),
@@ -3883,9 +3814,9 @@ check_truth_upload (struct UploadContext *uc,
tue->am_idx = am_idx;
tue->policies_length = 1;
if (GNUNET_OK !=
- lookup_salt (uc->state,
- provider_url,
- &provider_salt))
+ ANASTASIS_reducer_lookup_salt (uc->state,
+ provider_url,
+ &provider_salt))
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
@@ -3901,7 +3832,6 @@ check_truth_upload (struct UploadContext *uc,
struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
struct ANASTASIS_CRYPTO_KeyShareP key_share;
struct ANASTASIS_CRYPTO_NonceP nonce;
-
struct GNUNET_JSON_Specification jspec[] = {
GNUNET_JSON_spec_fixed_auto ("salt",
&question_salt),
@@ -3987,10 +3917,10 @@ upload (json_t *state,
struct UploadContext *uc;
json_t *auth_methods;
json_t *policies;
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_TIME_Timestamp expiration;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_absolute_time ("expiration",
- &expiration),
+ GNUNET_JSON_spec_timestamp ("expiration",
+ &expiration),
GNUNET_JSON_spec_end ()
};
@@ -4041,12 +3971,13 @@ upload (json_t *state,
struct GNUNET_JSON_Specification pspec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_relative_time ("timeout",
- &uc->timeout)),
+ &uc->timeout),
+ NULL),
GNUNET_JSON_spec_end ()
};
args = json_object_get (uc->state,
- "pay-arguments");
+ "pay_arguments");
if ( (NULL != args) &&
(GNUNET_OK !=
GNUNET_JSON_parse (args,
@@ -4100,7 +4031,8 @@ upload (json_t *state,
&am_idx),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_json ("truth",
- &truth)),
+ &truth),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -4258,18 +4190,19 @@ check_upload_size_limit (json_t *state,
json_object_foreach (aps, url, ap)
{
uint32_t limit = 0;
- bool disabled = false;
+ const char *status;
uint32_t http_status = 0;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("http_status",
- &http_status)),
+ &http_status),
+ NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
- &limit)),
+ &limit),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -4283,7 +4216,8 @@ check_upload_size_limit (json_t *state,
continue;
}
if ( (MHD_HTTP_OK != http_status) ||
- disabled)
+ (0 != strcmp (status,
+ "ok")) )
continue;
if (0 == limit)
return GNUNET_SYSERR;
@@ -4315,13 +4249,15 @@ enter_secret (json_t *state,
void *cb_cls)
{
json_t *jsecret;
- struct GNUNET_TIME_Absolute expiration = {0};
+ struct GNUNET_TIME_Timestamp expiration
+ = GNUNET_TIME_UNIT_ZERO_TS;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_json ("secret",
&jsecret),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_absolute_time ("expiration",
- &expiration)),
+ GNUNET_JSON_spec_timestamp ("expiration",
+ &expiration),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -4369,7 +4305,7 @@ enter_secret (json_t *state,
break;
}
}
- if (0 != expiration.abs_value_us)
+ if (! GNUNET_TIME_absolute_is_zero (expiration.abs_time))
{
if (GNUNET_OK !=
update_expiration_cost (state,
@@ -4500,10 +4436,10 @@ update_expiration (json_t *state,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_TIME_Timestamp expiration;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_absolute_time ("expiration",
- &expiration),
+ GNUNET_JSON_spec_timestamp ("expiration",
+ &expiration),
GNUNET_JSON_spec_end ()
};
@@ -4637,7 +4573,7 @@ pay_truths_backup (json_t *state,
if (NULL != arguments)
GNUNET_assert (0 ==
json_object_set (state,
- "pay-arguments",
+ "pay_arguments",
(json_t *) arguments));
return upload (state,
cb,
@@ -4667,7 +4603,7 @@ pay_policies_backup (json_t *state,
if (NULL != arguments)
GNUNET_assert (0 ==
json_object_set (state,
- "pay-arguments",
+ "pay_arguments",
(json_t *) arguments));
return upload (state,
cb,
@@ -4750,6 +4686,11 @@ ANASTASIS_backup_action_ (json_t *state,
},
{
ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING,
+ "poll_providers",
+ &ANASTASIS_REDUX_poll_providers_
+ },
+ {
+ ANASTASIS_BACKUP_STATE_AUTHENTICATIONS_EDITING,
"back",
&ANASTASIS_back_generic_decrement_
},
@@ -5089,11 +5030,10 @@ ANASTASIS_REDUX_backup_begin_ (json_t *state,
json_object_foreach (provider_list, url, prov) {
struct BackupStartStateProviderEntry *pe;
json_t *istate;
- bool disabled = false;
+ const char *status;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
+ GNUNET_JSON_spec_string ("status",
+ &status),
GNUNET_JSON_spec_end ()
};
@@ -5106,7 +5046,8 @@ ANASTASIS_REDUX_backup_begin_ (json_t *state,
GNUNET_break_op (0);
continue;
}
- if (disabled)
+ if (0 == strcmp (status,
+ "disabled"))
continue;
pe = GNUNET_new (struct BackupStartStateProviderEntry);
pe->bss = bss;
diff --git a/src/reducer/anastasis_api_discovery.c b/src/reducer/anastasis_api_discovery.c
new file mode 100644
index 0000000..3470d97
--- /dev/null
+++ b/src/reducer/anastasis_api_discovery.c
@@ -0,0 +1,549 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file reducer/anastasis_api_discovery.c
+ * @brief anastasis recovery policy discovery api
+ * @author Christian Grothoff
+ */
+#include <platform.h>
+#include <jansson.h>
+#include "anastasis_redux.h"
+#include "anastasis_error_codes.h"
+#include <taler/taler_json_lib.h>
+#include "anastasis_api_redux.h"
+#include <dlfcn.h>
+
+
+/**
+ * Handle for one request we are doing at a specific provider.
+ */
+struct ProviderOperation
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct ProviderOperation *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct ProviderOperation *prev;
+
+ /**
+ * Base URL of the provider.
+ */
+ char *provider_url;
+
+ /**
+ * Handle to the version check operation we are performing.
+ */
+ struct ANASTASIS_VersionCheck *vc;
+
+ /**
+ * Handle discovery operation we this is a part of.
+ */
+ struct ANASTASIS_PolicyDiscovery *pd;
+
+ /**
+ * Attribute mask applied to the identity attributes
+ * for this operation.
+ */
+ json_int_t attribute_mask;
+};
+
+
+/**
+ * Handle for a discovery operation.
+ */
+struct ANASTASIS_PolicyDiscovery
+{
+ /**
+ * Head of HTTP requests, kept in a DLL.
+ */
+ struct ProviderOperation *po_head;
+
+ /**
+ * Tail of HTTP requests, kept in a DLL.
+ */
+ struct ProviderOperation *po_tail;
+
+ /**
+ * Function to call with results.
+ */
+ ANASTASIS_PolicyDiscoveryCallback cb;
+
+ /**
+ * Closure for @e cb.
+ */
+ void *cb_cls;
+
+ /**
+ * Map for duplicate detection, maps hashes of policies we
+ * have already seen to a json_array with all providers
+ * and versions corresponding to this policy hash.
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *dd_map;
+
+ /**
+ * State we are operating on.
+ */
+ json_t *state;
+
+ /**
+ * Number of optional fields in our identity attributes.
+ */
+ json_int_t opt_cnt;
+};
+
+
+/**
+ * Callback which passes back meta data about one of the
+ * recovery documents available at the provider.
+ *
+ * @param cls our `struct ProviderOperation *`
+ * @param version version number of the policy document,
+ * 0 for the end of the list
+ * @param server_time time of the backup at the provider
+ * @param recdoc_id hash of the compressed recovery document, uniquely
+ * identifies the document; NULL for the end of the list
+ * @param secret_name name of the secret as chosen by the user,
+ * or NULL if the user did not provide a name
+ */
+static void
+meta_cb (void *cls,
+ uint32_t version,
+ struct GNUNET_TIME_Timestamp server_time,
+ const struct GNUNET_HashCode *recdoc_id,
+ const char *secret_name)
+{
+ struct ProviderOperation *po = cls;
+ struct ANASTASIS_PolicyDiscovery *pd = po->pd;
+ json_t *pa;
+ json_t *pe;
+
+ if (NULL == recdoc_id)
+ {
+ po->vc = NULL;
+ GNUNET_CONTAINER_DLL_remove (pd->po_head,
+ pd->po_tail,
+ po);
+ GNUNET_free (po->provider_url);
+ GNUNET_free (po);
+ return;
+ }
+ pe = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("version",
+ version),
+ GNUNET_JSON_pack_string ("url",
+ po->provider_url));
+
+ pa = GNUNET_CONTAINER_multihashmap_get (pd->dd_map,
+ recdoc_id);
+ if (NULL != pa)
+ {
+ GNUNET_break (0 ==
+ json_array_append_new (pa,
+ pe));
+ return;
+ }
+ pa = json_array ();
+ GNUNET_assert (NULL != pa);
+ GNUNET_break (0 ==
+ json_array_append_new (pa,
+ pe));
+ GNUNET_assert (
+ GNUNET_OK ==
+ GNUNET_CONTAINER_multihashmap_put (
+ pd->dd_map,
+ recdoc_id,
+ pa,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ pd->cb (pd->cb_cls,
+ recdoc_id,
+ po->provider_url,
+ version,
+ po->attribute_mask,
+ server_time,
+ secret_name,
+ pa);
+}
+
+
+/**
+ * Start policy operation for @a pd using identity @a id_data
+ * at provider @a provider_url.
+ *
+ * @param pd policy discovery operation
+ * @param id_data our identity data, derived using @a mask
+ * @param mask the mask describing which optional attributes were removed
+ * @param provider_url which provider to query
+ * @param cursor cursor telling us from where to query
+ */
+static void
+start_po (struct ANASTASIS_PolicyDiscovery *pd,
+ const json_t *id_data,
+ json_int_t mask,
+ const char *provider_url,
+ const json_t *cursor)
+{
+ const json_t *state = pd->state;
+ struct ProviderOperation *po;
+ uint32_t max_version = UINT32_MAX;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
+
+ if (NULL != cursor)
+ {
+ size_t i;
+ json_t *obj;
+
+ json_array_foreach ((json_t *) cursor, i, obj)
+ {
+ const char *url;
+ uint64_t cmask;
+ uint32_t mv;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("provider_url",
+ &url),
+ GNUNET_JSON_spec_uint64 ("mask",
+ &cmask),
+ GNUNET_JSON_spec_uint32 ("max_version",
+ &mv),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (obj,
+ spec,
+ NULL, NULL))
+ {
+ /* cursor invalid */
+ GNUNET_break (0);
+ json_dumpf (obj,
+ stderr,
+ JSON_INDENT (2));
+ return;
+ }
+ if ( (cmask == mask) &&
+ (0 == strcmp (url,
+ provider_url)) )
+ {
+ max_version = mv;
+ break;
+ }
+ }
+ }
+
+ if (GNUNET_OK !=
+ ANASTASIS_reducer_lookup_salt (state,
+ provider_url,
+ &provider_salt))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "No /config for `%s', skipping provider\n",
+ provider_url);
+ return;
+ }
+ po = GNUNET_new (struct ProviderOperation);
+ po->pd = pd;
+ po->attribute_mask = mask;
+ po->provider_url = GNUNET_strdup (provider_url);
+ po->vc = ANASTASIS_recovery_get_versions (ANASTASIS_REDUX_ctx_,
+ id_data,
+ max_version,
+ provider_url,
+ &provider_salt,
+ &meta_cb,
+ po);
+ if (NULL == po->vc)
+ {
+ GNUNET_free (po);
+ }
+ else
+ {
+ GNUNET_CONTAINER_DLL_insert (pd->po_head,
+ pd->po_tail,
+ po);
+ }
+}
+
+
+struct ANASTASIS_PolicyDiscovery *
+ANASTASIS_policy_discovery_start (const json_t *state,
+ const json_t *cursor,
+ ANASTASIS_PolicyDiscoveryCallback cb,
+ void *cb_cls)
+{
+ struct ANASTASIS_PolicyDiscovery *pd;
+ json_t *master_id = json_object_get (state,
+ "identity_attributes");
+ json_t *providers = json_object_get (state,
+ "authentication_providers");
+ json_t *required_attributes = json_object_get (state,
+ "required_attributes");
+ unsigned int opt_cnt;
+
+ if ( (NULL == master_id) ||
+ (! json_is_object (master_id)) )
+ {
+ GNUNET_break (0);
+ json_dumpf (state,
+ stderr,
+ JSON_INDENT (2));
+ return NULL;
+ }
+ if ( (NULL == providers) ||
+ (! json_is_object (providers)) )
+ {
+ GNUNET_break (0);
+ json_dumpf (state,
+ stderr,
+ JSON_INDENT (2));
+ return NULL;
+ }
+ if ( (NULL == required_attributes) ||
+ (! json_is_array (required_attributes)) )
+ {
+ GNUNET_break (0);
+ json_dumpf (required_attributes,
+ stderr,
+ JSON_INDENT (2));
+ return NULL;
+ }
+
+ /* count optional attributes present in 'master_id' */
+ opt_cnt = 0;
+ {
+ size_t index;
+ json_t *required_attribute;
+
+ json_array_foreach (required_attributes,
+ index,
+ required_attribute)
+ {
+ const char *name;
+ int optional = false;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("name",
+ &name),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_boolean ("optional",
+ &optional),
+ NULL),
+ GNUNET_JSON_spec_end ()
+ };
+ bool present;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (required_attribute,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ json_dumpf (required_attribute,
+ stderr,
+ JSON_INDENT (2));
+ return NULL;
+ }
+ present = (NULL !=
+ json_object_get (master_id,
+ name));
+ if ((! present) && (! optional))
+ {
+ GNUNET_break (0);
+ json_dumpf (master_id,
+ stderr,
+ JSON_INDENT (2));
+ return NULL;
+ }
+ if (present && optional)
+ opt_cnt++;
+ }
+ }
+
+ pd = GNUNET_new (struct ANASTASIS_PolicyDiscovery);
+ pd->dd_map = GNUNET_CONTAINER_multihashmap_create (128,
+ GNUNET_NO);
+ pd->cb = cb;
+ pd->cb_cls = cb_cls;
+ pd->opt_cnt = opt_cnt;
+ pd->state = json_deep_copy (state);
+
+ /* Compute 'id_data' for all possible masks, and then
+ start downloads at all providers for 'id_data' */
+ for (json_int_t mask = 0; mask < (1LL << opt_cnt); mask++)
+ {
+ json_t *id_data = ANASTASIS_mask_id_data (state,
+ master_id,
+ mask);
+ json_t *value;
+ const char *url;
+
+ json_object_foreach (providers, url, value)
+ {
+ start_po (pd,
+ id_data,
+ mask,
+ url,
+ cursor);
+ }
+ json_decref (id_data);
+ }
+ return pd;
+}
+
+
+void
+ANASTASIS_policy_discovery_more (struct ANASTASIS_PolicyDiscovery *pd,
+ const char *provider_url,
+ json_t *provider_state)
+{
+ json_t *master_id = json_object_get (pd->state,
+ "identity_attributes");
+ json_t *providers = json_object_get (pd->state,
+ "authentication_providers");
+
+ GNUNET_assert (NULL != master_id);
+ GNUNET_assert (NULL != providers);
+ GNUNET_assert (0 ==
+ json_object_set (providers,
+ provider_url,
+ provider_state));
+ /* Compute 'id_data' for all possible masks, and then
+ start downloads at provider for 'id_data' */
+ for (json_int_t mask = 0; mask < (1LL << pd->opt_cnt); mask++)
+ {
+ json_t *id_data = ANASTASIS_mask_id_data (pd->state,
+ master_id,
+ mask);
+
+ start_po (pd,
+ id_data,
+ mask,
+ provider_url,
+ NULL);
+ json_decref (id_data);
+ }
+}
+
+
+/**
+ * Free JSON Arrays from our hash map.
+ *
+ * @param cls NULL
+ * @param key ignored
+ * @param value `json_t *` to free
+ * @return #GNUNET_OK
+ */
+static enum GNUNET_GenericReturnValue
+free_dd_json (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ json_t *j = value;
+
+ (void) cls;
+ (void) key;
+ json_decref (j);
+ return GNUNET_OK;
+}
+
+
+void
+ANASTASIS_policy_discovery_stop (struct ANASTASIS_PolicyDiscovery *pd)
+{
+ struct ProviderOperation *po;
+
+ while (NULL != (po = pd->po_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (pd->po_head,
+ pd->po_tail,
+ po);
+ ANASTASIS_recovery_get_versions_cancel (po->vc);
+ GNUNET_free (po->provider_url);
+ GNUNET_free (po);
+ }
+ GNUNET_CONTAINER_multihashmap_iterate (pd->dd_map,
+ &free_dd_json,
+ NULL);
+ GNUNET_CONTAINER_multihashmap_destroy (pd->dd_map);
+ json_decref (pd->state);
+ GNUNET_free (pd);
+}
+
+
+json_t *
+ANASTASIS_mask_id_data (const json_t *state,
+ const json_t *master_id,
+ json_int_t mask)
+{
+ json_t *required_attributes = json_object_get (state,
+ "required_attributes");
+ size_t index;
+ json_t *required_attribute;
+ json_t *ret = json_deep_copy (master_id);
+ unsigned int bit = 0;
+
+ if ( (NULL == required_attributes) ||
+ (! json_is_array (required_attributes)) )
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+
+ json_array_foreach (required_attributes, index, required_attribute)
+ {
+ const char *name;
+ int optional = false;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("name",
+ &name),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_boolean ("optional",
+ &optional),
+ NULL),
+ GNUNET_JSON_spec_end ()
+ };
+ bool present;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (required_attribute,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ present = (NULL !=
+ json_object_get (master_id,
+ name));
+ if ((! present) && (! optional))
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ if (present && optional)
+ {
+ if (0 != ((1LL << bit) & mask))
+ {
+ GNUNET_assert (0 ==
+ json_object_del (ret,
+ name));
+ }
+ bit++;
+ }
+ }
+ return ret;
+}
diff --git a/src/reducer/anastasis_api_providers.c b/src/reducer/anastasis_api_providers.c
new file mode 100644
index 0000000..82243f5
--- /dev/null
+++ b/src/reducer/anastasis_api_providers.c
@@ -0,0 +1,300 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020, 2021, 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file reducer/anastasis_api_providers.c
+ * @brief anastasis provider synchronization logic
+ * @author Christian Grothoff
+ */
+
+#include <platform.h>
+#include <jansson.h>
+#include "anastasis_redux.h"
+#include "anastasis_error_codes.h"
+#include "anastasis_api_redux.h"
+
+
+/**
+ * Main data structure for sync_providers().
+ */
+struct MasterSync;
+
+
+/**
+ * Data structure for one provider we are syncing /config with.
+ */
+struct SyncEntry
+{
+ /**
+ * Kept in a DLL.
+ */
+ struct SyncEntry *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct SyncEntry *prev;
+
+ /**
+ * Sync operation we are part of.
+ */
+ struct MasterSync *ms;
+
+ /**
+ * Redux action for this provider.
+ */
+ struct ANASTASIS_ReduxAction *ra;
+};
+
+
+/**
+ * Main data structure for sync_providers().
+ */
+struct MasterSync
+{
+ /**
+ * Our own sync action we expose externally.
+ */
+ struct ANASTASIS_ReduxAction ra;
+ /**
+ * Head of DLL with entries per provider.
+ */
+ struct SyncEntry *se_head;
+ /**
+ * Tail of DLL with entries per provider.
+ */
+ struct SyncEntry *se_tail;
+
+ /**
+ * Function to call with the result.
+ */
+ ANASTASIS_ActionCallback cb;
+
+ /**
+ * Closure for @e cb.
+ */
+ void *cb_cls;
+
+};
+
+
+/**
+ * Free @a cls data structure.
+ *
+ * @param[in] cls data structure to free, must be a `struct MasterSync *`
+ */
+static void
+clean_sync (void *cls)
+{
+ struct MasterSync *ms = cls;
+ struct SyncEntry *se;
+
+ while (NULL != (se = ms->se_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (ms->se_head,
+ ms->se_tail,
+ se);
+ se->ra->cleanup (se->ra->cleanup_cls);
+ GNUNET_free (se);
+ }
+ GNUNET_free (ms);
+}
+
+
+/**
+ * Function called when we have made progress on any of the
+ * providers we are trying to sync with.
+ *
+ * @param cls closure
+ * @param error error code, #TALER_EC_NONE if @a new_bs is the new successful state
+ * @param new_state the new state of the operation (client should json_incref() to keep an alias)
+ */
+static void
+sync_progress (void *cls,
+ enum TALER_ErrorCode error,
+ json_t *new_state)
+{
+ struct SyncEntry *se = cls;
+ struct MasterSync *ms = se->ms;
+
+ GNUNET_CONTAINER_DLL_remove (ms->se_head,
+ ms->se_tail,
+ se);
+ GNUNET_free (se);
+ ms->cb (ms->cb_cls,
+ error,
+ new_state);
+ clean_sync (ms);
+}
+
+
+struct ANASTASIS_ReduxAction *
+ANASTASIS_REDUX_sync_providers_ (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ json_t *rd;
+ json_t *cs_arr;
+ struct MasterSync *ms;
+
+ rd = json_object_get (state,
+ "recovery_document");
+ if (NULL == rd)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'recovery_document' missing");
+ return NULL;
+ }
+ cs_arr = json_object_get (rd,
+ "challenges");
+ if (! json_is_array (cs_arr))
+ {
+ GNUNET_break_op (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'recovery_document' must be an array");
+ return NULL;
+ }
+ ms = GNUNET_new (struct MasterSync);
+ ms->cb = cb;
+ ms->cb_cls = cb_cls;
+ {
+ json_t *cs;
+ unsigned int n_index;
+
+ json_array_foreach (cs_arr, n_index, cs)
+ {
+ const char *provider_url;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("url",
+ &provider_url),
+ GNUNET_JSON_spec_end ()
+ };
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
+ struct SyncEntry *se;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (cs,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'recovery_document' missing");
+ clean_sync (ms);
+ return NULL;
+ }
+ if (GNUNET_OK ==
+ ANASTASIS_reducer_lookup_salt (state,
+ provider_url,
+ &provider_salt))
+ continue; /* provider already ready */
+ se = GNUNET_new (struct SyncEntry);
+ se->ms = ms;
+ GNUNET_CONTAINER_DLL_insert (ms->se_head,
+ ms->se_tail,
+ se);
+ se->ra = ANASTASIS_REDUX_add_provider_to_state_ (provider_url,
+ state,
+ &sync_progress,
+ se);
+ }
+ }
+ if (NULL == ms->se_head)
+ {
+ /* everything already synced */
+ clean_sync (ms);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_PROVIDERS_ALREADY_SYNCED,
+ "already in sync");
+ return NULL;
+ }
+ ms->ra.cleanup = &clean_sync;
+ ms->ra.cleanup_cls = ms;
+ return &ms->ra;
+}
+
+
+struct ANASTASIS_ReduxAction *
+ANASTASIS_REDUX_poll_providers_ (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
+{
+ json_t *ap;
+ const char *url;
+ json_t *obj;
+ struct MasterSync *ms;
+
+ ap = json_object_get (state,
+ "authentication_providers");
+ if (NULL == ap)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'authentication_providers' missing");
+ return NULL;
+ }
+ ms = GNUNET_new (struct MasterSync);
+ ms->cb = cb;
+ ms->cb_cls = cb_cls;
+ json_object_foreach (ap, url, obj)
+ {
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
+ struct SyncEntry *se;
+ struct ANASTASIS_ReduxAction *ra;
+
+ if (GNUNET_OK ==
+ ANASTASIS_reducer_lookup_salt (state,
+ url,
+ &provider_salt))
+ continue;
+ se = GNUNET_new (struct SyncEntry);
+ se->ms = ms;
+ GNUNET_CONTAINER_DLL_insert (ms->se_head,
+ ms->se_tail,
+ se);
+ ra = ANASTASIS_REDUX_add_provider_to_state_ (url,
+ state,
+ &sync_progress,
+ se);
+ if (NULL == ra)
+ return NULL; /* sync_progress already called! */
+ se->ra = ra;
+ }
+ if (NULL == ms->se_head)
+ {
+ /* everything already synced */
+ clean_sync (ms);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_ACTION_INVALID,
+ "already in sync");
+ return NULL;
+ }
+ ms->ra.cleanup = &clean_sync;
+ ms->ra.cleanup_cls = ms;
+ return &ms->ra;
+}
diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c
index 85a9c50..e795c55 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -100,8 +100,9 @@ ANASTASIS_recovery_start (const struct GNUNET_CONFIGURATION_Handle *cfg)
pid = fork ();
if (pid == 0)
{
- close (pipefd_stdout[0]);
- dup2 (pipefd_stdout[1], STDOUT_FILENO);
+ (void) close (pipefd_stdout[0]);
+ (void) dup2 (pipefd_stdout[1],
+ STDOUT_FILENO);
execlp (external_reducer,
external_reducer,
"-r",
@@ -150,6 +151,11 @@ ANASTASIS_recovery_start (const struct GNUNET_CONFIGURATION_Handle *cfg)
initial_state = ANASTASIS_REDUX_load_continents_ ();
if (NULL == initial_state)
return NULL;
+ GNUNET_assert (
+ 0 ==
+ json_object_set_new (initial_state,
+ "reducer_type",
+ json_string ("recovery")));
set_state (initial_state,
ANASTASIS_RECOVERY_STATE_CONTINENT_SELECTING);
return initial_state;
@@ -452,7 +458,7 @@ find_challenge_in_ri (json_t *state,
/**
- * Find challenge of @a uuid in @a state under "cs".
+ * Find challenge of @a uuid in @a state under "challenges".
*
* @param state the state to search
* @param uuid the UUID to search for
@@ -465,7 +471,7 @@ find_challenge_in_cs (json_t *state,
json_t *rd = json_object_get (state,
"recovery_document");
json_t *cs = json_object_get (rd,
- "cs");
+ "challenges");
json_t *c;
size_t off;
@@ -504,7 +510,7 @@ find_challenge_in_cs (json_t *state,
* @param csr response details
*/
static void
-answer_feedback_cb (
+start_feedback_cb (
void *cls,
const struct ANASTASIS_ChallengeStartResponse *csr)
{
@@ -533,114 +539,50 @@ answer_feedback_cb (
}
switch (csr->cs)
{
- case ANASTASIS_CHALLENGE_STATUS_SOLVED:
+ case ANASTASIS_CHALLENGE_START_STATUS_FILENAME_PROVIDED:
{
- json_t *rd;
-
- rd = ANASTASIS_recovery_serialize (sctx->r);
- if (NULL == rd)
- {
- GNUNET_break (0);
- ANASTASIS_redux_fail_ (sctx->cb,
- sctx->cb_cls,
- TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
- "unable to serialize recovery state");
- sctx_free (sctx);
- return;
- }
- GNUNET_assert (0 ==
- json_object_set_new (sctx->state,
- "recovery_document",
- rd));
- }
- {
- json_t *solved;
+ json_t *instructions;
+ char *hint;
- solved = GNUNET_JSON_PACK (
+ GNUNET_asprintf (&hint,
+ _ ("Required TAN can be found in `%s'"),
+ csr->details.tan_filename);
+ instructions = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("state",
- "solved"));
+ "code-in-file"),
+ GNUNET_JSON_pack_string ("filename",
+ csr->details.tan_filename),
+ GNUNET_JSON_pack_string ("display_hint",
+ hint));
+ GNUNET_free (hint);
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
- solved));
+ instructions));
}
- /* Delay reporting challenge success, as we MAY still
- also see a secret recovery success (and we can only
- call the callback once) */
- sctx->delayed_report = GNUNET_SCHEDULER_add_now (&report_solved,
- sctx);
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS:
+ case ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED:
{
json_t *instructions;
- const char *mime;
-
- mime = csr->details.open_challenge.content_type;
- if (NULL != mime)
- {
- if ( (0 == strcasecmp (mime,
- "text/plain")) ||
- (0 == strcasecmp (mime,
- "text/utf8")) )
- {
- char *s = GNUNET_strndup (csr->details.open_challenge.body,
- csr->details.open_challenge.body_size);
-
- instructions = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("state",
- "hint"),
- GNUNET_JSON_pack_string ("hint",
- s),
- GNUNET_JSON_pack_uint64 ("http_status",
- (json_int_t) csr->details.open_challenge.
- http_status));
- GNUNET_free (s);
- }
- else if (0 == strcasecmp (mime,
- "application/json"))
- {
- json_t *body;
+ char *hint;
- body = json_loadb (csr->details.open_challenge.body,
- csr->details.open_challenge.body_size,
- JSON_REJECT_DUPLICATES,
- NULL);
- if (NULL == body)
- {
- GNUNET_break_op (0);
- mime = NULL;
- }
- else
- {
- instructions = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("state",
- "details"),
- GNUNET_JSON_pack_object_steal ("details",
- body),
- GNUNET_JSON_pack_uint64 ("http_status",
- csr->details.open_challenge.http_status));
- }
- }
- else
- {
- /* unexpected / unsupported mime type */
- mime = NULL;
- }
- }
- if (NULL == mime)
- {
- instructions = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("state",
- "body"),
- GNUNET_JSON_pack_data_varsize ("body",
- csr->details.open_challenge.body,
- csr->details.open_challenge.body_size),
- GNUNET_JSON_pack_uint64 ("http_status",
- csr->details.open_challenge.http_status),
- GNUNET_JSON_pack_allow_null (
- GNUNET_JSON_pack_string ("mime_type",
- mime)));
- }
+ GNUNET_asprintf (&hint,
+ _ ("TAN code was sent to `%s'"),
+ csr->details.tan_address_hint);
+ instructions = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("state",
+ "send-to-address"),
+ GNUNET_JSON_pack_string ("address_hint",
+ csr->details.tan_address_hint),
+ GNUNET_JSON_pack_string ("display_hint",
+ hint));
+ GNUNET_free (hint);
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
@@ -653,20 +595,24 @@ answer_feedback_cb (
sctx->state);
sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_REDIRECT_FOR_AUTHENTICATION:
+
+ case ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT:
{
- json_t *redir;
+ json_t *instructions;
+ char *hint;
- redir = GNUNET_JSON_PACK (
+ GNUNET_asprintf (&hint,
+ _ ("TAN code already sent."));
+ instructions = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("state",
- "redirect"),
- GNUNET_JSON_pack_string ("redirect_url",
- csr->details.redirect_url));
- GNUNET_assert (NULL != redir);
+ "send-to-address"),
+ GNUNET_JSON_pack_string ("display_hint",
+ hint));
+ GNUNET_free (hint);
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
- redir));
+ instructions));
}
set_state (sctx->state,
ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
@@ -675,21 +621,29 @@ answer_feedback_cb (
sctx->state);
sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED:
+
+ case ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED:
{
json_t *pay;
+ char *hint;
+ GNUNET_asprintf (&hint,
+ _ ("Taler payment to `%s' required"),
+ csr->details.payment_required.taler_pay_uri);
pay = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("state",
- "payment"),
- GNUNET_JSON_pack_string ("taler_pay_uri",
- csr->details.payment_required.
- taler_pay_uri),
+ "taler-payment"),
+ GNUNET_JSON_pack_string (
+ "taler_pay_uri",
+ csr->details.payment_required.taler_pay_uri),
GNUNET_JSON_pack_string ("provider",
cd->provider_url),
+ GNUNET_JSON_pack_string ("display_hint",
+ hint),
GNUNET_JSON_pack_data_auto (
"payment_secret",
&csr->details.payment_required.payment_secret));
+ GNUNET_free (hint);
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
@@ -715,7 +669,7 @@ answer_feedback_cb (
sctx->state);
sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE:
+ case ANASTASIS_CHALLENGE_START_STATUS_SERVER_FAILURE:
{
json_t *err;
@@ -723,10 +677,9 @@ answer_feedback_cb (
GNUNET_JSON_pack_string ("state",
"server-failure"),
GNUNET_JSON_pack_uint64 ("http_status",
- csr->details.server_failure.
- http_status),
+ csr->http_status),
GNUNET_JSON_pack_uint64 ("error_code",
- csr->details.server_failure.ec));
+ csr->ec));
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
@@ -735,17 +688,19 @@ answer_feedback_cb (
set_state (sctx->state,
ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
sctx->cb (sctx->cb_cls,
- csr->details.server_failure.ec,
+ csr->ec,
sctx->state);
sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN:
+ case ANASTASIS_CHALLENGE_START_STATUS_TRUTH_UNKNOWN:
{
json_t *err;
err = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("state",
"truth-unknown"),
+ GNUNET_JSON_pack_uint64 ("http_status",
+ csr->http_status),
GNUNET_JSON_pack_uint64 ("error_code",
TALER_EC_ANASTASIS_TRUTH_UNKNOWN));
GNUNET_assert (0 ==
@@ -760,15 +715,242 @@ answer_feedback_cb (
sctx->state);
sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED:
+ case ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED:
+ {
+ json_t *reply;
+ json_t *c;
+ char *hint;
+
+ c = find_challenge_in_cs (sctx->state,
+ &cd->uuid);
+ if (NULL == c)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ NULL);
+ sctx_free (sctx);
+ return;
+ }
+ GNUNET_assert (0 ==
+ json_object_set_new (c,
+ "async",
+ json_true ()));
+ GNUNET_assert (
+ 0 ==
+ json_object_set_new (
+ c,
+ "answer-pin",
+ json_integer (
+ csr->details.bank_transfer_required.answer_code)));
+ GNUNET_asprintf (&hint,
+ _ ("Wire %s to %s (%s) with subject %s\n"),
+ TALER_amount2s (
+ &csr->details.bank_transfer_required.amount),
+ csr->details.bank_transfer_required.target_iban,
+ csr->details.bank_transfer_required.target_business_name,
+ csr->details.bank_transfer_required.wire_transfer_subject);
+ reply = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("state",
+ "iban-instructions"),
+ GNUNET_JSON_pack_string (
+ "target_iban",
+ csr->details.bank_transfer_required.target_iban),
+ GNUNET_JSON_pack_string (
+ "display_hint",
+ hint),
+ GNUNET_JSON_pack_string (
+ "target_business_name",
+ csr->details.bank_transfer_required.target_business_name),
+ GNUNET_JSON_pack_string (
+ "wire_transfer_subject",
+ csr->details.bank_transfer_required.wire_transfer_subject),
+ TALER_JSON_pack_amount (
+ "challenge_amount",
+ &csr->details.bank_transfer_required.amount));
+ GNUNET_free (hint);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ reply));
+ }
+ GNUNET_assert (0 ==
+ json_object_set_new (sctx->state,
+ "selected_challenge_uuid",
+ GNUNET_JSON_from_data_auto (
+ &cd->uuid)));
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ }
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ NULL);
+ sctx_free (sctx);
+}
+
+
+/**
+ * Defines a callback for the response status for a challenge answer
+ * operation.
+ *
+ * @param cls a `struct SelectChallengeContext *`
+ * @param csr response details
+ */
+static void
+answer_feedback_cb (
+ void *cls,
+ const struct ANASTASIS_ChallengeAnswerResponse *csr)
+{
+ struct SelectChallengeContext *sctx = cls;
+ const struct ANASTASIS_ChallengeDetails *cd;
+ char uuid[sizeof (cd->uuid) * 2];
+ char *end;
+ json_t *feedback;
+
+ cd = ANASTASIS_challenge_get_details (csr->challenge);
+ end = GNUNET_STRINGS_data_to_string (&cd->uuid,
+ sizeof (cd->uuid),
+ uuid,
+ sizeof (uuid));
+ GNUNET_assert (NULL != end);
+ *end = '\0';
+ feedback = json_object_get (sctx->state,
+ "challenge_feedback");
+ if (NULL == feedback)
+ {
+ feedback = json_object ();
+ GNUNET_assert (0 ==
+ json_object_set_new (sctx->state,
+ "challenge_feedback",
+ feedback));
+ }
+ switch (csr->cs)
+ {
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED:
+ {
+ json_t *rd;
+
+ rd = ANASTASIS_recovery_serialize (sctx->r);
+ if (NULL == rd)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
+ "unable to serialize recovery state");
+ sctx_free (sctx);
+ return;
+ }
+ GNUNET_assert (0 ==
+ json_object_set_new (sctx->state,
+ "recovery_document",
+ rd));
+ }
+ {
+ json_t *solved;
+
+ solved = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("state",
+ "solved"));
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ solved));
+ }
+ /* Delay reporting challenge success, as we MAY still
+ also see a secret recovery success (and we can only
+ call the callback once) */
+ sctx->delayed_report = GNUNET_SCHEDULER_add_now (&report_solved,
+ sctx);
+ return;
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_INVALID_ANSWER:
+ {
+ json_t *instructions;
+
+ instructions = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("state",
+ "incorrect-answer"),
+ GNUNET_JSON_pack_uint64 ("error_code",
+ csr->ec));
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ instructions));
+ }
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_PAYMENT_REQUIRED:
+ {
+ json_t *pay;
+ char *hint;
+
+ GNUNET_asprintf (&hint,
+ _ ("Taler payment to `%s' required"),
+ csr->details.payment_required.taler_pay_uri);
+ pay = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("state",
+ "taler-payment"),
+ GNUNET_JSON_pack_string (
+ "taler_pay_uri",
+ csr->details.payment_required.taler_pay_uri),
+ GNUNET_JSON_pack_string (
+ "display_hint",
+ hint),
+ GNUNET_JSON_pack_string ("provider",
+ cd->provider_url),
+ GNUNET_JSON_pack_data_auto (
+ "payment_secret",
+ &csr->details.payment_required.payment_secret));
+ GNUNET_free (hint);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ pay));
+ }
+ /* Remember payment secret for later (once application claims it paid) */
+ {
+ json_t *challenge = find_challenge_in_ri (sctx->state,
+ &cd->uuid);
+
+ GNUNET_assert (NULL != challenge);
+ GNUNET_assert (0 ==
+ json_object_set_new (
+ challenge,
+ "payment_secret",
+ GNUNET_JSON_from_data_auto (
+ &csr->details.payment_required.payment_secret)));
+ }
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_SERVER_FAILURE:
{
json_t *err;
err = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("state",
- "rate-limit-exceeded"),
+ "server-failure"),
+ GNUNET_JSON_pack_uint64 ("http_status",
+ csr->http_status),
GNUNET_JSON_pack_uint64 ("error_code",
- TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED));
+ csr->ec));
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
@@ -777,118 +959,71 @@ answer_feedback_cb (
set_state (sctx->state,
ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
sctx->cb (sctx->cb_cls,
- TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED,
+ csr->ec,
sctx->state);
sctx_free (sctx);
return;
- case ANASTASIS_CHALLENGE_STATUS_AUTH_TIMEOUT:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_TRUTH_UNKNOWN:
{
json_t *err;
err = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("state",
- "authentication-timeout"),
+ "truth-unknown"),
+ GNUNET_JSON_pack_uint64 ("http_status",
+ csr->http_status),
GNUNET_JSON_pack_uint64 ("error_code",
- TALER_EC_ANASTASIS_TRUTH_AUTH_TIMEOUT));
+ TALER_EC_ANASTASIS_TRUTH_UNKNOWN));
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
err));
}
- GNUNET_break_op (0);
set_state (sctx->state,
ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
sctx->cb (sctx->cb_cls,
- TALER_EC_ANASTASIS_TRUTH_AUTH_TIMEOUT,
+ TALER_EC_ANASTASIS_TRUTH_UNKNOWN,
sctx->state);
sctx_free (sctx);
return;
-
- case ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_RATE_LIMIT_EXCEEDED:
{
- const json_t *body = csr->details.external_challenge;
- const char *method;
- json_t *details;
- bool is_async = false;
- uint64_t code = 0;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("method",
- &method),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("async",
- &is_async)),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_uint64 ("answer_code",
- &code)),
- GNUNET_JSON_spec_json ("details",
- &details),
- GNUNET_JSON_spec_end ()
- };
- json_t *reply;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (body,
- spec,
- NULL, NULL))
- {
- json_t *err;
-
- GNUNET_break_op (0);
- err = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("state",
- "server-failure"),
- GNUNET_JSON_pack_uint64 ("error_code",
- TALER_EC_GENERIC_REPLY_MALFORMED));
- GNUNET_assert (0 ==
- json_object_set_new (feedback,
- uuid,
- err));
- return;
- }
- if (is_async)
- {
- json_t *c = find_challenge_in_cs (sctx->state,
- &cd->uuid);
-
- if (NULL == c)
- {
- GNUNET_break (0);
- ANASTASIS_redux_fail_ (sctx->cb,
- sctx->cb_cls,
- TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
- NULL);
- sctx_free (sctx);
- return;
- }
- GNUNET_assert (0 ==
- json_object_set_new (c,
- "async",
- json_true ()));
- GNUNET_assert (0 ==
- json_object_set_new (c,
- "answer-pin",
- json_integer (code)));
- }
- reply = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("state",
- "external-instructions"),
- GNUNET_JSON_pack_string ("method",
- method),
- GNUNET_JSON_pack_object_incref ("details",
- details));
- GNUNET_JSON_parse_free (spec);
+ json_t *err;
+ char *hint;
+
+ GNUNET_asprintf (
+ &hint,
+ _ ("exceeded limit of %llu attempts in %s"),
+ (unsigned long long) csr->details.rate_limit_exceeded.request_limit,
+ GNUNET_TIME_relative2s (
+ csr->details.rate_limit_exceeded.request_frequency,
+ true));
+ err = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string (
+ "state",
+ "rate-limit-exceeded"),
+ GNUNET_JSON_pack_string (
+ "display_hint",
+ hint),
+ GNUNET_JSON_pack_uint64 (
+ "request_limit",
+ csr->details.rate_limit_exceeded.request_limit),
+ GNUNET_JSON_pack_time_rel (
+ "request_frequency",
+ csr->details.rate_limit_exceeded.request_frequency),
+ GNUNET_JSON_pack_uint64 (
+ "error_code",
+ TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED));
+ GNUNET_free (hint);
GNUNET_assert (0 ==
json_object_set_new (feedback,
uuid,
- reply));
+ err));
}
- json_object_set_new (sctx->state,
- "selected_challenge_uuid",
- GNUNET_JSON_from_data_auto (&cd->uuid));
set_state (sctx->state,
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
sctx->cb (sctx->cb_cls,
- TALER_EC_NONE,
+ TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED,
sctx->state);
sctx_free (sctx);
return;
@@ -924,7 +1059,8 @@ solve_challenge_cb (void *cls,
struct GNUNET_JSON_Specification tspec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_relative_time ("timeout",
- &timeout)),
+ &timeout),
+ NULL),
GNUNET_JSON_spec_end ()
};
struct GNUNET_JSON_Specification pspec[] = {
@@ -1189,21 +1325,19 @@ solve_challenge_cb (void *cls,
sctx_free (sctx);
return;
}
- ret = ANASTASIS_challenge_start (ci,
- psp,
- timeout,
- &hashed_answer,
- &answer_feedback_cb,
- sctx);
+ ret = ANASTASIS_challenge_answer3 (ci,
+ psp,
+ timeout,
+ &hashed_answer,
+ &answer_feedback_cb,
+ sctx);
}
else
{
/* no answer provided */
ret = ANASTASIS_challenge_start (ci,
psp,
- timeout,
- NULL, /* no answer */
- &answer_feedback_cb,
+ &start_feedback_cb,
sctx);
}
}
@@ -1323,9 +1457,7 @@ pay_challenge_cb (void *cls,
{
ret = ANASTASIS_challenge_start (ci,
&sctx->ps,
- sctx->timeout,
- NULL, /* no answer yet */
- &answer_feedback_cb,
+ &start_feedback_cb,
sctx);
}
if (GNUNET_OK != ret)
@@ -1519,7 +1651,8 @@ pay_challenge (json_t *state,
struct GNUNET_JSON_Specification aspec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_relative_time ("timeout",
- &timeout)),
+ &timeout),
+ NULL),
GNUNET_JSON_spec_fixed_auto ("payment_secret",
&sctx->ps),
GNUNET_JSON_spec_end ()
@@ -1617,7 +1750,8 @@ select_challenge_cb (void *cls,
struct GNUNET_JSON_Specification tspec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_relative_time ("timeout",
- &timeout)),
+ &timeout),
+ NULL),
GNUNET_JSON_spec_end ()
};
struct GNUNET_JSON_Specification pspec[] = {
@@ -1772,9 +1906,7 @@ select_challenge_cb (void *cls,
{
ret = ANASTASIS_challenge_start (ci,
psp,
- timeout,
- NULL, /* no answer */
- &answer_feedback_cb,
+ &start_feedback_cb,
sctx);
}
}
@@ -1910,256 +2042,15 @@ back_challenge_solving (json_t *state,
/**
- * The user wants us to change the policy version. Download another version.
- *
- * @param[in] state we are in
- * @param arguments our arguments with the solution
- * @param cb functiont o call with the new state
- * @param cb_cls closure for @a cb
- * @return handle to cancel challenge selection step
- */
-static struct ANASTASIS_ReduxAction *
-change_version (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- uint64_t version;
- const char *provider_url;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_uint64 ("version",
- &version),
- GNUNET_JSON_spec_string ("provider_url",
- &provider_url),
- GNUNET_JSON_spec_end ()
- };
- json_t *ia;
- json_t *args;
- struct ANASTASIS_ReduxAction *ra;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (arguments,
- spec,
- NULL, NULL))
- {
- GNUNET_break (0);
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "'version' invalid");
- return NULL;
- }
- GNUNET_assert (NULL != provider_url);
- ia = json_object_get (state,
- "identity_attributes");
- if (NULL == ia)
- {
- GNUNET_break (0);
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "'identity_attributes' missing");
- return NULL;
- }
- args = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_uint64 ("version",
- version),
- GNUNET_JSON_pack_object_incref ("identity_attributes",
- (json_t *) ia),
- GNUNET_JSON_pack_string ("provider_url",
- provider_url));
- if (NULL == args)
- {
- GNUNET_break (0);
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
- NULL);
- return NULL;
- }
- ra = ANASTASIS_REDUX_recovery_challenge_begin_ (state,
- args,
- cb,
- cb_cls);
- json_decref (args);
- return ra;
-}
-
-
-/**
- * DispatchHandler/Callback function which is called for a
- * "next" action in "secret_selecting" state.
- *
- * @param state state to operate on
- * @param arguments arguments to use for operation on state
- * @param cb callback to call during/after operation
- * @param cb_cls callback closure
- * @return NULL
- */
-static struct ANASTASIS_ReduxAction *
-done_secret_selecting (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- const json_t *ri;
-
- ri = json_object_get (state,
- "recovery_information");
- if ( (NULL == ri) ||
- (NULL == json_object_get (ri,
- "challenges")) )
- {
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID_FOR_STATE,
- "no valid version selected");
- return NULL;
- }
- set_state (state,
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
- cb (cb_cls,
- TALER_EC_NONE,
- state);
- return NULL;
-}
-
-
-/**
- * Signature of callback function that implements a state transition.
- *
- * @param state current state
- * @param arguments arguments for the state transition
- * @param cb function to call when done
- * @param cb_cls closure for @a cb
- */
-typedef struct ANASTASIS_ReduxAction *
-(*DispatchHandler)(json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls);
-
-
-struct ANASTASIS_ReduxAction *
-ANASTASIS_recovery_action_ (json_t *state,
- const char *action,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- struct Dispatcher
- {
- enum ANASTASIS_RecoveryState recovery_state;
- const char *recovery_action;
- DispatchHandler fun;
- } dispatchers[] = {
- {
- ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
- "change_version",
- &change_version
- },
- {
- ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
- "next",
- &done_secret_selecting
- },
- {
- ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
- "back",
- &ANASTASIS_back_generic_decrement_
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
- "select_challenge",
- &select_challenge
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
- "poll",
- &poll_challenges
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
- "back",
- &ANASTASIS_back_generic_decrement_
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
- "pay",
- &pay_challenge
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
- "back",
- &ANASTASIS_back_generic_decrement_
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
- "solve_challenge",
- &solve_challenge
- },
- {
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
- "back",
- &back_challenge_solving
- },
- { ANASTASIS_RECOVERY_STATE_INVALID, NULL, NULL }
- };
- const char *s = json_string_value (json_object_get (state,
- "recovery_state"));
- enum ANASTASIS_RecoveryState rs;
-
- GNUNET_assert (NULL != s);
- rs = ANASTASIS_recovery_state_from_string_ (s);
- if (ANASTASIS_RECOVERY_STATE_INVALID == rs)
- {
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
- "'recovery_state' field invalid");
- return NULL;
- }
- for (unsigned int i = 0; NULL != dispatchers[i].fun; i++)
- {
- if ( (rs == dispatchers[i].recovery_state) &&
- (0 == strcmp (action,
- dispatchers[i].recovery_action)) )
- {
- return dispatchers[i].fun (state,
- arguments,
- cb,
- cb_cls);
- }
- }
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_ACTION_INVALID,
- action);
- return NULL;
-}
-
-
-/**
- * State for a "recover secret" CMD.
- */
-struct RecoverSecretState;
-
-
-/**
* State for a "policy download" as part of a recovery operation.
*/
struct PolicyDownloadEntry
{
/**
- * Kept in a DLL.
- */
- struct PolicyDownloadEntry *prev;
-
- /**
- * Kept in a DLL.
+ * Redux action handle associated with this state.
*/
- struct PolicyDownloadEntry *next;
+ struct ANASTASIS_ReduxAction ra;
/**
* Backend we are querying.
@@ -2167,286 +2058,46 @@ struct PolicyDownloadEntry
char *backend_url;
/**
- * Salt to be used to derive the id for this provider
- */
- struct ANASTASIS_CRYPTO_ProviderSaltP salt;
-
- /**
- * Context we operate in.
- */
- struct RecoverSecretState *rss;
-
- /**
* The /policy GET operation handle.
*/
struct ANASTASIS_Recovery *recovery;
-};
-
-
-/**
- * Entry in the list of all known applicable Anastasis providers.
- * Used to wait for it to complete downloading /config.
- */
-struct RecoveryStartStateProviderEntry
-{
- /**
- * Kept in a DLL.
- */
- struct RecoveryStartStateProviderEntry *next;
-
- /**
- * Kept in a DLL.
- */
- struct RecoveryStartStateProviderEntry *prev;
-
- /**
- * Main operation this entry is part of.
- */
- struct RecoverSecretState *rss;
-
- /**
- * Resulting provider information, NULL if not (yet) available.
- */
- json_t *istate;
-
- /**
- * Ongoing reducer action to obtain /config, NULL if completed.
- */
- struct ANASTASIS_ReduxAction *ra;
-
- /**
- * Final result of the operation (once completed).
- */
- enum TALER_ErrorCode ec;
-};
-
-
-/**
- * State for a "recover secret" CMD.
- */
-struct RecoverSecretState
-{
-
/**
- * Redux action handle associated with this state.
- */
- struct ANASTASIS_ReduxAction ra;
-
- /**
- * Head of list of provider /config operations we are doing.
- */
- struct RecoveryStartStateProviderEntry *pe_head;
-
- /**
- * Tail of list of provider /config operations we are doing.
- */
- struct RecoveryStartStateProviderEntry *pe_tail;
-
- /**
- * Identification data from the user
- */
- json_t *id_data;
-
- /**
- * Head of DLL of policy downloads.
- */
- struct PolicyDownloadEntry *pd_head;
-
- /**
- * Tail of DLL of policy downloads.
- */
- struct PolicyDownloadEntry *pd_tail;
-
- /**
- * Reference to our state.
- */
- json_t *state;
-
- /**
- * callback to call during/after operation
+ * Function to call with the result.
*/
ANASTASIS_ActionCallback cb;
/**
- * closure for action callback @e cb.
+ * Closure for @e cb.
*/
void *cb_cls;
/**
- * Set if recovery must be done with this provider.
- */
- char *provider_url;
-
- /**
- * version of the recovery document to request.
+ * State we are using.
*/
- unsigned int version;
-
- /**
- * Number of provider /config operations in @e ba_head that
- * are still awaiting completion.
- */
- unsigned int pending;
+ json_t *state;
- /**
- * Is @e version set?
- */
- bool have_version;
};
/**
- * Function to free a `struct RecoverSecretState`
+ * Free @a cls data structure.
*
- * @param cls must be a `struct RecoverSecretState`
+ * @param[in] cls data structure to free, must be a `struct PolicyDownloadEntry *`
*/
static void
-free_rss (void *cls)
+free_pd (void *cls)
{
- struct RecoverSecretState *rss = cls;
- struct PolicyDownloadEntry *pd;
- struct RecoveryStartStateProviderEntry *pe;
+ struct PolicyDownloadEntry *pd = cls;
- while (NULL != (pe = rss->pe_head))
- {
- GNUNET_CONTAINER_DLL_remove (rss->pe_head,
- rss->pe_tail,
- pe);
- ANASTASIS_redux_action_cancel (pe->ra);
- rss->pending--;
- GNUNET_free (pe);
- }
- while (NULL != (pd = rss->pd_head))
+ if (NULL != pd->recovery)
{
- GNUNET_CONTAINER_DLL_remove (rss->pd_head,
- rss->pd_tail,
- pd);
- if (NULL != pd->recovery)
- {
- ANASTASIS_recovery_abort (pd->recovery);
- pd->recovery = NULL;
- }
- GNUNET_free (pd->backend_url);
- GNUNET_free (pd);
+ ANASTASIS_recovery_abort (pd->recovery);
+ pd->recovery = NULL;
}
- json_decref (rss->state);
- json_decref (rss->id_data);
- GNUNET_assert (0 == rss->pending);
- GNUNET_free (rss->provider_url);
- GNUNET_free (rss);
-}
-
-
-/**
- * This function is called whenever the recovery process ends.
- * In this case, that should not be possible as this callback
- * is used before we even begin with the challenges. So if
- * we are called, it is because of some fatal error.
- *
- * @param cls a `struct PolicyDownloadEntry`
- * @param rc error code
- * @param secret contains the core secret which is passed to the user
- * @param secret_size defines the size of the core secret
- */
-static void
-core_early_secret_cb (void *cls,
- enum ANASTASIS_RecoveryStatus rc,
- const void *secret,
- size_t secret_size)
-{
- struct PolicyDownloadEntry *pd = cls;
- struct RecoverSecretState *rss = pd->rss;
-
- pd->recovery = NULL;
- GNUNET_assert (NULL == secret);
- GNUNET_CONTAINER_DLL_remove (rss->pd_head,
- rss->pd_tail,
- pd);
GNUNET_free (pd->backend_url);
+ json_decref (pd->state);
GNUNET_free (pd);
- if (NULL != rss->pd_head)
- return; /* wait for another one */
- /* all failed! report failure! */
- GNUNET_assert (ANASTASIS_RS_SUCCESS != rc);
- fail_by_error (rss->cb,
- rss->cb_cls,
- rc);
- rss->cb = NULL;
- free_rss (rss);
-}
-
-
-/**
- * Determine recovery @a cost of solving a challenge of type @a type
- * at @a provider_url by inspecting @a state.
- *
- * @param state the state to inspect
- * @param provider_url the provider to lookup config info from
- * @param type the method to lookup the cost of
- * @param[out] cost the recovery cost to return
- * @return #GNUNET_OK on success, #GNUNET_NO if not found, #GNUNET_SYSERR on state error
- */
-static int
-lookup_cost (const json_t *state,
- const char *provider_url,
- const char *type,
- struct TALER_Amount *cost)
-{
- const json_t *providers;
- const json_t *provider;
- const json_t *methods;
-
- providers = json_object_get (state,
- "authentication_providers");
- if (NULL == providers)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- provider = json_object_get (providers,
- provider_url);
- if (NULL == provider)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- methods = json_object_get (provider,
- "methods");
- if ( (NULL == methods) ||
- (! json_is_array (methods)) )
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
- {
- size_t index;
- json_t *method;
-
- json_array_foreach (methods, index, method) {
- const char *t;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("type",
- &t),
- TALER_JSON_spec_amount_any ("usage_fee",
- cost),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (method,
- spec,
- NULL, NULL))
- {
- GNUNET_break (0);
- continue;
- }
- if (0 == strcmp (t,
- type))
- return GNUNET_OK;
- }
- }
- return GNUNET_NO; /* not found */
}
@@ -2455,27 +2106,22 @@ lookup_cost (const json_t *state,
* allow the user to specify alternative providers and/or policy
* versions.
*
- * @param[in] rss state to fail with the policy download
+ * @param[in] pd state to fail with the policy download
* @param offline true of the reason to show is that all providers
* were offline / did not return a salt to us
*/
static void
-return_no_policy (struct RecoverSecretState *rss,
+return_no_policy (struct PolicyDownloadEntry *pd,
bool offline)
{
+ enum TALER_ErrorCode ec = TALER_EC_ANASTASIS_REDUCER_NETWORK_FAILED;
+ const char *detail = (offline)
+ ? "could not contact provider (offline)"
+ : "provider does not know this policy";
json_t *estate;
- const char *detail;
- enum TALER_ErrorCode ec;
- ec = TALER_EC_ANASTASIS_REDUCER_NETWORK_FAILED;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No provider online, need user to manually specify providers!\n");
-
- if (offline)
- detail = "could not contact provider (offline)";
- else
- detail = "provider does not know you";
-
+ "Provider offline!\n");
estate = GNUNET_JSON_PACK (
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string ("detail",
@@ -2484,10 +2130,10 @@ return_no_policy (struct RecoverSecretState *rss,
ec),
GNUNET_JSON_pack_string ("hint",
TALER_ErrorCode_get_hint (ec)));
- rss->cb (rss->cb_cls,
- ec,
- estate);
- free_rss (rss);
+ pd->cb (pd->cb_cls,
+ ec,
+ estate);
+ free_pd (pd);
}
@@ -2500,7 +2146,7 @@ return_no_policy (struct RecoverSecretState *rss,
* cancel all of the others, passing the obtained recovery information
* back to the user.
*
- * @param cls closure for the callback
+ * @param cls closure for the callback with a `struct PolicyDownloadEntry *`
* @param ri recovery information struct which contains the policies
*/
static void
@@ -2508,7 +2154,6 @@ policy_lookup_cb (void *cls,
const struct ANASTASIS_RecoveryInformation *ri)
{
struct PolicyDownloadEntry *pd = cls;
- struct RecoverSecretState *rss = pd->rss;
json_t *policies;
json_t *challenges;
json_t *recovery_information;
@@ -2516,16 +2161,10 @@ policy_lookup_cb (void *cls,
if (NULL == ri)
{
/* Woopsie, failed hard. */
- GNUNET_CONTAINER_DLL_remove (rss->pd_head,
- rss->pd_tail,
- pd);
ANASTASIS_recovery_abort (pd->recovery);
GNUNET_free (pd->backend_url);
GNUNET_free (pd);
- if (NULL != rss->pd_head)
- return; /* wait for another one */
- /* all failed! report failure! */
- return_no_policy (rss,
+ return_no_policy (pd,
false);
return;
}
@@ -2564,35 +2203,15 @@ policy_lookup_cb (void *cls,
struct ANASTASIS_Challenge *c = ri->cs[i];
const struct ANASTASIS_ChallengeDetails *cd;
json_t *cj;
- struct TALER_Amount cost;
- int ret;
cd = ANASTASIS_challenge_get_details (c);
- ret = lookup_cost (rss->state,
- cd->provider_url,
- cd->type,
- &cost);
- if (GNUNET_SYSERR == ret)
- {
- json_decref (challenges);
- json_decref (policies);
- ANASTASIS_redux_fail_ (rss->cb,
- rss->cb_cls,
- TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
- "failed to 'lookup_cost'");
- free_rss (rss);
- return;
- }
-
cj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_data_auto ("uuid",
&cd->uuid),
- TALER_JSON_pack_amount ("cost",
- (GNUNET_NO == ret)
- ? NULL
- : &cost),
GNUNET_JSON_pack_string ("type",
cd->type),
+ GNUNET_JSON_pack_string ("uuid-display",
+ ANASTASIS_CRYPTO_uuid2s (&cd->uuid)),
GNUNET_JSON_pack_string ("instructions",
cd->instructions));
GNUNET_assert (0 ==
@@ -2612,7 +2231,7 @@ policy_lookup_cb (void *cls,
GNUNET_JSON_pack_uint64 ("version",
ri->version));
GNUNET_assert (0 ==
- json_object_set_new (rss->state,
+ json_object_set_new (pd->state,
"recovery_information",
recovery_information));
{
@@ -2622,228 +2241,387 @@ policy_lookup_cb (void *cls,
if (NULL == rd)
{
GNUNET_break (0);
- ANASTASIS_redux_fail_ (rss->cb,
- rss->cb_cls,
+ ANASTASIS_redux_fail_ (pd->cb,
+ pd->cb_cls,
TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
"unable to serialize recovery state");
- free_rss (rss);
+ free_pd (pd);
return;
}
GNUNET_assert (0 ==
- json_object_set_new (rss->state,
+ json_object_set_new (pd->state,
"recovery_document",
rd));
}
- /* In case there is an old error remove it! */
- (void) json_object_del (rss->state,
- "recovery_error");
- set_state (rss->state,
- ANASTASIS_RECOVERY_STATE_SECRET_SELECTING);
- rss->cb (rss->cb_cls,
- TALER_EC_NONE,
- rss->state);
- free_rss (rss);
+ set_state (pd->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
+ pd->cb (pd->cb_cls,
+ TALER_EC_NONE,
+ pd->state);
+ free_pd (pd);
}
/**
- * Try to launch recovery at provider @a provider_url with config @a p_cfg.
+ * This function is called whenever the recovery process ends.
+ * In this case, that should not be possible as this callback
+ * is used before we even begin with the challenges. So if
+ * we are called, it is because of some fatal error.
*
- * @param[in,out] rss recovery context
- * @param provider_url base URL of the provider to try
- * @param p_cfg configuration of the provider
- * @return true if a recovery was launched
+ * @param cls a `struct PolicyDownloadEntry`
+ * @param rc error code
+ * @param secret contains the core secret which is passed to the user
+ * @param secret_size defines the size of the core secret
*/
-static bool
-launch_recovery (struct RecoverSecretState *rss,
- const char *provider_url,
- const json_t *p_cfg)
+static void
+core_early_secret_cb (void *cls,
+ enum ANASTASIS_RecoveryStatus rc,
+ const void *secret,
+ size_t secret_size)
{
- struct PolicyDownloadEntry *pd = GNUNET_new (struct PolicyDownloadEntry);
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("salt",
- &pd->salt),
- GNUNET_JSON_spec_end ()
- };
+ struct PolicyDownloadEntry *pd = cls;
- if (MHD_HTTP_OK !=
- json_integer_value (json_object_get (p_cfg,
- "http_status")))
- return false; /* skip providers that are down */
- if (GNUNET_OK !=
- GNUNET_JSON_parse (p_cfg,
- spec,
- NULL, NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No salt for `%s', provider offline?\n",
- provider_url);
- GNUNET_free (pd);
- return false;
- }
- pd->backend_url = GNUNET_strdup (provider_url);
- pd->rss = rss;
- pd->recovery = ANASTASIS_recovery_begin (ANASTASIS_REDUX_ctx_,
- rss->id_data,
- rss->have_version
- ? rss->version
- : 0,
- pd->backend_url,
- &pd->salt,
- &policy_lookup_cb,
- pd,
- &core_early_secret_cb,
- pd);
- if (NULL != pd->recovery)
- {
- GNUNET_CONTAINER_DLL_insert (rss->pd_head,
- rss->pd_tail,
- pd);
- return true;
- }
- GNUNET_free (pd->backend_url);
- GNUNET_free (pd);
- return false;
+ pd->recovery = NULL;
+ GNUNET_assert (NULL == secret);
+ GNUNET_assert (ANASTASIS_RS_SUCCESS != rc);
+ fail_by_error (pd->cb,
+ pd->cb_cls,
+ rc);
+ free_pd (pd);
}
/**
- * We finished downloading /config from all providers, merge
- * into the main state, trigger the continuation and free our
- * state.
+ * DispatchHandler/Callback function which is called for a
+ * "next" action in "secret_selecting" state.
*
- * @param[in] rss main state to merge into
+ * @param state state to operate on
+ * @param arguments arguments to use for operation on state
+ * @param cb callback to call during/after operation
+ * @param cb_cls callback closure
+ * @return NULL
*/
-static void
-providers_complete (struct RecoverSecretState *rss)
+static struct ANASTASIS_ReduxAction *
+done_secret_selecting (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
{
- bool launched = false;
- struct RecoveryStartStateProviderEntry *pe;
- json_t *tlist;
+ uint32_t mask;
+ const json_t *pa;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_uint32 ("attribute_mask",
+ &mask),
+ GNUNET_JSON_spec_array_const ("providers",
+ &pa),
+ GNUNET_JSON_spec_end ()
+ };
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
+ struct GNUNET_JSON_Specification pspec[] = {
+ GNUNET_JSON_spec_fixed_auto ("provider_salt",
+ &provider_salt),
+ GNUNET_JSON_spec_end ()
+ };
+ json_t *p_cfg;
+ json_t *id_data;
+ const json_t *providers;
- tlist = json_object_get (rss->state,
- "authentication_providers");
- if (NULL == tlist)
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (arguments,
+ spec,
+ NULL, NULL))
{
- tlist = json_object ();
- GNUNET_assert (NULL != tlist);
- GNUNET_assert (0 ==
- json_object_set_new (rss->state,
- "authentication_providers",
- tlist));
+ GNUNET_break (0);
+ json_dumpf (arguments,
+ stderr,
+ JSON_INDENT (2));
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ NULL);
+ return NULL;
}
- while (NULL != (pe = rss->pe_head))
+ providers = json_object_get (state,
+ "authentication_providers");
+ if ( (NULL == providers) ||
+ (! json_is_object (providers)) )
{
- json_t *provider_list;
-
- GNUNET_CONTAINER_DLL_remove (rss->pe_head,
- rss->pe_tail,
- pe);
- provider_list = json_object_get (pe->istate,
- "authentication_providers");
- /* merge provider_list into tlist (overriding existing entries) */
- if (NULL != provider_list)
- {
- const char *url;
- json_t *value;
-
- json_object_foreach (provider_list, url, value) {
- GNUNET_assert (0 ==
- json_object_set (tlist,
- url,
- value));
- }
- }
- json_decref (pe->istate);
- GNUNET_free (pe);
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'authentication_providers' missing");
+ return NULL;
}
- /* now iterate over providers and begin downloading */
- if (NULL != rss->provider_url)
{
- json_t *p_cfg;
-
- p_cfg = json_object_get (tlist,
- rss->provider_url);
- if (NULL != p_cfg)
- launched = launch_recovery (rss,
- rss->provider_url,
- p_cfg);
- }
- else
- {
- json_t *p_cfg;
+ size_t poff;
+ json_t *pe;
+ uint64_t version;
const char *provider_url;
- json_object_foreach (tlist, provider_url, p_cfg)
+ json_array_foreach (pa, poff, pe)
{
- launched |= launch_recovery (rss,
- provider_url,
- p_cfg);
+ struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_uint64 ("version",
+ &version),
+ GNUNET_JSON_spec_string ("url",
+ &provider_url),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (pe,
+ ispec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ json_dumpf (pe,
+ stderr,
+ JSON_INDENT (2));
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ NULL);
+ return NULL;
+ }
+
+ p_cfg = json_object_get (providers,
+ provider_url);
+ if (MHD_HTTP_OK !=
+ json_integer_value (json_object_get (p_cfg,
+ "http_status")))
+ continue;
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (p_cfg,
+ pspec,
+ NULL, NULL))
+ {
+ GNUNET_break (0); /* should be impossible for well-formed state */
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "Salt unknown for selected provider");
+ return NULL;
+ }
+ id_data = json_object_get (state,
+ "identity_attributes");
+ if (NULL == id_data)
+ {
+ GNUNET_break (0); /* should be impossible for well-formed state */
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'identity_attributes' missing");
+ return NULL;
+ }
+ {
+ struct PolicyDownloadEntry *pd
+ = GNUNET_new (struct PolicyDownloadEntry);
+
+ pd->cb = cb;
+ pd->cb_cls = cb_cls;
+ pd->state = json_incref (state);
+ pd->backend_url = GNUNET_strdup (provider_url);
+ pd->recovery = ANASTASIS_recovery_begin (ANASTASIS_REDUX_ctx_,
+ id_data,
+ version,
+ pd->backend_url,
+ &provider_salt,
+ &policy_lookup_cb,
+ pd,
+ &core_early_secret_cb,
+ pd);
+ if (NULL == pd->recovery)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INTERNAL_ERROR,
+ NULL);
+ GNUNET_free (pd->backend_url);
+ json_decref (pd->state);
+ GNUNET_free (pd);
+ return NULL;
+ }
+ pd->ra.cleanup = &free_pd;
+ pd->ra.cleanup_cls = pd;
+ return &pd->ra;
+ }
}
}
- if (! launched)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "No provider online, need user to specify different provider!\n");
- return_no_policy (rss,
- true);
- return;
- }
+
+ /* no provider worked */
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ "selected provider is not online");
+ return NULL;
}
/**
- * Function called when the complete information about a provider
- * was added to @a new_state.
+ * The user wants us to add another provider. Download /config.
*
- * @param cls a `struct RecoveryStartStateProviderEntry`
- * @param error error code
- * @param new_state resulting new state
+ * @param[in] state we are in
+ * @param arguments our arguments with the solution
+ * @param cb function to call with the new state
+ * @param cb_cls closure for @a cb
+ * @return handle to cancel challenge selection step
*/
-static void
-provider_added_cb (void *cls,
- enum TALER_ErrorCode error,
- json_t *new_state)
+static struct ANASTASIS_ReduxAction *
+add_provider (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
{
- struct RecoveryStartStateProviderEntry *pe = cls;
-
- pe->ra = NULL;
- pe->istate = json_incref (new_state);
- pe->ec = error;
- pe->rss->pending--;
- if (0 == pe->rss->pending)
- providers_complete (pe->rss);
+ const char *provider_url;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("provider_url",
+ &provider_url),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (arguments,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ NULL);
+ return NULL;
+ }
+ return ANASTASIS_REDUX_add_provider_to_state_ (provider_url,
+ state,
+ cb,
+ cb_cls);
}
/**
- * Start to query provider for recovery document.
+ * Signature of callback function that implements a state transition.
*
- * @param[in,out] rss overall recovery state
- * @param provider_url base URL of the provider to query
+ * @param state current state
+ * @param arguments arguments for the state transition
+ * @param cb function to call when done
+ * @param cb_cls closure for @a cb
*/
-static void
-begin_query_provider (struct RecoverSecretState *rss,
- const char *provider_url)
+typedef struct ANASTASIS_ReduxAction *
+(*DispatchHandler)(json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls);
+
+
+struct ANASTASIS_ReduxAction *
+ANASTASIS_recovery_action_ (json_t *state,
+ const char *action,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
{
- struct RecoveryStartStateProviderEntry *pe;
- json_t *istate;
-
- pe = GNUNET_new (struct RecoveryStartStateProviderEntry);
- pe->rss = rss;
- istate = json_object ();
- GNUNET_assert (NULL != istate);
- GNUNET_CONTAINER_DLL_insert (rss->pe_head,
- rss->pe_tail,
- pe);
- pe->ra = ANASTASIS_REDUX_add_provider_to_state_ (provider_url,
- istate,
- &provider_added_cb,
- pe);
- json_decref (istate);
- if (NULL != pe->ra)
- rss->pending++;
+ struct Dispatcher
+ {
+ enum ANASTASIS_RecoveryState recovery_state;
+ const char *recovery_action;
+ DispatchHandler fun;
+ } dispatchers[] = {
+ {
+ ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
+ "add_provider",
+ &add_provider
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
+ "poll_providers",
+ &ANASTASIS_REDUX_poll_providers_
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
+ "select_version",
+ &done_secret_selecting
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_SECRET_SELECTING,
+ "back",
+ &ANASTASIS_back_generic_decrement_
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
+ "select_challenge",
+ &select_challenge
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
+ "sync_providers",
+ &ANASTASIS_REDUX_sync_providers_
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
+ "poll",
+ &poll_challenges
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
+ "back",
+ &ANASTASIS_back_generic_decrement_
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
+ "pay",
+ &pay_challenge
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
+ "back",
+ &ANASTASIS_back_generic_decrement_
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
+ "solve_challenge",
+ &solve_challenge
+ },
+ {
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
+ "back",
+ &back_challenge_solving
+ },
+ { ANASTASIS_RECOVERY_STATE_INVALID, NULL, NULL }
+ };
+ const char *s = json_string_value (json_object_get (state,
+ "recovery_state"));
+ enum ANASTASIS_RecoveryState rs;
+
+ GNUNET_assert (NULL != s);
+ rs = ANASTASIS_recovery_state_from_string_ (s);
+ if (ANASTASIS_RECOVERY_STATE_INVALID == rs)
+ {
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
+ "'recovery_state' field invalid");
+ return NULL;
+ }
+ for (unsigned int i = 0; NULL != dispatchers[i].fun; i++)
+ {
+ if ( (rs == dispatchers[i].recovery_state) &&
+ (0 == strcmp (action,
+ dispatchers[i].recovery_action)) )
+ {
+ return dispatchers[i].fun (state,
+ arguments,
+ cb,
+ cb_cls);
+ }
+ }
+ ANASTASIS_redux_fail_ (cb,
+ cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_ACTION_INVALID,
+ action);
+ return NULL;
}
@@ -2853,11 +2631,8 @@ ANASTASIS_REDUX_recovery_challenge_begin_ (json_t *state,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
- json_t *version;
- json_t *providers;
- const json_t *attributes;
- struct RecoverSecretState *rss;
- const char *provider_url;
+ const json_t *providers;
+ json_t *attributes;
providers = json_object_get (state,
"authentication_providers");
@@ -2883,63 +2658,13 @@ ANASTASIS_REDUX_recovery_challenge_begin_ (json_t *state,
"'identity_attributes' missing");
return NULL;
}
- rss = GNUNET_new (struct RecoverSecretState);
- rss->id_data = json_incref ((json_t *) attributes);
- version = json_object_get (arguments,
- "version");
- if (NULL != version)
- {
- rss->version = (unsigned int) json_integer_value (version);
- rss->have_version = true;
- }
- rss->state = json_incref (state);
- rss->cb = cb;
- rss->cb_cls = cb_cls;
- rss->pending = 1; /* decremented after initialization loop */
-
- provider_url = json_string_value (json_object_get (arguments,
- "provider_url"));
- if (NULL != provider_url)
- {
- rss->provider_url = GNUNET_strdup (provider_url);
- begin_query_provider (rss,
- provider_url);
- }
- else
- {
- json_t *prov;
- const char *url;
-
- json_object_foreach (providers, url, prov) {
- bool disabled = false;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_bool ("disabled",
- &disabled)),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (prov,
- spec,
- NULL, NULL))
- {
- /* skip malformed provider entry */
- GNUNET_break_op (0);
- continue;
- }
- begin_query_provider (rss,
- url);
- }
- }
- rss->pending--;
- if (0 == rss->pending)
- {
- providers_complete (rss);
- if (NULL == rss->cb)
- return NULL;
- }
- rss->ra.cleanup = &free_rss;
- rss->ra.cleanup_cls = rss;
- return &rss->ra;
+ json_object_set (state,
+ "identity_attributes",
+ attributes);
+ set_state (state,
+ ANASTASIS_RECOVERY_STATE_SECRET_SELECTING);
+ cb (cb_cls,
+ TALER_EC_NONE,
+ state);
+ return NULL;
}
diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c
index 41bbdda..4b5ad7b 100644
--- a/src/reducer/anastasis_api_redux.c
+++ b/src/reducer/anastasis_api_redux.c
@@ -1,16 +1,16 @@
/*
This file is part of Anastasis
- Copyright (C) 2020, 2021 Anastasis SARL
+ Copyright (C) 2020, 2021, 2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -36,6 +36,12 @@
*/
#define CONFIG_GENERIC_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+/**
+ * How long do we wait in a more "synchronous"
+ * scenaro for a /config reply from an Anastasis provider.
+ */
+#define CONFIG_FAST_TIMEOUT GNUNET_TIME_UNIT_SECONDS
+
#define GENERATE_STRING(STRING) #STRING,
static const char *generic_strings[] = {
@@ -132,6 +138,21 @@ struct ConfigRequest
struct ConfigReduxWaiting *w_tail;
/**
+ * When did we start?
+ */
+ struct GNUNET_TIME_Absolute start_time;
+
+ /**
+ * When do we time out?
+ */
+ struct GNUNET_TIME_Absolute timeout_at;
+
+ /**
+ * How long do we wait before trying again?
+ */
+ struct GNUNET_TIME_Relative backoff;
+
+ /**
* Obtained status code.
*/
unsigned int http_status;
@@ -152,11 +173,6 @@ struct ConfigRequest
char *business_name;
/**
- * currency used by the anastasis backend.
- */
- char *currency;
-
- /**
* Array of authorization methods supported by the server.
*/
struct AuthorizationMethodConfig *methods;
@@ -188,9 +204,9 @@ struct ConfigRequest
struct TALER_Amount liability_limit;
/**
- * Server salt.
+ * Provider salt.
*/
- struct ANASTASIS_CRYPTO_ProviderSaltP salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
/**
* Task to timeout /config requests.
@@ -311,6 +327,8 @@ ANASTASIS_redux_fail_ (ANASTASIS_ActionCallback cb,
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string ("detail",
detail)),
+ GNUNET_JSON_pack_string ("reducer_type",
+ "error"),
GNUNET_JSON_pack_uint64 ("code",
ec),
GNUNET_JSON_pack_string ("hint",
@@ -364,7 +382,6 @@ free_config_request (struct ConfigRequest *cr)
ANASTASIS_config_cancel (cr->co);
if (NULL != cr->tt)
GNUNET_SCHEDULER_cancel (cr->tt);
- GNUNET_free (cr->currency);
GNUNET_free (cr->url);
GNUNET_free (cr->business_name);
for (unsigned int i = 0; i<cr->methods_length; i++)
@@ -491,13 +508,11 @@ notify_waiting (struct ConfigRequest *cr)
"authentication_providers",
provider_list = json_object ()));
}
- provider_list = json_object_get (w->state,
- "authentication_providers");
- GNUNET_assert (NULL != provider_list);
-
if (TALER_EC_NONE != cr->ec)
{
prov = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("status",
+ "error"),
GNUNET_JSON_pack_uint64 ("error_code",
cr->ec),
GNUNET_JSON_pack_uint64 ("http_status",
@@ -523,6 +538,8 @@ notify_waiting (struct ConfigRequest *cr)
mj));
}
prov = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("status",
+ "ok"),
GNUNET_JSON_pack_array_steal ("methods",
methods_list),
TALER_JSON_pack_amount ("annual_fee",
@@ -531,14 +548,12 @@ notify_waiting (struct ConfigRequest *cr)
&cr->truth_upload_fee),
TALER_JSON_pack_amount ("liability_limit",
&cr->liability_limit),
- GNUNET_JSON_pack_string ("currency",
- cr->currency),
GNUNET_JSON_pack_string ("business_name",
cr->business_name),
GNUNET_JSON_pack_uint64 ("storage_limit_in_megabytes",
cr->storage_limit_in_megabytes),
- GNUNET_JSON_pack_data_auto ("salt",
- &cr->salt),
+ GNUNET_JSON_pack_data_auto ("provider_salt",
+ &cr->provider_salt),
GNUNET_JSON_pack_uint64 ("http_status",
cr->http_status));
}
@@ -551,68 +566,108 @@ notify_waiting (struct ConfigRequest *cr)
w->state);
abort_provider_config_cb (w);
}
+}
+
+
+/**
+ * Notify anyone waiting on @a cr that the request is done
+ * (successful or failed).
+ *
+ * @param[in,out] cls request that completed
+ */
+static void
+notify_waiting_cb (void *cls)
+{
+ struct ConfigRequest *cr = cls;
+ cr->tt = NULL;
+ notify_waiting (cr);
}
/**
+ * Function called when it is time to retry a
+ * failed /config request.
+ *
+ * @param cls the `struct ConfigRequest *` to retry.
+ */
+static void
+retry_config (void *cls);
+
+
+/**
* Function called with the results of a #ANASTASIS_get_config().
*
* @param cls closure
- * @param http_status HTTP status of the request
* @param acfg anastasis configuration
*/
static void
config_cb (void *cls,
- unsigned int http_status,
const struct ANASTASIS_Config *acfg)
{
struct ConfigRequest *cr = cls;
cr->co = NULL;
- GNUNET_SCHEDULER_cancel (cr->tt);
- cr->tt = NULL;
- cr->http_status = http_status;
- if (MHD_HTTP_OK != http_status)
- cr->ec = TALER_EC_ANASTASIS_REDUCER_PROVIDER_CONFIG_FAILED;
- if ( (MHD_HTTP_OK == http_status) &&
+ if (NULL != cr->tt)
+ {
+ GNUNET_SCHEDULER_cancel (cr->tt);
+ cr->tt = NULL;
+ }
+ cr->http_status = acfg->http_status;
+ if (MHD_HTTP_OK != acfg->http_status)
+ {
+ if (0 == acfg->http_status)
+ cr->ec = TALER_EC_ANASTASIS_GENERIC_PROVIDER_UNREACHABLE;
+ else
+ cr->ec = TALER_EC_ANASTASIS_REDUCER_PROVIDER_CONFIG_FAILED;
+ }
+ if ( (MHD_HTTP_OK == acfg->http_status) &&
(NULL == acfg) )
{
cr->http_status = MHD_HTTP_NOT_FOUND;
cr->ec = TALER_EC_ANASTASIS_REDUCER_PROVIDER_CONFIG_FAILED;
}
- else if (NULL != acfg)
+ else
{
- if (0 == acfg->storage_limit_in_megabytes)
+ if (0 == acfg->details.ok.storage_limit_in_megabytes)
{
cr->http_status = 0;
cr->ec = TALER_EC_ANASTASIS_REDUCER_PROVIDER_INVALID_CONFIG;
}
else
{
- GNUNET_free (cr->currency);
- cr->currency = GNUNET_strdup (acfg->currency);
+ cr->ec = TALER_EC_NONE;
GNUNET_free (cr->business_name);
- cr->business_name = GNUNET_strdup (acfg->business_name);
+ cr->business_name = GNUNET_strdup (acfg->details.ok.business_name);
for (unsigned int i = 0; i<cr->methods_length; i++)
GNUNET_free (cr->methods[i].type);
GNUNET_free (cr->methods);
- cr->methods = GNUNET_new_array (acfg->methods_length,
+ cr->methods = GNUNET_new_array (acfg->details.ok.methods_length,
struct AuthorizationMethodConfig);
- for (unsigned int i = 0; i<acfg->methods_length; i++)
+ for (unsigned int i = 0; i<acfg->details.ok.methods_length; i++)
{
- cr->methods[i].type = GNUNET_strdup (acfg->methods[i].type);
- cr->methods[i].usage_fee = acfg->methods[i].usage_fee;
+ cr->methods[i].type = GNUNET_strdup (acfg->details.ok.methods[i].type);
+ cr->methods[i].usage_fee = acfg->details.ok.methods[i].usage_fee;
}
- cr->methods_length = acfg->methods_length;
- cr->storage_limit_in_megabytes = acfg->storage_limit_in_megabytes;
- cr->annual_fee = acfg->annual_fee;
- cr->truth_upload_fee = acfg->truth_upload_fee;
- cr->liability_limit = acfg->liability_limit;
- cr->salt = acfg->salt;
+ cr->methods_length = acfg->details.ok.methods_length;
+ cr->storage_limit_in_megabytes =
+ acfg->details.ok.storage_limit_in_megabytes;
+ cr->annual_fee = acfg->details.ok.annual_fee;
+ cr->truth_upload_fee = acfg->details.ok.truth_upload_fee;
+ cr->liability_limit = acfg->details.ok.liability_limit;
+ cr->provider_salt = acfg->details.ok.provider_salt;
}
}
notify_waiting (cr);
+ if (MHD_HTTP_OK != acfg->http_status)
+ {
+ cr->backoff = GNUNET_TIME_STD_BACKOFF (cr->backoff);
+ GNUNET_assert (NULL == cr->tt);
+ GNUNET_assert (NULL != cr->url);
+ cr->tt = GNUNET_SCHEDULER_add_delayed (cr->backoff,
+ &retry_config,
+ cr);
+ }
}
@@ -627,22 +682,57 @@ config_request_timeout (void *cls)
struct ConfigRequest *cr = cls;
cr->tt = NULL;
- ANASTASIS_config_cancel (cr->co);
- cr->co = NULL;
+ if (NULL != cr->co)
+ {
+ ANASTASIS_config_cancel (cr->co);
+ cr->co = NULL;
+ }
cr->http_status = 0;
cr->ec = TALER_EC_GENERIC_TIMEOUT;
notify_waiting (cr);
+ cr->backoff = GNUNET_TIME_STD_BACKOFF (cr->backoff);
+ GNUNET_assert (NULL == cr->tt);
+ GNUNET_assert (NULL != cr->url);
+ cr->tt = GNUNET_SCHEDULER_add_delayed (cr->backoff,
+ &retry_config,
+ cr);
+}
+
+
+static void
+retry_config (void *cls)
+{
+ struct ConfigRequest *cr = cls;
+
+ cr->tt = NULL;
+ if (NULL != cr->co)
+ {
+ ANASTASIS_config_cancel (cr->co);
+ cr->co = NULL;
+ }
+ cr->timeout_at = GNUNET_TIME_relative_to_absolute (CONFIG_GENERIC_TIMEOUT);
+ GNUNET_assert (NULL == cr->tt);
+ cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at,
+ &config_request_timeout,
+ cr);
+ cr->co = ANASTASIS_get_config (ANASTASIS_REDUX_ctx_,
+ cr->url,
+ &config_cb,
+ cr);
+ GNUNET_break (NULL != cr->co);
}
/**
* Schedule job to obtain Anastasis provider configuration at @a url.
*
+ * @param timeout how long to wait for a reply
* @param url base URL of Anastasis provider
* @return check config handle
*/
static struct ConfigRequest *
-check_config (const char *url)
+check_config (struct GNUNET_TIME_Relative timeout,
+ const char *url)
{
struct ConfigRequest *cr;
@@ -652,17 +742,47 @@ check_config (const char *url)
cr->url))
continue;
if (NULL != cr->co)
+ {
+ struct GNUNET_TIME_Relative duration;
+ struct GNUNET_TIME_Relative left;
+ struct GNUNET_TIME_Relative xleft;
+
+ duration = GNUNET_TIME_absolute_get_duration (cr->start_time);
+ left = GNUNET_TIME_relative_subtract (timeout,
+ duration);
+ xleft = GNUNET_TIME_absolute_get_remaining (cr->timeout_at);
+ if (GNUNET_TIME_relative_cmp (left,
+ <,
+ xleft))
+ {
+ /* new timeout is shorter! */
+ cr->timeout_at = GNUNET_TIME_relative_to_absolute (left);
+ GNUNET_SCHEDULER_cancel (cr->tt);
+ cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at,
+ &config_request_timeout,
+ cr);
+ }
return cr; /* already on it */
+ }
break;
}
if (NULL == cr)
{
cr = GNUNET_new (struct ConfigRequest);
+ cr->start_time = GNUNET_TIME_absolute_get ();
cr->url = GNUNET_strdup (url);
GNUNET_CONTAINER_DLL_insert (cr_head,
cr_tail,
cr);
}
+ if (MHD_HTTP_OK == cr->http_status)
+ return cr;
+ cr->timeout_at = GNUNET_TIME_relative_to_absolute (timeout);
+ if (NULL != cr->tt)
+ GNUNET_SCHEDULER_cancel (cr->tt);
+ cr->tt = GNUNET_SCHEDULER_add_at (cr->timeout_at,
+ &config_request_timeout,
+ cr);
cr->co = ANASTASIS_get_config (ANASTASIS_REDUX_ctx_,
cr->url,
&config_cb,
@@ -672,12 +792,6 @@ check_config (const char *url)
GNUNET_break (0);
return NULL;
}
- else
- {
- cr->tt = GNUNET_SCHEDULER_add_delayed (CONFIG_GENERIC_TIMEOUT,
- &config_request_timeout,
- cr);
- }
return cr;
}
@@ -685,12 +799,12 @@ check_config (const char *url)
/**
* Begin asynchronous check for provider configurations.
*
- * @param currencies the currencies to initiate the provider checks for
+ * @param cc country code that was selected
* @param[in,out] state to set provider list for
* @return #TALER_EC_NONE on success
*/
static enum TALER_ErrorCode
-begin_provider_config_check (const json_t *currencies,
+begin_provider_config_check (const char *cc,
json_t *state)
{
if (NULL == provider_list)
@@ -738,14 +852,17 @@ begin_provider_config_check (const json_t *currencies,
json_array_foreach (provider_arr, index, provider)
{
const char *url;
- const char *cur;
+ const char *restricted = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("url",
&url),
- GNUNET_JSON_spec_string ("currency",
- &cur),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("restricted",
+ &restricted),
+ NULL),
GNUNET_JSON_spec_end ()
};
+ json_t *prov;
if (GNUNET_OK !=
GNUNET_JSON_parse (provider,
@@ -756,33 +873,35 @@ begin_provider_config_check (const json_t *currencies,
json_decref (pl);
return TALER_EC_ANASTASIS_REDUCER_RESOURCE_MALFORMED;
}
-
+ if ( (NULL != restricted) &&
+ (0 != strcmp (restricted,
+ cc)) )
{
- bool found = false;
- json_t *cu;
- size_t off;
-
- json_array_foreach (currencies, off, cu)
- {
- const char *currency;
-
- currency = json_string_value (cu);
- if (NULL == currency)
- {
- json_decref (pl);
- return TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID;
- }
- found = (0 == strcasecmp (currency,
- cur));
- }
- if (! found)
- continue;
+ /* skip */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Skipping provider restricted to country `%s'\n",
+ restricted);
+ continue;
}
+ if ( (NULL == restricted) &&
+ (0 == strcmp (cc,
+ "xx")) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Running in demo mode, skipping unrestricted providers\n");
+ /* demo mode, skipping regular providers */
+ continue;
+ }
+ prov = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("status",
+ "not-contacted"));
+ GNUNET_assert (NULL != prov);
GNUNET_assert (0 ==
json_object_set_new (pl,
url,
- json_object ()));
- check_config (url);
+ prov));
+ check_config (CONFIG_GENERIC_TIMEOUT,
+ url);
}
GNUNET_assert (0 ==
json_object_set_new (state,
@@ -1010,7 +1129,6 @@ select_country (json_t *state,
{
const json_t *required_attrs;
const json_t *country_code;
- const json_t *currencies;
const json_t *redux_id_attr;
if (NULL == arguments)
@@ -1060,23 +1178,11 @@ select_country (json_t *state,
}
}
- currencies = json_object_get (arguments,
- "currencies");
- if ( (NULL == currencies) ||
- (! json_is_array (currencies)) )
- {
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_STATE_INVALID,
- "'currencies' missing");
- return NULL;
- }
- /* We now have an idea of the currency, begin fetching
- provider /configs (we likely need them later) */
+ /* Begin fetching provider /configs (we likely need them later) */
{
enum TALER_ErrorCode ec;
- ec = begin_provider_config_check (currencies,
+ ec = begin_provider_config_check (json_string_value (country_code),
state);
if (TALER_EC_NONE != ec)
{
@@ -1116,10 +1222,6 @@ select_country (json_t *state,
(json_t *) country_code));
GNUNET_assert (0 ==
json_object_set (state,
- "currencies",
- (json_t *) currencies));
- GNUNET_assert (0 ==
- json_object_set (state,
"required_attributes",
(json_t *) required_attrs));
cb (cb_cls,
@@ -1163,7 +1265,8 @@ ANASTASIS_REDUX_add_provider_to_state_ (const char *url,
struct ConfigRequest *cr;
struct ConfigReduxWaiting *w;
- cr = check_config (url);
+ cr = check_config (CONFIG_FAST_TIMEOUT,
+ url);
w = GNUNET_new (struct ConfigReduxWaiting);
w->cr = cr;
w->state = json_incref (state);
@@ -1176,8 +1279,10 @@ ANASTASIS_REDUX_add_provider_to_state_ (const char *url,
w);
if (NULL == cr->co)
{
- notify_waiting (cr);
- return NULL;
+ if (NULL != cr->tt)
+ GNUNET_SCHEDULER_cancel (cr->tt);
+ cr->tt = GNUNET_SCHEDULER_add_now (&notify_waiting_cb,
+ cr);
}
return &w->ra;
}
@@ -1248,19 +1353,22 @@ enter_user_attributes (json_t *state,
const char *attribute_value;
const char *regexp = NULL;
const char *reglog = NULL;
- int optional = false;
+ bool optional = false;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("name",
&name),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("validation-regex",
- &regexp)),
+ &regexp),
+ NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_string ("validation-logic",
- &reglog)),
+ &reglog),
+ NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_boolean ("optional",
- &optional)),
+ GNUNET_JSON_spec_bool ("optional",
+ &optional),
+ NULL),
GNUNET_JSON_spec_end ()
};
@@ -1619,9 +1727,14 @@ external_reducer_read_cb (void *cls)
return;
}
- red_cls->action_cb (red_cls->action_cb_cls,
- TALER_EC_NONE,
- json);
+ {
+ enum TALER_ErrorCode ec;
+ ec = json_integer_value (json_object_get (json, "code"));
+
+ red_cls->action_cb (red_cls->action_cb_cls,
+ ec,
+ json);
+ }
cleanup_external_reducer (red_cls);
return;
}
@@ -1994,3 +2107,68 @@ ANASTASIS_REDUX_load_continents_ ()
GNUNET_JSON_pack_array_steal ("continents",
continents));
}
+
+
+/**
+ * Lookup @a provider_salt of @a provider_url in @a state.
+ *
+ * @param state the state to inspect
+ * @param provider_url provider to look into
+ * @param[out] provider_salt value to extract
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+ANASTASIS_reducer_lookup_salt (
+ const json_t *state,
+ const char *provider_url,
+ struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt)
+{
+ const json_t *aps;
+ const json_t *cfg;
+ uint32_t http_status = 0;
+ const char *status;
+ bool no_salt;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("status",
+ &status),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_uint32 ("http_status",
+ &http_status),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto ("provider_salt",
+ provider_salt),
+ &no_salt),
+ GNUNET_JSON_spec_end ()
+ };
+
+ aps = json_object_get (state,
+ "authentication_providers");
+ if (NULL == aps)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ cfg = json_object_get (aps,
+ provider_url);
+ if (NULL == cfg)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (cfg,
+ spec,
+ NULL, NULL))
+ {
+ /* provider not working */
+ GNUNET_break_op (0);
+ return GNUNET_NO;
+ }
+ if (0 == strcmp (status,
+ "disabled"))
+ return GNUNET_NO;
+ if (no_salt)
+ return GNUNET_NO;
+ return GNUNET_OK;
+}
diff --git a/src/reducer/anastasis_api_redux.h b/src/reducer/anastasis_api_redux.h
index 408c63c..03eef33 100644
--- a/src/reducer/anastasis_api_redux.h
+++ b/src/reducer/anastasis_api_redux.h
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -108,6 +108,42 @@ ANASTASIS_REDUX_load_continents_ (void);
/**
+ * Try to obtain configuration information on all configured
+ * providers. Upon success, call @a cb with the updated provider
+ * status data.
+ *
+ * @param[in] state we are in
+ * @param arguments our arguments with the solution
+ * @param cb functiont o call with the new state
+ * @param cb_cls closure for @a cb
+ * @return handle to cancel challenge selection step
+ */
+struct ANASTASIS_ReduxAction *
+ANASTASIS_REDUX_poll_providers_ (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Check if we have information on all providers involved in
+ * a recovery procedure, and if not, try to obtain it. Upon
+ * success, call @a cb with the updated provider status data.
+ *
+ * @param[in] state we are in
+ * @param arguments our arguments with the solution
+ * @param cb functiont o call with the new state
+ * @param cb_cls closure for @a cb
+ * @return handle to cancel challenge selection step
+ */
+struct ANASTASIS_ReduxAction *
+ANASTASIS_REDUX_sync_providers_ (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls);
+
+
+/**
* Returns the enum value to a string value of a state.
*
* @param state_string string to convert
@@ -168,6 +204,20 @@ ANASTASIS_recovery_state_to_string_ (enum ANASTASIS_RecoveryState rs);
/**
+ * Lookup @a salt of @a provider_url in @a state.
+ *
+ * @param state the state to inspect
+ * @param provider_url provider to look into
+ * @param[out] salt value to extract
+ * @return #GNUNET_OK on success
+ */
+enum GNUNET_GenericReturnValue
+ANASTASIS_reducer_lookup_salt (const json_t *state,
+ const char *provider_url,
+ struct ANASTASIS_CRYPTO_ProviderSaltP *salt);
+
+
+/**
* Function to return a json error response.
*
* @param cb callback to give error to
diff --git a/src/reducer/validation_CH_AHV.c b/src/reducer/validation_CH_AHV.c
index 6beded1..4ea973c 100644
--- a/src/reducer/validation_CH_AHV.c
+++ b/src/reducer/validation_CH_AHV.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_CZ_BN.c b/src/reducer/validation_CZ_BN.c
index 85dea4a..b570841 100644
--- a/src/reducer/validation_CZ_BN.c
+++ b/src/reducer/validation_CZ_BN.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_DE_SVN.c b/src/reducer/validation_DE_SVN.c
index 7096708..e753f0c 100644
--- a/src/reducer/validation_DE_SVN.c
+++ b/src/reducer/validation_DE_SVN.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_DE_TIN.c b/src/reducer/validation_DE_TIN.c
index 0412f87..5678579 100644
--- a/src/reducer/validation_DE_TIN.c
+++ b/src/reducer/validation_DE_TIN.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_ES_DNI.c b/src/reducer/validation_ES_DNI.c
index 6679f45..5fb3885 100644
--- a/src/reducer/validation_ES_DNI.c
+++ b/src/reducer/validation_ES_DNI.c
@@ -3,14 +3,14 @@
Copyright (C) 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_FR_INSEE.c b/src/reducer/validation_FR_INSEE.c
new file mode 100644
index 0000000..19d81fd
--- /dev/null
+++ b/src/reducer/validation_FR_INSEE.c
@@ -0,0 +1,66 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file reducer/validation_FR_INSEE.c
+ * @brief Validation for French INSEE Numbers
+ * @author Christian Grothoff
+ */
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+
+/**
+ * Function to validate a French INSEE number.
+ *
+ * See https://en.wikipedia.org/wiki/INSEE_code
+ *
+ * Note that we do not implement checks on the month
+ * and also allow non-binary prefixes.
+ *
+ * @param insee_number social security number to validate (input)
+ * @return true if validation passed, else false
+ */
+bool
+FR_INSEE_check (const char *insee_number)
+{
+ char pfx[14];
+ unsigned long long num;
+ unsigned int cc;
+ char dum;
+
+ if (strlen (insee_number) != 15)
+ return false;
+ memcpy (pfx,
+ insee_number,
+ 13);
+ pfx[13] = '\0';
+ if (1 !=
+ sscanf (pfx,
+ "%llu%c",
+ &num,
+ &dum))
+ return false;
+ if (1 !=
+ sscanf (&insee_number[13],
+ "%u%c",
+ &cc,
+ &dum))
+ return false;
+ if (97 - cc != num % 97)
+ return false;
+ return true;
+}
diff --git a/src/reducer/validation_IN_AADHAR.c b/src/reducer/validation_IN_AADHAR.c
index 4c4901a..d53b655 100644
--- a/src/reducer/validation_IN_AADHAR.c
+++ b/src/reducer/validation_IN_AADHAR.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_IT_CF.c b/src/reducer/validation_IT_CF.c
index ca66a11..6e9c6c6 100644
--- a/src/reducer/validation_IT_CF.c
+++ b/src/reducer/validation_IT_CF.c
@@ -3,14 +3,14 @@
Copyright (C) 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_NL_BSN.c b/src/reducer/validation_NL_BSN.c
new file mode 100644
index 0000000..f92bb38
--- /dev/null
+++ b/src/reducer/validation_NL_BSN.c
@@ -0,0 +1,57 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020, 2021 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file reducer/validation_NL_BSN.c
+ * @brief Validation for Dutch Buergerservicenummern
+ * @author Christian Grothoff
+ */
+#include <string.h>
+#include <stdbool.h>
+
+
+/**
+ * Function to validate a Dutch Social Security number.
+ *
+ * See https://nl.wikipedia.org/wiki/Burgerservicenummer
+ *
+ * @param bsn_number social security number to validate (input)
+ * @return true if validation passed, else false
+ */
+bool
+NL_BSN_check (const char *bsn_number)
+{
+ static const int factors[] = {
+ 9, 8, 7, 6, 5, 4, 3, 2, -1
+ };
+ unsigned int sum = 0;
+
+ if (strlen (bsn_number) != 9)
+ return false;
+ for (unsigned int i = 0; i<8; i++)
+ {
+ unsigned char c = (unsigned char) bsn_number[i];
+
+ if ( ('0' > c) || ('9' < c) )
+ return false;
+ sum += (c - '0') * factors[i];
+ }
+ {
+ unsigned char c = (unsigned char) bsn_number[8];
+ unsigned int v = (c - '0');
+
+ return (sum % 11 == v);
+ }
+}
diff --git a/src/reducer/validation_XX_SQUARE.c b/src/reducer/validation_XX_SQUARE.c
index 88cf890..1f43400 100644
--- a/src/reducer/validation_XX_SQUARE.c
+++ b/src/reducer/validation_XX_SQUARE.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/reducer/validation_XY_PRIME.c b/src/reducer/validation_XY_PRIME.c
index 32bdce0..56aa724 100644
--- a/src/reducer/validation_XY_PRIME.c
+++ b/src/reducer/validation_XY_PRIME.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
diff --git a/src/restclient/Makefile.am b/src/restclient/Makefile.am
index 075d3a7..1a4d83c 100644
--- a/src/restclient/Makefile.am
+++ b/src/restclient/Makefile.am
@@ -17,9 +17,11 @@ libanastasisrest_la_LDFLAGS = \
libanastasisrest_la_SOURCES = \
anastasis_api_config.c \
anastasis_api_policy_store.c \
- anastasis_api_truth_store.c \
anastasis_api_policy_lookup.c \
- anastasis_api_keyshare_lookup.c \
+ anastasis_api_policy_meta_lookup.c \
+ anastasis_api_truth_challenge.c \
+ anastasis_api_truth_solve.c \
+ anastasis_api_truth_store.c \
anastasis_api_curl_defaults.c anastasis_api_curl_defaults.h
libanastasisrest_la_LIBADD = \
-lgnunetcurl \
@@ -27,9 +29,10 @@ libanastasisrest_la_LIBADD = \
-lgnunetutil \
-ljansson \
-ltalerjson \
- -ltalerutil \
+ -ltalercurl \
-ltalermerchant \
-ltalerjson \
+ -ltalerutil \
$(XLIB)
if HAVE_LIBCURL
@@ -39,4 +42,3 @@ if HAVE_LIBGNURL
libanastasisrest_la_LIBADD += -lgnurl
endif
endif
-
diff --git a/src/restclient/anastasis_api_config.c b/src/restclient/anastasis_api_config.c
index acb0967..fff4774 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -86,6 +86,10 @@ handle_config_finished (void *cls,
{
struct ANASTASIS_ConfigOperation *co = cls;
const json_t *json = response;
+ struct ANASTASIS_Config acfg = {
+ .http_status = response_code,
+ .response = json
+ };
co->job = NULL;
switch (response_code)
@@ -99,29 +103,29 @@ handle_config_finished (void *cls,
case MHD_HTTP_OK:
{
const char *name;
- struct ANASTASIS_Config acfg;
- json_t *methods;
+ const json_t *methods;
+ struct TALER_JSON_ProtocolVersion pv;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("name",
&name),
GNUNET_JSON_spec_string ("business_name",
- &acfg.business_name),
+ &acfg.details.ok.business_name),
GNUNET_JSON_spec_string ("version",
- &acfg.version),
- GNUNET_JSON_spec_string ("currency",
- &acfg.currency),
- GNUNET_JSON_spec_json ("methods",
- &methods),
+ &acfg.details.ok.version),
+ TALER_JSON_spec_version ("version",
+ &pv),
+ GNUNET_JSON_spec_array_const ("methods",
+ &methods),
GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
- &acfg.storage_limit_in_megabytes),
+ &acfg.details.ok.storage_limit_in_megabytes),
TALER_JSON_spec_amount_any ("annual_fee",
- &acfg.annual_fee),
+ &acfg.details.ok.annual_fee),
TALER_JSON_spec_amount_any ("truth_upload_fee",
- &acfg.truth_upload_fee),
+ &acfg.details.ok.truth_upload_fee),
TALER_JSON_spec_amount_any ("liability_limit",
- &acfg.liability_limit),
- GNUNET_JSON_spec_fixed_auto ("server_salt",
- &acfg.salt),
+ &acfg.details.ok.liability_limit),
+ GNUNET_JSON_spec_fixed_auto ("provider_salt",
+ &acfg.details.ok.provider_salt),
GNUNET_JSON_spec_end ()
};
@@ -131,80 +135,47 @@ handle_config_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
- response_code = 0;
+ json_dumpf (json,
+ stderr,
+ JSON_INDENT (2));
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;
}
if (0 != strcmp (name,
"anastasis"))
{
GNUNET_JSON_parse_free (spec);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;
}
+ if ( (ANASTASIS_PROTOCOL_CURRENT < pv.current) &&
+ (ANASTASIS_PROTOCOL_CURRENT < pv.current - pv.age) )
{
- unsigned int age;
- unsigned int revision;
- unsigned int current;
- char dummy;
-
- if (3 != sscanf (acfg.version,
- "%u:%u:%u%c",
- &current,
- &revision,
- &age,
- &dummy))
- {
- GNUNET_break_op (0);
- response_code = 0;
- GNUNET_JSON_parse_free (spec);
- break;
- }
- if ( (ANASTASIS_PROTOCOL_CURRENT < current) &&
- (ANASTASIS_PROTOCOL_CURRENT < current - age) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Provider protocol version too new\n");
- response_code = 0;
- GNUNET_JSON_parse_free (spec);
- break;
- }
- if ( (ANASTASIS_PROTOCOL_CURRENT > current) &&
- (ANASTASIS_PROTOCOL_CURRENT - ANASTASIS_PROTOCOL_AGE > current) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Provider protocol version too old\n");
- GNUNET_break_op (0);
- response_code = 0;
- GNUNET_JSON_parse_free (spec);
- break;
- }
- }
- if ( (GNUNET_OK !=
- TALER_amount_cmp_currency (&acfg.liability_limit,
- &acfg.annual_fee)) ||
- (0 !=
- strcasecmp (acfg.currency,
- acfg.annual_fee.currency)) )
- {
- GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- response_code = 0;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Provider protocol version too new\n");
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
break;
}
-
- if (! json_is_array (methods))
+ if ( (ANASTASIS_PROTOCOL_CURRENT > pv.current) &&
+ (ANASTASIS_PROTOCOL_CURRENT - ANASTASIS_PROTOCOL_AGE > pv.current) )
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Provider protocol version too old\n");
GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_VERSION_MALFORMED;
break;
}
- acfg.methods_length = json_array_size (methods);
+ acfg.details.ok.methods_length = json_array_size (methods);
{
struct ANASTASIS_AuthorizationMethodConfig mcfg[GNUNET_NZL (
- acfg.methods_length)];
+ acfg.details.ok.
+ methods_length)];
- for (unsigned int i = 0; i<acfg.methods_length; i++)
+ for (unsigned int i = 0; i<acfg.details.ok.methods_length; i++)
{
struct ANASTASIS_AuthorizationMethodConfig *m = &mcfg[i];
struct GNUNET_JSON_Specification spec[] = {
@@ -222,16 +193,17 @@ handle_config_finished (void *cls,
NULL, NULL)) )
{
GNUNET_break_op (0);
- GNUNET_JSON_parse_free (spec);
- response_code = 0;
+ acfg.http_status = 0;
+ acfg.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
goto end;
}
}
- acfg.methods = mcfg;
+ acfg.details.ok.methods = mcfg;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Good backend found at `%s'\n",
+ co->url);
co->cb (co->cb_cls,
- MHD_HTTP_OK,
&acfg);
- GNUNET_JSON_parse_free (spec);
ANASTASIS_config_cancel (co);
return;
}
@@ -257,8 +229,7 @@ handle_config_finished (void *cls,
}
end:
co->cb (co->cb_cls,
- response_code,
- NULL);
+ &acfg);
ANASTASIS_config_cancel (co);
}
diff --git a/src/restclient/anastasis_api_curl_defaults.c b/src/restclient/anastasis_api_curl_defaults.c
index b777bae..f64347b 100644
--- a/src/restclient/anastasis_api_curl_defaults.c
+++ b/src/restclient/anastasis_api_curl_defaults.c
@@ -3,14 +3,14 @@
Copyright (C) 2014-2019 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
@@ -20,6 +20,7 @@
* @author Florian Dold
*/
#include "platform.h"
+#include <taler/taler_curl_lib.h>
#include "anastasis_api_curl_defaults.h"
CURL *
@@ -34,13 +35,17 @@ ANASTASIS_curl_easy_get_ (const char *url)
curl_easy_setopt (eh,
CURLOPT_URL,
url));
- GNUNET_assert (CURLE_OK ==
- curl_easy_setopt (eh,
- CURLOPT_FOLLOWLOCATION,
- 1L));
+ TALER_curl_set_secure_redirect_policy (eh,
+ url);
GNUNET_assert (CURLE_OK ==
curl_easy_setopt (eh,
CURLOPT_TCP_FASTOPEN,
1L));
+ /* Enable compression (using whatever curl likes), see
+ https://curl.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html */
+ GNUNET_break (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_ACCEPT_ENCODING,
+ ""));
return eh;
}
diff --git a/src/restclient/anastasis_api_curl_defaults.h b/src/restclient/anastasis_api_curl_defaults.h
index 4d990af..948b931 100644
--- a/src/restclient/anastasis_api_curl_defaults.h
+++ b/src/restclient/anastasis_api_curl_defaults.h
@@ -3,14 +3,14 @@
Copyright (C) 2014-2019 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
diff --git a/src/restclient/anastasis_api_keyshare_lookup.c b/src/restclient/anastasis_api_keyshare_lookup.c
index e681d5a..4840a7e 100644
--- a/src/restclient/anastasis_api_keyshare_lookup.c
+++ b/src/restclient/anastasis_api_keyshare_lookup.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -228,7 +228,6 @@ handle_keyshare_lookup_finished (void *cls,
kdd.status = ANASTASIS_KSD_REDIRECT_FOR_AUTHENTICATION;
kdd.details.redirect_url = kslo->location;
break;
- case MHD_HTTP_ALREADY_REPORTED:
case MHD_HTTP_FORBIDDEN:
/* Nothing really to verify, authentication required/failed */
kdd.status = ANASTASIS_KSD_INVALID_ANSWER;
@@ -245,19 +244,57 @@ handle_keyshare_lookup_finished (void *cls,
/* Nothing really to verify */
kdd.status = ANASTASIS_KSD_AUTHENTICATION_TIMEOUT;
break;
- case MHD_HTTP_GONE:
- /* Nothing really to verify */
- kdd.status = ANASTASIS_KSD_TRUTH_UNKNOWN;
- break;
- case MHD_HTTP_EXPECTATION_FAILED:
+ case MHD_HTTP_CONFLICT:
/* Nothing really to verify */
kdd.status = ANASTASIS_KSD_CLIENT_FAILURE;
- kdd.details.server_failure.http_status = MHD_HTTP_EXPECTATION_FAILED;
+ kdd.details.server_failure.http_status = MHD_HTTP_CONFLICT;
kdd.details.server_failure.ec = TALER_JSON_get_error_code2 (data,
data_size);
break;
+ case MHD_HTTP_GONE:
+ /* Nothing really to verify */
+ kdd.status = ANASTASIS_KSD_TRUTH_UNKNOWN;
+ break;
case MHD_HTTP_TOO_MANY_REQUESTS:
kdd.status = ANASTASIS_KSD_RATE_LIMIT_EXCEEDED;
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_uint32 (
+ "request_limit",
+ &kdd.details.rate_limit_exceeded.request_limit),
+ GNUNET_JSON_spec_relative_time (
+ "request_frequency",
+ &kdd.details.rate_limit_exceeded.request_frequency),
+ GNUNET_JSON_spec_end ()
+ };
+ json_t *reply;
+
+ reply = json_loadb (data,
+ data_size,
+ JSON_REJECT_DUPLICATES,
+ NULL);
+ if (NULL == reply)
+ {
+ GNUNET_break_op (0);
+ kdd.status = ANASTASIS_KSD_SERVER_ERROR;
+ kdd.details.server_failure.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ kdd.details.server_failure.http_status = response_code;
+ break;
+ }
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (reply,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ kdd.status = ANASTASIS_KSD_SERVER_ERROR;
+ kdd.details.server_failure.ec = TALER_JSON_get_error_code (reply);
+ kdd.details.server_failure.http_status = response_code;
+ json_decref (reply);
+ break;
+ }
+ json_decref (reply);
+ }
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
@@ -487,8 +524,8 @@ ANASTASIS_keyshare_lookup (
answer_s,
"timeout_ms",
(0 != timeout.rel_value_us)
- ? timeout_ms
- : NULL,
+ ? timeout_ms
+ : NULL,
NULL);
GNUNET_free (answer_s);
}
@@ -500,8 +537,8 @@ ANASTASIS_keyshare_lookup (
path,
"timeout_ms",
(0 != timeout.rel_value_us)
- ? timeout_ms
- : NULL,
+ ? timeout_ms
+ : NULL,
NULL);
}
}
diff --git a/src/restclient/anastasis_api_policy_lookup.c b/src/restclient/anastasis_api_policy_lookup.c
index e21ed58..b3132ef 100644
--- a/src/restclient/anastasis_api_policy_lookup.c
+++ b/src/restclient/anastasis_api_policy_lookup.c
@@ -3,16 +3,16 @@
Copyright (C) 2014-2019 Anastasis SARL
ANASTASIS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
+ it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2.1,
or (at your option) any later version.
ANASTASIS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
+ You should have received a copy of the GNU General Public
License along with ANASTASIS; see the file COPYING.LGPL. If not,
see <http://www.gnu.org/licenses/>
*/
@@ -106,6 +106,9 @@ handle_policy_lookup_finished (void *cls,
size_t data_size)
{
struct ANASTASIS_PolicyLookupOperation *plo = cls;
+ struct ANASTASIS_DownloadDetails dd = {
+ .http_status = response_code
+ };
plo->job = NULL;
switch (response_code)
@@ -117,7 +120,6 @@ handle_policy_lookup_finished (void *cls,
break;
case MHD_HTTP_OK:
{
- struct ANASTASIS_DownloadDetails dd;
struct ANASTASIS_UploadSignaturePS usp = {
.purpose.purpose = htonl (TALER_SIGNATURE_ANASTASIS_POLICY_UPLOAD),
.purpose.size = htonl (sizeof (usp)),
@@ -133,18 +135,17 @@ handle_policy_lookup_finished (void *cls,
&plo->account_pub.pub))
{
GNUNET_break_op (0);
- response_code = 0;
+ dd.http_status = 0;
+ dd.ec = -1; // FIXME: needs new code in Gana!
break;
}
/* Success, call callback with all details! */
- memset (&dd, 0, sizeof (dd));
- dd.sig = plo->account_sig;
- dd.curr_policy_hash = usp.new_recovery_data_hash;
- dd.policy = data;
- dd.policy_size = data_size;
- dd.version = plo->version;
+ dd.details.ok.sig = plo->account_sig;
+ dd.details.ok.curr_policy_hash = usp.new_recovery_data_hash;
+ dd.details.ok.policy = data;
+ dd.details.ok.policy_size = data_size;
+ dd.details.ok.version = plo->version;
plo->cb (plo->cb_cls,
- response_code,
&dd);
plo->cb = NULL;
ANASTASIS_policy_lookup_cancel (plo);
@@ -167,12 +168,10 @@ handle_policy_lookup_finished (void *cls,
"Unexpected response code %u\n",
(unsigned int) response_code);
GNUNET_break (0);
- response_code = 0;
break;
}
plo->cb (plo->cb_cls,
- response_code,
- NULL);
+ &dd);
plo->cb = NULL;
ANASTASIS_policy_lookup_cancel (plo);
}
diff --git a/src/restclient/anastasis_api_policy_meta_lookup.c b/src/restclient/anastasis_api_policy_meta_lookup.c
new file mode 100644
index 0000000..cf381fd
--- /dev/null
+++ b/src/restclient/anastasis_api_policy_meta_lookup.c
@@ -0,0 +1,272 @@
+/*
+ This file is part of ANASTASIS
+ Copyright (C) 2022 Anastasis SARL
+
+ ANASTASIS 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 Foundation; either version 2.1,
+ or (at your option) any later version.
+
+ ANASTASIS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with ANASTASIS; see the file COPYING.LGPL. If not,
+ see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file restclient/anastasis_api_policy_meta_lookup.c
+ * @brief Implementation of the /policy/$POL/meta GET request
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <curl/curl.h>
+#include <jansson.h>
+#include <microhttpd.h> /* just for HTTP status codes */
+#include "anastasis_service.h"
+#include "anastasis_api_curl_defaults.h"
+#include <gnunet/gnunet_json_lib.h>
+#include <taler/taler_signatures.h>
+
+
+/**
+ * @brief A Meta Operation Handle
+ */
+struct ANASTASIS_PolicyMetaLookupOperation
+{
+
+ /**
+ * The url for this request, including parameters.
+ */
+ char *url;
+
+ /**
+ * Handle for the request.
+ */
+ struct GNUNET_CURL_Job *job;
+
+ /**
+ * Function to call with the result.
+ */
+ ANASTASIS_PolicyMetaLookupCallback cb;
+
+ /**
+ * Closure for @a cb.
+ */
+ void *cb_cls;
+
+ /**
+ * Reference to the execution context.
+ */
+ struct GNUNET_CURL_Context *ctx;
+
+ /**
+ * Public key of the account we are downloading from.
+ */
+ struct ANASTASIS_CRYPTO_AccountPublicKeyP account_pub;
+
+ /**
+ * Maximum version to fetch.
+ */
+ uint32_t max_version;
+
+};
+
+
+/**
+ * Process GET /policy/$POL/meta response
+ *
+ * @param cls our `struct ANASTASIS_PolicyMetaLookupOperation *`
+ * @param response_code HTTP status
+ * @param data response body, a `json_t *`, NULL on error
+ */
+static void
+handle_policy_meta_lookup_finished (void *cls,
+ long response_code,
+ const void *response)
+{
+ struct ANASTASIS_PolicyMetaLookupOperation *plo = cls;
+ const json_t *json = response;
+ struct ANASTASIS_MetaDownloadDetails mdd = {
+ .http_status = response_code,
+ .response = json
+ };
+
+ plo->job = NULL;
+ switch (response_code)
+ {
+ case 0:
+ /* Hard error */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Backend didn't even return from GET /policy\n");
+ break;
+ case MHD_HTTP_OK:
+ {
+ size_t mlen = json_object_size (json);
+
+ /* put a cap, as we will stack-allocate below and the
+ current service LIMITs the result to 1000 anyway;
+ could theoretically be increased in the future, but
+ then we should not put this onto the stack anymore... */
+ if (mlen > 10000)
+ {
+ GNUNET_break (0);
+ response_code = 0;
+ break;
+ }
+ {
+ struct ANASTASIS_MetaDataEntry metas[GNUNET_NZL (mlen)];
+ void *md[GNUNET_NZL (mlen)];
+ size_t off = 0;
+ const char *label;
+ const json_t *val;
+
+ memset (md,
+ 0,
+ sizeof (md));
+ mdd.details.ok.metas = metas;
+ mdd.details.ok.metas_length = mlen;
+ json_object_foreach ((json_t *) json,
+ label,
+ val)
+ {
+ unsigned int ver;
+ char dummy;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_varsize ("meta",
+ &md[off],
+ &metas[off].meta_data_size),
+ GNUNET_JSON_spec_timestamp ("upload_time",
+ &metas[off].server_time),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (1 != sscanf (label,
+ "%u%c",
+ &ver,
+ &dummy))
+ {
+ GNUNET_break (0);
+ mdd.http_status = 0;
+ mdd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (val,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ mdd.http_status = 0;
+ mdd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ metas[off].version = (uint32_t) ver;
+ metas[off].meta_data = md[off];
+ off++;
+ }
+ if (off < mlen)
+ {
+ GNUNET_break (0);
+ mdd.http_status = 0;
+ mdd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ for (size_t i = 0; i<off; i++)
+ GNUNET_free (md[i]);
+ break;
+ }
+ plo->cb (plo->cb_cls,
+ &mdd);
+ for (size_t i = 0; i<off; i++)
+ GNUNET_free (md[i]);
+ plo->cb = NULL;
+ }
+ ANASTASIS_policy_meta_lookup_cancel (plo);
+ return;
+ }
+ case MHD_HTTP_BAD_REQUEST:
+ /* This should never happen, either us or the anastasis server is buggy
+ (or API version conflict); just pass JSON reply to the application */
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ /* Nothing really to verify */
+ break;
+ case MHD_HTTP_INTERNAL_SERVER_ERROR:
+ /* Server had an internal issue; we should retry, but this API
+ leaves this to the application */
+ break;
+ default:
+ /* unexpected response code */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u\n",
+ (unsigned int) response_code);
+ GNUNET_break (0);
+ break;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "HTTP status for policy meta lookup is %u\n",
+ (unsigned int) response_code);
+ plo->cb (plo->cb_cls,
+ &mdd);
+ plo->cb = NULL;
+ ANASTASIS_policy_meta_lookup_cancel (plo);
+}
+
+
+struct ANASTASIS_PolicyMetaLookupOperation *
+ANASTASIS_policy_meta_lookup (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
+ uint32_t max_version,
+ ANASTASIS_PolicyMetaLookupCallback cb,
+ void *cb_cls)
+{
+ struct ANASTASIS_PolicyMetaLookupOperation *plo;
+ CURL *eh;
+ char *path;
+
+ // FIXME: pass 'max_version' in CURL request!
+ GNUNET_assert (NULL != cb);
+ plo = GNUNET_new (struct ANASTASIS_PolicyMetaLookupOperation);
+ plo->account_pub = *anastasis_pub;
+ {
+ char *acc_pub_str;
+
+ acc_pub_str = GNUNET_STRINGS_data_to_string_alloc (anastasis_pub,
+ sizeof (*anastasis_pub));
+ GNUNET_asprintf (&path,
+ "policy/%s/meta",
+ acc_pub_str);
+ GNUNET_free (acc_pub_str);
+ }
+ plo->url = TALER_url_join (backend_url,
+ path,
+ NULL);
+ GNUNET_free (path);
+ eh = ANASTASIS_curl_easy_get_ (plo->url);
+ GNUNET_assert (NULL != eh);
+ plo->cb = cb;
+ plo->cb_cls = cb_cls;
+ plo->job = GNUNET_CURL_job_add (ctx,
+ eh,
+ &handle_policy_meta_lookup_finished,
+ plo);
+ return plo;
+}
+
+
+void
+ANASTASIS_policy_meta_lookup_cancel (
+ struct ANASTASIS_PolicyMetaLookupOperation *plo)
+{
+ if (NULL != plo->job)
+ {
+ GNUNET_CURL_job_cancel (plo->job);
+ plo->job = NULL;
+ }
+ GNUNET_free (plo->url);
+ GNUNET_free (plo);
+}
diff --git a/src/restclient/anastasis_api_policy_store.c b/src/restclient/anastasis_api_policy_store.c
index 0333a13..3afee7d 100644
--- a/src/restclient/anastasis_api_policy_store.c
+++ b/src/restclient/anastasis_api_policy_store.c
@@ -1,18 +1,18 @@
/*
This file is part of ANASTASIS
- Copyright (C) 2014-2021 Anastasis SARL
+ Copyright (C) 2014-2022 Anastasis SARL
ANASTASIS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
+ it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2.1,
or (at your option) any later version.
ANASTASIS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
+ You should have received a copy of the GNU General Public
License along with ANASTASIS; see the file COPYING.LGPL. If not,
see <http://www.gnu.org/licenses/>
*/
@@ -165,8 +165,7 @@ handle_policy_store_finished (void *cls,
ud.us = ANASTASIS_US_SUCCESS;
ud.details.success.curr_backup_hash = &pso->new_upload_hash;
ud.details.success.policy_expiration
- = GNUNET_TIME_absolute_add (
- GNUNET_TIME_UNIT_ZERO_ABS,
+ = GNUNET_TIME_relative_to_timestamp (
GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_SECONDS,
expiration));
@@ -212,6 +211,10 @@ handle_policy_store_finished (void *cls,
ud.us = ANASTASIS_US_PAYMENT_REQUIRED;
ud.details.payment.payment_request = pso->pay_uri;
break;
+ case MHD_HTTP_REQUEST_TIMEOUT:
+ ud.us = ANASTASIS_US_CLIENT_ERROR;
+ ud.ec = TALER_EC_ANASTASIS_PAYMENT_GENERIC_TIMEOUT;
+ break;
case MHD_HTTP_PAYLOAD_TOO_LARGE:
ud.us = ANASTASIS_US_CLIENT_ERROR;
ud.ec = TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT;
@@ -353,6 +356,8 @@ ANASTASIS_policy_store (
const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
const void *recovery_data,
size_t recovery_data_size,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size,
uint32_t payment_years_requested,
const struct ANASTASIS_PaymentSecretP *payment_secret,
struct GNUNET_TIME_Relative payment_timeout,
@@ -369,6 +374,11 @@ ANASTASIS_policy_store (
.purpose.size = htonl (sizeof (usp))
};
+ if (NULL == recovery_meta_data)
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
tms = (unsigned long long) (payment_timeout.rel_value_us
/ GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
GNUNET_CRYPTO_hash (recovery_data,
@@ -407,7 +417,7 @@ ANASTASIS_policy_store (
val = GNUNET_STRINGS_data_to_string_alloc (&usp.new_recovery_data_hash,
sizeof (struct GNUNET_HashCode));
GNUNET_asprintf (&hdr,
- "%s: %s",
+ "%s: \"%s\"",
MHD_HTTP_HEADER_IF_NONE_MATCH,
val);
GNUNET_free (val);
@@ -422,6 +432,30 @@ ANASTASIS_policy_store (
}
job_headers = ext;
+ /* Setup meta-data header */
+ {
+ char *meta_val;
+
+ meta_val = GNUNET_STRINGS_data_to_string_alloc (
+ recovery_meta_data,
+ recovery_meta_data_size);
+ GNUNET_asprintf (&hdr,
+ "%s: %s",
+ ANASTASIS_HTTP_HEADER_POLICY_META_DATA,
+ meta_val);
+ GNUNET_free (meta_val);
+ ext = curl_slist_append (job_headers,
+ hdr);
+ GNUNET_free (hdr);
+ if (NULL == ext)
+ {
+ GNUNET_break (0);
+ curl_slist_free_all (job_headers);
+ return NULL;
+ }
+ job_headers = ext;
+ }
+
/* Setup Payment-Identifier header */
if (NULL != payment_secret)
{
diff --git a/src/restclient/anastasis_api_truth_challenge.c b/src/restclient/anastasis_api_truth_challenge.c
new file mode 100644
index 0000000..7a39db5
--- /dev/null
+++ b/src/restclient/anastasis_api_truth_challenge.c
@@ -0,0 +1,456 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020, 2021, 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file restclient/anastasis_api_truth_challenge.c
+ * @brief Implementation of the POST /truth/$TID/challenge request on the client-side
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ */
+#include "platform.h"
+#include <curl/curl.h>
+#include <jansson.h>
+#include <microhttpd.h> /* just for HTTP status codes */
+#include "anastasis_service.h"
+#include "anastasis_api_curl_defaults.h"
+#include <taler/taler_curl_lib.h>
+#include <taler/taler_json_lib.h>
+#include <taler/taler_merchant_service.h>
+
+
+/**
+ * @brief A Contract Operation Handle
+ */
+struct ANASTASIS_TruthChallengeOperation
+{
+ /**
+ * The url for this request.
+ */
+ char *url;
+
+ /**
+ * Handle for the request.
+ */
+ struct GNUNET_CURL_Job *job;
+
+ /**
+ * Function to call with the result.
+ */
+ ANASTASIS_TruthChallengeCallback cb;
+
+ /**
+ * Closure for @a cb.
+ */
+ void *cb_cls;
+
+ /**
+ * Context for #TEH_curl_easy_post(). Keeps the data that must
+ * persist for Curl to make the upload.
+ */
+ struct TALER_CURL_PostContext ctx;
+
+ /**
+ * Payment URI we received from the service, or NULL.
+ */
+ char *pay_uri;
+
+ /**
+ * Content type of the body.
+ */
+ char *content_type;
+};
+
+
+void
+ANASTASIS_truth_challenge_cancel (
+ struct ANASTASIS_TruthChallengeOperation *tco)
+{
+ if (NULL != tco->job)
+ {
+ GNUNET_CURL_job_cancel (tco->job);
+ tco->job = NULL;
+ }
+ GNUNET_free (tco->pay_uri);
+ GNUNET_free (tco->url);
+ GNUNET_free (tco->content_type);
+ TALER_curl_easy_post_finished (&tco->ctx);
+ GNUNET_free (tco);
+}
+
+
+/**
+ * Process POST /truth/$TID/challenge response
+ *
+ * @param cls our `struct ANASTASIS_TruthChallengeOperation *`
+ * @param response_code the HTTP status
+ * @param response parsed JSON result, NULL one rrro
+ */
+static void
+handle_truth_challenge_finished (void *cls,
+ long response_code,
+ const void *response)
+{
+ struct ANASTASIS_TruthChallengeOperation *tco = cls;
+ const json_t *j = response;
+ struct ANASTASIS_TruthChallengeDetails tcd = {
+ .http_status = response_code,
+ .response = j
+ };
+
+ tco->job = NULL;
+ switch (response_code)
+ {
+ case 0:
+ /* Hard error */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Backend didn't even return from POST /truth/$TID/challenge\n");
+ tcd.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
+ case MHD_HTTP_OK:
+ {
+ const char *ct;
+ const char *tan_hint = NULL;
+ const char *filename = NULL;
+ const json_t *wire_details = NULL;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string (
+ "challenge_type",
+ &ct),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("tan_address_hint",
+ &tan_hint),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("filename",
+ &filename),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_object_const ("wire_details",
+ &wire_details),
+ NULL),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (j,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ tcd.http_status = 0;
+ tcd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ if (0 == strcmp (ct,
+ "TAN_SENT"))
+ {
+ tcd.details.success.cs = ANASTASIS_CS_TAN_SENT;
+ tcd.details.success.details.tan_address_hint = tan_hint;
+ break;
+ }
+ if (0 == strcmp (ct,
+ "TAN_ALREADY_SENT"))
+ {
+ tcd.details.success.cs = ANASTASIS_CS_TAN_ALREADY_SENT;
+ break;
+ }
+ if ( (0 == strcmp (ct,
+ "FILE_WRITTEN")) &&
+ (NULL != filename) )
+ {
+ tcd.details.success.cs = ANASTASIS_CS_FILE_WRITTEN;
+ tcd.details.success.details.challenge_filename = filename;
+ break;
+ }
+ if ( (0 == strcmp (ct,
+ "IBAN_WIRE")) &&
+ (NULL != wire_details) )
+ {
+ struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_string (
+ "credit_iban",
+ &tcd.details.success.details.wire_funds.target_iban),
+ GNUNET_JSON_spec_uint64 (
+ "answer_code",
+ &tcd.details.success.details.wire_funds.answer_code),
+ GNUNET_JSON_spec_string (
+ "business_name",
+ &tcd.details.success.details.wire_funds.target_business_name),
+ GNUNET_JSON_spec_string (
+ "wire_transfer_subject",
+ &tcd.details.success.details.wire_funds.wire_transfer_subject),
+ TALER_JSON_spec_amount_any ("challenge_amount",
+ &tcd.details.success.details.wire_funds.
+ amount),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (wire_details,
+ ispec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ tcd.http_status = 0;
+ tcd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ tcd.details.success.cs = ANASTASIS_CS_WIRE_FUNDS;
+ tco->cb (tco->cb_cls,
+ &tcd);
+ ANASTASIS_truth_challenge_cancel (tco);
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected challenge type `%s'\n",
+ ct);
+ json_dumpf (j,
+ stderr,
+ JSON_INDENT (2));
+ tcd.http_status = 0;
+ tcd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ case MHD_HTTP_BAD_REQUEST:
+ /* This should never happen, either us or the anastasis server is buggy
+ (or API version conflict); just pass JSON reply to the application */
+ GNUNET_break (0);
+ tcd.ec = TALER_JSON_get_error_code (j);
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ {
+ struct TALER_MERCHANT_PayUriData pd;
+
+ if ( (NULL == tco->pay_uri) ||
+ (GNUNET_OK !=
+ TALER_MERCHANT_parse_pay_uri (tco->pay_uri,
+ &pd)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse `%s'\n",
+ tco->pay_uri);
+ tcd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (
+ pd.order_id,
+ strlen (pd.order_id),
+ &tcd.details.payment_required.ps,
+ sizeof (tcd.details.payment_required.ps)))
+ {
+ GNUNET_break (0);
+ tcd.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ break;
+ }
+ tcd.details.payment_required.pd = &pd;
+ tcd.details.payment_required.payment_request = tco->pay_uri;
+ tco->cb (tco->cb_cls,
+ &tcd);
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ ANASTASIS_truth_challenge_cancel (tco);
+ return;
+ }
+ break;
+ case MHD_HTTP_FORBIDDEN:
+ /* Nothing really to verify, authentication required/failed */
+ tcd.ec = TALER_JSON_get_error_code (j);
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ /* Nothing really to verify */
+ tcd.ec = TALER_JSON_get_error_code (j);
+ break;
+ case MHD_HTTP_INTERNAL_SERVER_ERROR:
+ tcd.ec = TALER_JSON_get_error_code (j);
+ break;
+ case MHD_HTTP_BAD_GATEWAY:
+ tcd.ec = TALER_JSON_get_error_code (j);
+ break;
+ default:
+ /* unexpected response code */
+ tcd.ec = TALER_JSON_get_error_code (j);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u/%d to POST /truth/$TID/challenge\n",
+ (unsigned int) response_code,
+ (int) tcd.ec);
+ GNUNET_break (0);
+ break;
+ }
+ tco->cb (tco->cb_cls,
+ &tcd);
+ ANASTASIS_truth_challenge_cancel (tco);
+}
+
+
+/**
+ * Patch value in @a val, replacing new line with '\0'.
+ *
+ * @param[in,out] val 0-terminated string to replace '\\n' and '\\r' with '\\0' in.
+ */
+static void
+patch_value (char *val)
+{
+ size_t len;
+
+ /* found location URI we care about! */
+ len = strlen (val);
+ while ( (len > 0) &&
+ ( ('\n' == val[len - 1]) ||
+ ('\r' == val[len - 1]) ) )
+ {
+ len--;
+ val[len] = '\0';
+ }
+}
+
+
+/**
+ * Handle HTTP header received by curl.
+ *
+ * @param buffer one line of HTTP header data
+ * @param size size of an item
+ * @param nitems number of items passed
+ * @param userdata our `struct ANASTASIS_StorePolicyOperation *`
+ * @return `size * nitems`
+ */
+static size_t
+handle_header (char *buffer,
+ size_t size,
+ size_t nitems,
+ void *userdata)
+{
+ struct ANASTASIS_TruthChallengeOperation *tco = userdata;
+ size_t total = size * nitems;
+ char *ndup;
+ const char *hdr_type;
+ char *hdr_val;
+ char *sp;
+
+ ndup = GNUNET_strndup (buffer,
+ total);
+ hdr_type = strtok_r (ndup,
+ ":",
+ &sp);
+ if (NULL == hdr_type)
+ {
+ GNUNET_free (ndup);
+ return total;
+ }
+ hdr_val = strtok_r (NULL,
+ "",
+ &sp);
+ if (NULL == hdr_val)
+ {
+ GNUNET_free (ndup);
+ return total;
+ }
+ if (' ' == *hdr_val)
+ hdr_val++;
+ if (0 == strcasecmp (hdr_type,
+ ANASTASIS_HTTP_HEADER_TALER))
+ {
+ /* found payment URI we care about! */
+ GNUNET_free (tco->pay_uri);
+ tco->pay_uri = GNUNET_strdup (hdr_val);
+ patch_value (tco->pay_uri);
+ }
+ if (0 == strcasecmp (hdr_type,
+ MHD_HTTP_HEADER_CONTENT_TYPE))
+ {
+ /* found location URI we care about! */
+ GNUNET_free (tco->content_type);
+ tco->content_type = GNUNET_strdup (hdr_val);
+ patch_value (tco->content_type);
+ }
+ GNUNET_free (ndup);
+ return total;
+}
+
+
+struct ANASTASIS_TruthChallengeOperation *
+ANASTASIS_truth_challenge (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ ANASTASIS_TruthChallengeCallback cb,
+ void *cb_cls)
+{
+ struct ANASTASIS_TruthChallengeOperation *tco;
+ CURL *eh;
+ json_t *body;
+
+ body = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_data_auto ("truth_decryption_key",
+ truth_key),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_data_auto ("payment_secret",
+ payment_secret)));
+ GNUNET_assert (NULL != body);
+ tco = GNUNET_new (struct ANASTASIS_TruthChallengeOperation);
+ tco->cb = cb;
+ tco->cb_cls = cb_cls;
+ {
+ char *path;
+ char *uuid_str;
+
+ uuid_str = GNUNET_STRINGS_data_to_string_alloc (truth_uuid,
+ sizeof (*truth_uuid));
+ GNUNET_asprintf (&path,
+ "truth/%s/challenge",
+ uuid_str);
+ GNUNET_free (uuid_str);
+ tco->url = TALER_url_join (backend_url,
+ path,
+ NULL);
+ GNUNET_free (path);
+ }
+ eh = ANASTASIS_curl_easy_get_ (tco->url);
+ if ( (NULL == eh) ||
+ (GNUNET_OK !=
+ TALER_curl_easy_post (&tco->ctx,
+ eh,
+ body)) )
+ {
+ GNUNET_break (0);
+ if (NULL != eh)
+ curl_easy_cleanup (eh);
+ json_decref (body);
+ GNUNET_free (tco->url);
+ GNUNET_free (tco);
+ return NULL;
+ }
+ json_decref (body);
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_HEADERFUNCTION,
+ &handle_header));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_HEADERDATA,
+ tco));
+ tco->job = GNUNET_CURL_job_add2 (ctx,
+ eh,
+ tco->ctx.headers,
+ &handle_truth_challenge_finished,
+ tco);
+ return tco;
+}
+
+
+/* end of anastasis_api_truth_challenge.c */
diff --git a/src/restclient/anastasis_api_truth_solve.c b/src/restclient/anastasis_api_truth_solve.c
new file mode 100644
index 0000000..9002a63
--- /dev/null
+++ b/src/restclient/anastasis_api_truth_solve.c
@@ -0,0 +1,437 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020, 2021, 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file restclient/anastasis_api_truth_solve.c
+ * @brief Implementation of the POST /truth/$TID/solve request
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ */
+#include "platform.h"
+#include <curl/curl.h>
+#include <jansson.h>
+#include <microhttpd.h> /* just for HTTP status codes */
+#include "anastasis_service.h"
+#include "anastasis_api_curl_defaults.h"
+#include <taler/taler_json_lib.h>
+#include <taler/taler_curl_lib.h>
+#include <taler/taler_merchant_service.h>
+
+
+/**
+ * @brief A Contract Operation Handle
+ */
+struct ANASTASIS_TruthSolveOperation
+{
+ /**
+ * The url for this request, including parameters.
+ */
+ char *url;
+
+ /**
+ * Handle for the request.
+ */
+ struct GNUNET_CURL_Job *job;
+
+ /**
+ * Function to call with the result.
+ */
+ ANASTASIS_TruthSolveCallback cb;
+
+ /**
+ * Closure for @a cb.
+ */
+ void *cb_cls;
+
+ /**
+ * Context for #TEH_curl_easy_post(). Keeps the data that must
+ * persist for Curl to make the upload.
+ */
+ struct TALER_CURL_PostContext ctx;
+
+ /**
+ * Payment URI we received from the service, or NULL.
+ */
+ char *pay_uri;
+
+ /**
+ * Content type of the body.
+ */
+ char *content_type;
+};
+
+
+void
+ANASTASIS_truth_solve_cancel (
+ struct ANASTASIS_TruthSolveOperation *tso)
+{
+ if (NULL != tso->job)
+ {
+ GNUNET_CURL_job_cancel (tso->job);
+ tso->job = NULL;
+ }
+ GNUNET_free (tso->pay_uri);
+ GNUNET_free (tso->url);
+ GNUNET_free (tso->content_type);
+ TALER_curl_easy_post_finished (&tso->ctx);
+ GNUNET_free (tso);
+}
+
+
+/**
+ * Process POST /truth/$TID/solve response
+ *
+ * @param cls our `struct ANASTASIS_TruthSolveOperation *`
+ * @param response_code the HTTP status
+ * @param data the body of the response
+ * @param data_size number of bytes in @a data
+ */
+static void
+handle_truth_solve_finished (void *cls,
+ long response_code,
+ const void *data,
+ size_t data_size)
+{
+ struct ANASTASIS_TruthSolveOperation *tso = cls;
+ struct ANASTASIS_TruthSolveReply tsr = {
+ .http_status = response_code
+ };
+
+ tso->job = NULL;
+ switch (response_code)
+ {
+ case 0:
+ /* Hard error */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Backend didn't even return from POST /truth/$TID/solve\n");
+ tsr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
+ case MHD_HTTP_OK:
+ if (sizeof (tsr.details.success.eks) != data_size)
+ {
+ GNUNET_break_op (0);
+ tsr.http_status = 0;
+ tsr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
+ }
+ /* Success, call callback with all details! */
+ memcpy (&tsr.details.success.eks,
+ data,
+ data_size);
+ break;
+ case MHD_HTTP_BAD_REQUEST:
+ /* This should never happen, either us or the anastasis server is buggy
+ (or API version conflict); just pass JSON reply to the application */
+ GNUNET_break (0);
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ {
+ struct TALER_MERCHANT_PayUriData pd;
+
+ if ( (NULL == tso->pay_uri) ||
+ (GNUNET_OK !=
+ TALER_MERCHANT_parse_pay_uri (tso->pay_uri,
+ &pd)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse `%s'\n",
+ tso->pay_uri);
+ tsr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (
+ pd.order_id,
+ strlen (pd.order_id),
+ &tsr.details.payment_required.ps,
+ sizeof (tsr.details.payment_required.ps)))
+ {
+ GNUNET_break (0);
+ tsr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ break;
+ }
+ tsr.details.payment_required.pd = &pd;
+ tsr.details.payment_required.payment_request = tso->pay_uri;
+ tso->cb (tso->cb_cls,
+ &tsr);
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ ANASTASIS_truth_solve_cancel (tso);
+ return;
+ }
+ break;
+ case MHD_HTTP_FORBIDDEN:
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
+ case MHD_HTTP_NOT_FOUND:
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
+ case MHD_HTTP_REQUEST_TIMEOUT:
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
+ case MHD_HTTP_TOO_MANY_REQUESTS:
+ {
+ json_t *reply;
+
+ reply = json_loadb (data,
+ data_size,
+ JSON_REJECT_DUPLICATES,
+ NULL);
+ if (NULL == reply)
+ {
+ GNUNET_break_op (0);
+ tsr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ break;
+ }
+
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_uint32 (
+ "request_limit",
+ &tsr.details.too_many_requests.request_limit),
+ GNUNET_JSON_spec_relative_time (
+ "request_frequency",
+ &tsr.details.too_many_requests.request_frequency),
+ GNUNET_JSON_spec_end ()
+ };
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (reply,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ tsr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ json_decref (reply);
+ break;
+ }
+ json_decref (reply);
+ break;
+ }
+ }
+ case MHD_HTTP_INTERNAL_SERVER_ERROR:
+ /* Server had an internal issue; we should retry, but this API
+ leaves this to the application */
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
+ case MHD_HTTP_BAD_GATEWAY:
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
+ default:
+ /* unexpected response code */
+ tsr.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected response code %u/%d to POST /truth/$TID/solve\n",
+ (unsigned int) response_code,
+ (int) tsr.ec);
+ break;
+ }
+ tso->cb (tso->cb_cls,
+ &tsr);
+ ANASTASIS_truth_solve_cancel (tso);
+}
+
+
+/**
+ * Patch value in @a val, replacing new line with '\0'.
+ *
+ * @param[in,out] val 0-terminated string to replace '\\n' and '\\r' with '\\0' in.
+ */
+static void
+patch_value (char *val)
+{
+ size_t len;
+
+ /* found location URI we care about! */
+ len = strlen (val);
+ while ( (len > 0) &&
+ ( ('\n' == val[len - 1]) ||
+ ('\r' == val[len - 1]) ) )
+ {
+ len--;
+ val[len] = '\0';
+ }
+}
+
+
+/**
+ * Handle HTTP header received by curl.
+ *
+ * @param buffer one line of HTTP header data
+ * @param size size of an item
+ * @param nitems number of items passed
+ * @param userdata our `struct ANASTASIS_StorePolicyOperation *`
+ * @return `size * nitems`
+ */
+static size_t
+handle_header (char *buffer,
+ size_t size,
+ size_t nitems,
+ void *userdata)
+{
+ struct ANASTASIS_TruthSolveOperation *tso = userdata;
+ size_t total = size * nitems;
+ char *ndup;
+ const char *hdr_type;
+ char *hdr_val;
+ char *sp;
+
+ ndup = GNUNET_strndup (buffer,
+ total);
+ hdr_type = strtok_r (ndup,
+ ":",
+ &sp);
+ if (NULL == hdr_type)
+ {
+ GNUNET_free (ndup);
+ return total;
+ }
+ hdr_val = strtok_r (NULL,
+ "",
+ &sp);
+ if (NULL == hdr_val)
+ {
+ GNUNET_free (ndup);
+ return total;
+ }
+ if (' ' == *hdr_val)
+ hdr_val++;
+ if (0 == strcasecmp (hdr_type,
+ ANASTASIS_HTTP_HEADER_TALER))
+ {
+ /* found payment URI we care about! */
+ GNUNET_free (tso->pay_uri);
+ tso->pay_uri = GNUNET_strdup (hdr_val);
+ patch_value (tso->pay_uri);
+ }
+ if (0 == strcasecmp (hdr_type,
+ MHD_HTTP_HEADER_CONTENT_TYPE))
+ {
+ /* found location URI we care about! */
+ GNUNET_free (tso->content_type);
+ tso->content_type = GNUNET_strdup (hdr_val);
+ patch_value (tso->content_type);
+ }
+ GNUNET_free (ndup);
+ return total;
+}
+
+
+struct ANASTASIS_TruthSolveOperation *
+ANASTASIS_truth_solve (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ struct GNUNET_TIME_Relative timeout,
+ const struct GNUNET_HashCode *hashed_answer,
+ ANASTASIS_TruthSolveCallback cb,
+ void *cb_cls)
+{
+ struct ANASTASIS_TruthSolveOperation *tso;
+ CURL *eh;
+ char *path;
+ unsigned long long tms;
+ json_t *body;
+
+ body = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_data_auto ("truth_decryption_key",
+ truth_key),
+ GNUNET_JSON_pack_data_auto ("h_response",
+ hashed_answer),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_data_auto ("payment_secret",
+ payment_secret)));
+ GNUNET_assert (NULL != body);
+
+ tms = (unsigned long long) (timeout.rel_value_us
+ / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us);
+ tso = GNUNET_new (struct ANASTASIS_TruthSolveOperation);
+ tso->cb = cb;
+ tso->cb_cls = cb_cls;
+ {
+ char *uuid_str;
+
+ uuid_str = GNUNET_STRINGS_data_to_string_alloc (truth_uuid,
+ sizeof (*truth_uuid));
+ GNUNET_asprintf (&path,
+ "truth/%s/solve",
+ uuid_str);
+ GNUNET_free (uuid_str);
+ }
+ {
+ char timeout_ms[32];
+
+ GNUNET_snprintf (timeout_ms,
+ sizeof (timeout_ms),
+ "%llu",
+ tms);
+ tso->url = TALER_url_join (backend_url,
+ path,
+ "timeout_ms",
+ (! GNUNET_TIME_relative_is_zero (timeout))
+ ? timeout_ms
+ : NULL,
+ NULL);
+ }
+ GNUNET_free (path);
+ eh = ANASTASIS_curl_easy_get_ (tso->url);
+ if ( (NULL == eh) ||
+ (GNUNET_OK !=
+ TALER_curl_easy_post (&tso->ctx,
+ eh,
+ body)) )
+ {
+ GNUNET_break (0);
+ if (NULL != eh)
+ curl_easy_cleanup (eh);
+ json_decref (body);
+ GNUNET_free (tso->url);
+ GNUNET_free (tso);
+ return NULL;
+ }
+ json_decref (body);
+ if (0 != tms)
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_TIMEOUT_MS,
+ (long) (tms + 5000)));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_HEADERFUNCTION,
+ &handle_header));
+ GNUNET_assert (CURLE_OK ==
+ curl_easy_setopt (eh,
+ CURLOPT_HEADERDATA,
+ tso));
+ tso->job = GNUNET_CURL_job_add_raw (ctx,
+ eh,
+ tso->ctx.headers,
+ &handle_truth_solve_finished,
+ tso);
+ return tso;
+}
+
+
+/* end of anastasis_api_truth_solve.c */
diff --git a/src/restclient/anastasis_api_truth_store.c b/src/restclient/anastasis_api_truth_store.c
index 18a3682..855ad5a 100644
--- a/src/restclient/anastasis_api_truth_store.c
+++ b/src/restclient/anastasis_api_truth_store.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -169,10 +169,18 @@ handle_truth_store_finished (void *cls,
ud.ec = TALER_JSON_get_error_code2 (data,
data_size);
break;
+ case MHD_HTTP_BAD_GATEWAY:
+ ud.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ break;
default:
- GNUNET_break (0);
ud.ec = TALER_JSON_get_error_code2 (data,
data_size);
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unexpected HTTP status code %u/%d\n",
+ (unsigned int) response_code,
+ ud.ec);
break;
}
tso->cb (tso->cb_cls,
diff --git a/src/stasis/Makefile.am b/src/stasis/Makefile.am
index 140f65e..0197f0e 100644
--- a/src/stasis/Makefile.am
+++ b/src/stasis/Makefile.am
@@ -16,9 +16,9 @@ endif
sqldir = $(prefix)/share/anastasis/sql/
sql_DATA = \
- stasis-0000.sql \
+ versioning.sql \
stasis-0001.sql \
- drop0001.sql
+ drop.sql
pkgcfgdir = $(prefix)/share/anastasis/config.d/
@@ -59,16 +59,16 @@ libanastasisdb_la_LDFLAGS = \
libanastasis_plugin_db_postgres_la_SOURCES = \
plugin_anastasis_postgres.c
-libanastasis_plugin_db_postgres_la_LIBADD = \
- $(LTLIBINTL)
libanastasis_plugin_db_postgres_la_LDFLAGS = \
+ $(ANASTASIS_PLUGIN_LDFLAGS)
+libanastasis_plugin_db_postgres_la_LIBADD = \
+ $(LTLIBINTL) \
$(top_builddir)/src/util/libanastasisutil.la \
- $(ANASTASIS_PLUGIN_LDFLAGS) \
- -lgnunetpq \
- -lpq \
-ltalerpq \
-ltalerutil \
+ -lgnunetpq \
-lgnunetutil \
+ -lpq \
$(XLIB)
check_PROGRAMS = \
@@ -83,7 +83,6 @@ test_anastasis_db_postgres_LDFLAGS = \
-lgnunetpq \
-ltalerutil \
-ltalerpq \
- -luuid \
$(XLIB)
AM_TESTS_ENVIRONMENT=export ANASTASIS_PREFIX=$${ANASTASIS_PREFIX:-@libdir@};export PATH=$${ANASTASIS_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/stasis/anastasis_db_plugin.c b/src/stasis/anastasis_db_plugin.c
index 7edca5f..a7e55b9 100644
--- a/src/stasis/anastasis_db_plugin.c
+++ b/src/stasis/anastasis_db_plugin.c
@@ -3,7 +3,7 @@
Copyright (C) 2015, 2016 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
diff --git a/src/stasis/drop0001.sql b/src/stasis/drop.sql
index c7697c0..357fa9d 100644
--- a/src/stasis/drop0001.sql
+++ b/src/stasis/drop.sql
@@ -1,6 +1,6 @@
--
-- This file is part of ANASTASIS
--- Copyright (C) 2014--2020 Anastasis Systems SA
+-- Copyright (C) 2014--2022 Anastasis Systems SA
--
-- ANASTASIS 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
@@ -17,22 +17,15 @@
-- Everything in one big transaction
BEGIN;
--- This script DROPs all of the tables we create.
---
--- Unlike the other SQL files, it SHOULD be updated to reflect the
--- latest requirements for dropping tables.
-
--- Drops for 0001.sql
-DROP TABLE IF EXISTS anastasis_truth CASCADE;
-DROP TABLE IF EXISTS anastasis_user CASCADE;
-DROP TABLE IF EXISTS anastasis_recdoc_payment;
-DROP TABLE IF EXISTS anastasis_recoverydocument;
-DROP TABLE IF EXISTS anastasis_challengecode;
-DROP TABLE IF EXISTS anastasis_challenge_payment;
-DROP TABLE IF EXISTS anastasis_auth_iban_in;
+WITH xpatches AS (
+ SELECT patch_name
+ FROM _v.patches
+ WHERE starts_with(patch_name,'stasis-')
+)
+ SELECT _v.unregister_patch(xpatches.patch_name)
+ FROM xpatches;
--- Unregister patch (0001.sql)
-SELECT _v.unregister_patch('stasis-0001');
+DROP SCHEMA anastasis CASCADE;
-- And we're out of here...
COMMIT;
diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c
index b0b8f96..9f4b969 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1,9 +1,9 @@
/*
This file is part of Anastasis
- Copyright (C) 2020, 2021 Anastasis SARL
+ Copyright (C) 2020, 2021, 2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,8 +15,7 @@
*/
/**
* @file stasis/plugin_anastasis_postgres.c
- * @brief database helper functions for postgres used by the anastasis
- * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ * @brief database helper functions for postgres used by GNU Anastasis
* @author Christian Grothoff
* @author Marcello Stanisci
*/
@@ -38,12 +37,6 @@
*/
#define MAX_RETRIES 3
-/**
- * Maximum value allowed for nonces. Limited to 2^52 to ensure the
- * numeric value survives a conversion to float by JavaScript.
- */
-#define NONCE_MAX_VALUE (1LLU << 52)
-
/**
* Type of the "cls" argument given to each of the functions in
@@ -90,16 +83,19 @@ postgres_drop_tables (void *cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_Context *conn;
+ enum GNUNET_GenericReturnValue ret;
conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
"stasis-postgres",
- "drop",
+ NULL,
NULL,
NULL);
if (NULL == conn)
return GNUNET_SYSERR;
+ ret = GNUNET_PQ_exec_sql (conn,
+ "drop");
GNUNET_PQ_disconnect (conn);
- return GNUNET_OK;
+ return ret;
}
@@ -114,11 +110,15 @@ postgres_create_tables (void *cls)
{
struct PostgresClosure *pc = cls;
struct GNUNET_PQ_Context *conn;
+ struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_execute ("SET search_path TO anastasis;"),
+ GNUNET_PQ_EXECUTE_STATEMENT_END
+ };
conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
"stasis-postgres",
"stasis-",
- NULL,
+ es,
NULL);
if (NULL == conn)
return GNUNET_SYSERR;
@@ -134,7 +134,7 @@ postgres_create_tables (void *cls)
* @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
*/
static enum GNUNET_GenericReturnValue
-postgres_connect (void *cls)
+prepare_statements (void *cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_PreparedStatement ps[] = {
@@ -143,54 +143,44 @@ postgres_connect (void *cls)
"(user_id"
",expiration_date"
") VALUES "
- "($1, $2);",
- 2),
+ "($1, $2);"),
GNUNET_PQ_make_prepare ("do_commit",
- "COMMIT",
- 0),
+ "COMMIT"),
GNUNET_PQ_make_prepare ("user_select",
"SELECT"
" expiration_date "
"FROM anastasis_user"
" WHERE user_id=$1"
- " FOR UPDATE;",
- 1),
+ " FOR UPDATE;"),
GNUNET_PQ_make_prepare ("user_update",
"UPDATE anastasis_user"
" SET "
" expiration_date=$1"
- " WHERE user_id=$2;",
- 2),
+ " WHERE user_id=$2;"),
GNUNET_PQ_make_prepare ("recdoc_payment_insert",
"INSERT INTO anastasis_recdoc_payment "
"(user_id"
",post_counter"
- ",amount_val"
- ",amount_frac"
+ ",amount"
",payment_identifier"
",creation_date"
") VALUES "
- "($1, $2, $3, $4, $5, $6);",
- 6),
+ "($1, $2, $3, $4, $5);"),
GNUNET_PQ_make_prepare ("challenge_payment_insert",
"INSERT INTO anastasis_challenge_payment "
"(truth_uuid"
- ",amount_val"
- ",amount_frac"
+ ",amount"
",payment_identifier"
",creation_date"
") VALUES "
- "($1, $2, $3, $4, $5);",
- 5),
+ "($1, $2, $3, $4);"),
GNUNET_PQ_make_prepare ("truth_payment_insert",
"INSERT INTO anastasis_truth_payment "
"(truth_uuid"
- ",amount_val"
- ",amount_frac"
+ ",amount"
",expiration"
") VALUES "
- "($1, $2, $3, $4);",
- 4),
+ "($1, $2, $3);"),
GNUNET_PQ_make_prepare ("recdoc_payment_done",
"UPDATE anastasis_recdoc_payment "
"SET"
@@ -200,8 +190,7 @@ postgres_connect (void *cls)
" AND"
" user_id=$2"
" AND"
- " paid=FALSE;",
- 2),
+ " paid=FALSE;"),
GNUNET_PQ_make_prepare ("challenge_refund_update",
"UPDATE anastasis_challenge_payment "
"SET"
@@ -211,8 +200,7 @@ postgres_connect (void *cls)
" AND"
" paid=TRUE"
" AND"
- " truth_uuid=$2;",
- 2),
+ " truth_uuid=$2;"),
GNUNET_PQ_make_prepare ("challenge_payment_done",
"UPDATE anastasis_challenge_payment "
"SET"
@@ -224,43 +212,36 @@ postgres_connect (void *cls)
" AND"
" truth_uuid=$2"
" AND"
- " paid=FALSE;",
- 2),
+ " paid=FALSE;"),
GNUNET_PQ_make_prepare ("recdoc_payment_select",
"SELECT"
" creation_date"
",post_counter"
- ",amount_val"
- ",amount_frac"
+ ",amount"
",paid"
" FROM anastasis_recdoc_payment"
- " WHERE payment_identifier=$1;",
- 1),
+ " WHERE payment_identifier=$1;"),
GNUNET_PQ_make_prepare ("truth_payment_select",
"SELECT"
" expiration"
" FROM anastasis_truth_payment"
" WHERE truth_uuid=$1"
- " AND expiration>$2;",
- 2),
+ " AND expiration>$2;"),
GNUNET_PQ_make_prepare ("challenge_payment_select",
"SELECT"
" creation_date"
- ",amount_val"
- ",amount_frac"
+ ",amount"
",paid"
" FROM anastasis_challenge_payment"
" WHERE payment_identifier=$1"
" AND truth_uuid=$2"
" AND refunded=FALSE"
- " AND counter>0;",
- 1),
+ " AND counter>0;"),
GNUNET_PQ_make_prepare ("challenge_pending_payment_select",
"SELECT"
" creation_date"
",payment_identifier"
- ",amount_val"
- ",amount_frac"
+ ",amount"
" FROM anastasis_challenge_payment"
" WHERE"
" paid=FALSE"
@@ -269,29 +250,24 @@ postgres_connect (void *cls)
" AND"
" truth_uuid=$1"
" AND"
- " creation_date > $2;",
- 1),
+ " creation_date > $2;"),
GNUNET_PQ_make_prepare ("recdoc_payments_select",
"SELECT"
" user_id"
",payment_identifier"
- ",amount_val"
- ",amount_frac"
+ ",amount"
" FROM anastasis_recdoc_payment"
- " WHERE paid=FALSE;",
- 0),
+ " WHERE paid=FALSE;"),
GNUNET_PQ_make_prepare ("gc_accounts",
"DELETE FROM anastasis_user "
"WHERE"
- " expiration_date < $1;",
- 1),
+ " expiration_date < $1;"),
GNUNET_PQ_make_prepare ("gc_recdoc_pending_payments",
"DELETE FROM anastasis_recdoc_payment "
"WHERE"
" paid=FALSE"
" AND"
- " creation_date < $1;",
- 1),
+ " creation_date < $1;"),
GNUNET_PQ_make_prepare ("gc_challenge_pending_payments",
"DELETE FROM anastasis_challenge_payment "
"WHERE"
@@ -299,8 +275,7 @@ postgres_connect (void *cls)
" OR"
" refunded=TRUE)"
" AND"
- " creation_date < $1;",
- 1),
+ " creation_date < $1;"),
GNUNET_PQ_make_prepare ("truth_insert",
"INSERT INTO anastasis_truth "
"(truth_uuid"
@@ -310,32 +285,24 @@ postgres_connect (void *cls)
",truth_mime"
",expiration"
") VALUES "
- "($1, $2, $3, $4, $5, $6);",
- 6),
-
+ "($1, $2, $3, $4, $5, $6);"),
GNUNET_PQ_make_prepare ("test_auth_iban_payment",
"SELECT"
- " credit_val"
- ",credit_frac"
+ " credit"
",wire_subject"
" FROM anastasis_auth_iban_in"
" WHERE debit_account_details=$1"
- " AND execution_date>=$2;",
- 2),
+ " AND execution_date>=$2;"),
GNUNET_PQ_make_prepare ("store_auth_iban_payment_details",
"INSERT INTO anastasis_auth_iban_in "
"(wire_reference"
",wire_subject"
- ",credit_val"
- ",credit_frac"
+ ",credit"
",debit_account_details"
",credit_account_details"
",execution_date"
") VALUES "
- "($1, $2, $3, $4, $5, $6, $7);",
- 7),
-
-
+ "($1, $2, $3, $4, $5, $6);"),
GNUNET_PQ_make_prepare ("recovery_document_insert",
"INSERT INTO anastasis_recoverydocument "
"(user_id"
@@ -343,17 +310,27 @@ postgres_connect (void *cls)
",account_sig"
",recovery_data_hash"
",recovery_data"
+ ",recovery_meta_data"
+ ",creation_date"
") VALUES "
- "($1, $2, $3, $4, $5);",
- 5),
+ "($1, $2, $3, $4, $5, $6, $7);"),
GNUNET_PQ_make_prepare ("truth_select",
"SELECT "
" method_name"
",encrypted_truth"
",truth_mime"
" FROM anastasis_truth"
- " WHERE truth_uuid =$1;",
- 1),
+ " WHERE truth_uuid=$1;"),
+ GNUNET_PQ_make_prepare ("recoverydocument_select_meta",
+ "SELECT "
+ " version"
+ ",creation_date"
+ ",recovery_meta_data"
+ " FROM anastasis_recoverydocument"
+ " WHERE user_id=$1"
+ " AND version < $2"
+ " ORDER BY version DESC"
+ " LIMIT 1000;"),
GNUNET_PQ_make_prepare ("latest_recoverydocument_select",
"SELECT "
" version"
@@ -361,10 +338,9 @@ postgres_connect (void *cls)
",recovery_data_hash"
",recovery_data"
" FROM anastasis_recoverydocument"
- " WHERE user_id =$1 "
+ " WHERE user_id=$1"
" ORDER BY version DESC"
- " LIMIT 1;",
- 1),
+ " LIMIT 1;"),
GNUNET_PQ_make_prepare ("latest_recovery_version_select",
"SELECT"
" version"
@@ -374,8 +350,7 @@ postgres_connect (void *cls)
" JOIN anastasis_user USING (user_id)"
" WHERE user_id=$1"
" ORDER BY version DESC"
- " LIMIT 1;",
- 1),
+ " LIMIT 1;"),
GNUNET_PQ_make_prepare ("recoverydocument_select",
"SELECT "
" account_sig"
@@ -383,30 +358,26 @@ postgres_connect (void *cls)
",recovery_data"
" FROM anastasis_recoverydocument"
" WHERE user_id=$1"
- " AND version=$2;",
- 2),
+ " AND version=$2;"),
GNUNET_PQ_make_prepare ("postcounter_select",
"SELECT"
" post_counter"
" FROM anastasis_recdoc_payment"
" WHERE user_id=$1"
- " AND payment_identifier=$2;",
- 2),
+ " AND payment_identifier=$2;"),
GNUNET_PQ_make_prepare ("postcounter_update",
- "UPDATE "
- "anastasis_recdoc_payment "
- "SET "
- "post_counter=$1 "
- "WHERE user_id =$2 "
- "AND payment_identifier=$3;",
- 3),
+ "UPDATE"
+ " anastasis_recdoc_payment"
+ " SET"
+ " post_counter=$1"
+ " WHERE user_id =$2"
+ " AND payment_identifier=$3;"),
GNUNET_PQ_make_prepare ("key_share_select",
"SELECT "
"key_share_data "
"FROM "
"anastasis_truth "
- "WHERE truth_uuid =$1;",
- 1),
+ "WHERE truth_uuid =$1;"),
GNUNET_PQ_make_prepare ("challengecode_insert",
"INSERT INTO anastasis_challengecode "
"(truth_uuid"
@@ -415,8 +386,7 @@ postgres_connect (void *cls)
",expiration_date"
",retry_counter"
") VALUES "
- "($1, $2, $3, $4, $5);",
- 5),
+ "($1, $2, $3, $4, $5);"),
GNUNET_PQ_make_prepare ("challengecode_select",
"SELECT "
" code"
@@ -424,8 +394,7 @@ postgres_connect (void *cls)
" FROM anastasis_challengecode"
" WHERE truth_uuid=$1"
" AND expiration_date > $2"
- " AND retry_counter != 0;",
- 2),
+ " AND retry_counter != 0;"),
GNUNET_PQ_make_prepare ("challengecode_set_satisfied",
"UPDATE anastasis_challengecode"
" SET satisfied=TRUE"
@@ -437,16 +406,14 @@ postgres_connect (void *cls)
" WHERE truth_uuid=$1"
" AND code=$2"
" ORDER BY creation_date DESC"
- " LIMIT 1);",
- 2),
+ " LIMIT 1);"),
GNUNET_PQ_make_prepare ("challengecode_test_satisfied",
"SELECT 1 FROM anastasis_challengecode"
" WHERE truth_uuid=$1"
" AND satisfied=TRUE"
" AND code=$2"
" AND creation_date >= $3"
- " LIMIT 1;",
- 3),
+ " LIMIT 1;"),
GNUNET_PQ_make_prepare ("challengecode_select_meta",
"SELECT "
" code"
@@ -457,22 +424,19 @@ postgres_connect (void *cls)
" AND expiration_date > $2"
" AND creation_date > $3"
" ORDER BY creation_date DESC"
- " LIMIT 1;",
- 2),
+ " LIMIT 1;"),
GNUNET_PQ_make_prepare ("challengecode_update_retry",
"UPDATE anastasis_challengecode"
" SET retry_counter=retry_counter - 1"
" WHERE truth_uuid=$1"
" AND code=$2"
- " AND retry_counter != 0;",
- 1),
+ " AND retry_counter != 0;"),
GNUNET_PQ_make_prepare ("challengepayment_dec_counter",
"UPDATE anastasis_challenge_payment"
" SET counter=counter - 1"
" WHERE truth_uuid=$1"
" AND payment_identifier=$2"
- " AND counter > 0;",
- 2),
+ " AND counter > 0;"),
GNUNET_PQ_make_prepare ("challengecode_mark_sent",
"UPDATE anastasis_challengecode"
" SET retransmission_date=$3"
@@ -484,32 +448,31 @@ postgres_connect (void *cls)
" WHERE truth_uuid=$1"
" AND code=$2"
" ORDER BY creation_date DESC"
- " LIMIT 1);",
- 3),
+ " LIMIT 1);"),
GNUNET_PQ_make_prepare ("get_last_auth_iban_payment",
"SELECT "
" wire_reference"
" FROM anastasis_auth_iban_in"
" WHERE credit_account_details=$1"
" ORDER BY wire_reference DESC"
- " LIMIT 1;",
- 1),
+ " LIMIT 1;"),
GNUNET_PQ_make_prepare ("gc_challengecodes",
"DELETE FROM anastasis_challengecode "
"WHERE "
- "expiration_date < $1;",
- 1),
+ "expiration_date < $1;"),
GNUNET_PQ_PREPARED_STATEMENT_END
};
- pg->conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
- "stasis-postgres",
- NULL,
- NULL,
- ps);
- if (NULL == pg->conn)
- return GNUNET_SYSERR;
- return GNUNET_OK;
+ {
+ enum GNUNET_GenericReturnValue ret;
+
+ ret = GNUNET_PQ_prepare_statements (pg->conn,
+ ps);
+ if (GNUNET_OK != ret)
+ return ret;
+ pg->init = true;
+ return GNUNET_OK;
+ }
}
@@ -554,15 +517,19 @@ internal_setup (struct PostgresClosure *pg,
"SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"),
GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"),
GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"),
+ GNUNET_PQ_make_execute ("SET search_path TO anastasis;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
#else
- struct GNUNET_PQ_ExecuteStatement *es = NULL;
+ struct GNUNET_PQ_ExecuteStatement es[] = {
+ GNUNET_PQ_make_execute ("SET search_path TO anastasis;"),
+ GNUNET_PQ_EXECUTE_STATEMENT_END
+ };
#endif
struct GNUNET_PQ_Context *db_conn;
db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
- "exchangedb-postgres",
+ "stasis-postgres",
NULL,
es,
NULL);
@@ -576,7 +543,7 @@ internal_setup (struct PostgresClosure *pg,
return GNUNET_OK;
if (skip_prepare)
return GNUNET_OK;
- return postgres_connect (pg);
+ return prepare_statements (pg);
}
@@ -635,7 +602,7 @@ postgres_preflight (void *cls)
* must point to a constant
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
begin_transaction (void *cls,
const char *name)
{
@@ -838,6 +805,8 @@ postgres_store_recovery_document (
const struct GNUNET_HashCode *recovery_data_hash,
const void *recovery_data,
size_t recovery_data_size,
+ const void *recovery_meta_data,
+ size_t recovery_meta_data_size,
const struct ANASTASIS_PaymentSecretP *payment_secret,
uint32_t *version)
{
@@ -1014,6 +983,8 @@ postgres_store_recovery_document (
/* finally, actually insert the recovery document */
{
+ struct GNUNET_TIME_Timestamp now
+ = GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_uint32 (version),
@@ -1021,6 +992,9 @@ postgres_store_recovery_document (
GNUNET_PQ_query_param_auto_from_type (recovery_data_hash),
GNUNET_PQ_query_param_fixed_size (recovery_data,
recovery_data_size),
+ GNUNET_PQ_query_param_fixed_size (recovery_meta_data,
+ recovery_meta_data_size),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
@@ -1055,7 +1029,8 @@ retry:
/**
- * Increment account lifetime.
+ * Increment account lifetime based on payment having been received.
+ * Does nothing if the payment is not new.
*
* @param cls closure
* @param account_pub which account received a payment
@@ -1070,11 +1045,16 @@ postgres_increment_lifetime (
const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
const struct ANASTASIS_PaymentSecretP *payment_identifier,
struct GNUNET_TIME_Relative lifetime,
- struct GNUNET_TIME_Absolute *paid_until)
+ struct GNUNET_TIME_Timestamp *paid_until)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Incrementing lifetime of account %s based on payment by %s\n",
+ TALER_B2S (account_pub),
+ GNUNET_TIME_relative2s (lifetime,
+ true));
check_connection (pg);
for (unsigned int retries = 0; retries<MAX_RETRIES; retries++)
{
@@ -1099,14 +1079,16 @@ postgres_increment_lifetime (
{
case GNUNET_DB_STATUS_HARD_ERROR:
rollback (pg);
- *paid_until = GNUNET_TIME_UNIT_ZERO_ABS;
+ *paid_until = GNUNET_TIME_UNIT_ZERO_TS;
return qs;
case GNUNET_DB_STATUS_SOFT_ERROR:
goto retry;
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ /* Payment not new or payment request unknown. */
/* continued below */
break;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ /* Payment just now marked as 'paid' */
/* continued below */
break;
}
@@ -1118,10 +1100,10 @@ postgres_increment_lifetime (
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_end
};
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_TIME_Timestamp expiration;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("expiration_date",
- &expiration),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ &expiration),
GNUNET_PQ_result_spec_end
};
@@ -1149,14 +1131,18 @@ postgres_increment_lifetime (
/* user does not exist, create new one */
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
- GNUNET_PQ_query_param_absolute_time (&expiration),
+ GNUNET_PQ_query_param_timestamp (&expiration),
GNUNET_PQ_query_param_end
};
- expiration = GNUNET_TIME_relative_to_absolute (lifetime);
- GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
- expiration.abs_value_us);
+ expiration = GNUNET_TIME_relative_to_timestamp (lifetime);
+ GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time));
*paid_until = expiration;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Creating new account %s with initial lifetime of %s\n",
+ TALER_B2S (account_pub),
+ GNUNET_TIME_relative2s (lifetime,
+ true));
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_insert",
params);
@@ -1165,28 +1151,36 @@ postgres_increment_lifetime (
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
- /* existing rec doc payment, return expiration */
+ /* existing rec doc payment (payment replay), return
+ existing expiration */
*paid_until = expiration;
rollback (pg);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Payment existed, lifetime of account %s unchanged at %s\n",
TALER_B2S (account_pub),
- GNUNET_STRINGS_absolute_time_to_string (*paid_until));
+ GNUNET_TIME_timestamp2s (*paid_until));
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
else
{
- /* user exists, update expiration_date */
+ /* user exists, payment is new, update expiration_date */
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_absolute_time (&expiration),
+ GNUNET_PQ_query_param_timestamp (&expiration),
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_end
};
- expiration = GNUNET_TIME_absolute_add (expiration,
- lifetime);
- GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
- expiration.abs_value_us);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Incrementing lifetime of account %s by %s\n",
+ TALER_B2S (account_pub),
+ GNUNET_TIME_relative2s (lifetime,
+ true));
+ expiration
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_add (expiration.abs_time,
+ lifetime));
+ GNUNET_break (! GNUNET_TIME_absolute_is_never (
+ expiration.abs_time));
*paid_until = expiration;
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_update",
@@ -1218,7 +1212,7 @@ postgres_increment_lifetime (
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Incremented lifetime of account %s to %s\n",
TALER_B2S (account_pub),
- GNUNET_STRINGS_absolute_time_to_string (*paid_until));
+ GNUNET_TIME_timestamp2s (*paid_until));
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
retry:
rollback (pg);
@@ -1242,7 +1236,7 @@ postgres_update_lifetime (
void *cls,
const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
const struct ANASTASIS_PaymentSecretP *payment_identifier,
- struct GNUNET_TIME_Absolute eol)
+ struct GNUNET_TIME_Timestamp eol)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
@@ -1286,10 +1280,10 @@ postgres_update_lifetime (
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_end
};
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_TIME_Timestamp expiration;
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("expiration_date",
- &expiration),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ &expiration),
GNUNET_PQ_result_spec_end
};
@@ -1309,41 +1303,39 @@ postgres_update_lifetime (
/* user does not exist, create new one */
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
- GNUNET_PQ_query_param_absolute_time (&eol),
+ GNUNET_PQ_query_param_timestamp (&eol),
GNUNET_PQ_query_param_end
};
- GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
- eol.abs_value_us);
+ GNUNET_break (! GNUNET_TIME_absolute_is_never (eol.abs_time));
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_insert",
params);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Created new account %s with expiration %s\n",
TALER_B2S (account_pub),
- GNUNET_STRINGS_absolute_time_to_string (eol));
+ GNUNET_TIME_timestamp2s (eol));
}
break;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
{
/* user exists, update expiration_date */
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_absolute_time (&expiration),
+ GNUNET_PQ_query_param_timestamp (&expiration),
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_end
};
- expiration = GNUNET_TIME_absolute_max (expiration,
- eol);
- GNUNET_break (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us !=
- expiration.abs_value_us);
+ expiration = GNUNET_TIME_timestamp_max (expiration,
+ eol);
+ GNUNET_break (! GNUNET_TIME_absolute_is_never (expiration.abs_time));
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"user_update",
params);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Updated account %s to new expiration %s\n",
TALER_B2S (account_pub),
- GNUNET_STRINGS_absolute_time_to_string (expiration));
+ GNUNET_TIME_timestamp2s (expiration));
}
break;
}
@@ -1397,14 +1389,15 @@ postgres_record_recdoc_payment (
const struct TALER_Amount *amount)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- struct GNUNET_TIME_Absolute expiration;
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
+ struct GNUNET_TIME_Timestamp expiration;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
GNUNET_PQ_query_param_uint32 (&post_counter),
- TALER_PQ_query_param_amount (amount),
+ TALER_PQ_query_param_amount (pg->conn,
+ amount),
GNUNET_PQ_query_param_auto_from_type (payment_secret),
- GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -1421,8 +1414,8 @@ postgres_record_recdoc_payment (
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("expiration_date",
- &expiration),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ &expiration),
GNUNET_PQ_result_spec_end
};
@@ -1441,11 +1434,11 @@ postgres_record_recdoc_payment (
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
{
/* create new user with short lifetime */
- struct GNUNET_TIME_Absolute exp
- = GNUNET_TIME_relative_to_absolute (TRANSIENT_LIFETIME);
+ struct GNUNET_TIME_Timestamp exp
+ = GNUNET_TIME_relative_to_timestamp (TRANSIENT_LIFETIME);
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (account_pub),
- GNUNET_PQ_query_param_absolute_time (&exp),
+ GNUNET_PQ_query_param_timestamp (&exp),
GNUNET_PQ_query_param_end
};
@@ -1467,7 +1460,7 @@ postgres_record_recdoc_payment (
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Created new account %s with transient life until %s\n",
TALER_B2S (account_pub),
- GNUNET_STRINGS_absolute_time_to_string (exp));
+ GNUNET_TIME_timestamp2s (exp));
break;
}
}
@@ -1501,11 +1494,13 @@ postgres_record_truth_upload_payment (
struct GNUNET_TIME_Relative duration)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute exp = GNUNET_TIME_relative_to_absolute (duration);
+ struct GNUNET_TIME_Timestamp exp = GNUNET_TIME_relative_to_timestamp (
+ duration);
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (uuid),
- TALER_PQ_query_param_amount (amount),
- GNUNET_PQ_query_param_absolute_time (&exp),
+ TALER_PQ_query_param_amount (pg->conn,
+ amount),
+ GNUNET_PQ_query_param_timestamp (&exp),
GNUNET_PQ_query_param_end
};
@@ -1528,18 +1523,18 @@ static enum GNUNET_DB_QueryStatus
postgres_check_truth_upload_paid (
void *cls,
const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid,
- struct GNUNET_TIME_Absolute *paid_until)
+ struct GNUNET_TIME_Timestamp *paid_until)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (uuid),
- GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("expiration",
- paid_until),
+ GNUNET_PQ_result_spec_timestamp ("expiration",
+ paid_until),
GNUNET_PQ_result_spec_end
};
@@ -1568,12 +1563,13 @@ postgres_record_challenge_payment (
const struct TALER_Amount *amount)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
- TALER_PQ_query_param_amount (amount),
+ TALER_PQ_query_param_amount (pg->conn,
+ amount),
GNUNET_PQ_query_param_auto_from_type (payment_secret),
- GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
@@ -1632,16 +1628,17 @@ postgres_record_auth_iban_payment (
const struct TALER_Amount *amount,
const char *debit_account,
const char *credit_account,
- struct GNUNET_TIME_Absolute execution_date)
+ struct GNUNET_TIME_Timestamp execution_date)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&wire_reference),
GNUNET_PQ_query_param_string (wire_subject),
- TALER_PQ_query_param_amount (amount),
+ TALER_PQ_query_param_amount (pg->conn,
+ amount),
GNUNET_PQ_query_param_string (debit_account),
GNUNET_PQ_query_param_string (credit_account),
- GNUNET_PQ_query_param_absolute_time (&execution_date),
+ GNUNET_PQ_query_param_timestamp (&execution_date),
GNUNET_PQ_query_param_end
};
@@ -1751,7 +1748,7 @@ static enum GNUNET_DB_QueryStatus
postgres_test_auth_iban_payment (
void *cls,
const char *debit_account,
- struct GNUNET_TIME_Absolute earliest_date,
+ struct GNUNET_TIME_Timestamp earliest_date,
ANASTASIS_DB_AuthIbanTransfercheck cb,
void *cb_cls)
{
@@ -1763,7 +1760,7 @@ postgres_test_auth_iban_payment (
};
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_string (debit_account),
- TALER_PQ_query_param_absolute_time (&earliest_date),
+ GNUNET_PQ_query_param_timestamp (&earliest_date),
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -1934,7 +1931,7 @@ postgres_store_truth (
struct GNUNET_TIME_Relative truth_expiration)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute expiration = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Timestamp expiration;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
GNUNET_PQ_query_param_auto_from_type (key_share_data),
@@ -1942,14 +1939,12 @@ postgres_store_truth (
GNUNET_PQ_query_param_fixed_size (encrypted_truth,
encrypted_truth_size),
GNUNET_PQ_query_param_string (mime_type),
- TALER_PQ_query_param_absolute_time (&expiration),
+ GNUNET_PQ_query_param_timestamp (&expiration),
GNUNET_PQ_query_param_end
};
- expiration = GNUNET_TIME_absolute_add (expiration,
- truth_expiration);
- GNUNET_TIME_round_abs (&expiration);
+ expiration = GNUNET_TIME_relative_to_timestamp (truth_expiration);
check_connection (pg);
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"truth_insert",
@@ -2049,7 +2044,7 @@ enum ANASTASIS_DB_AccountStatus
postgres_lookup_account (
void *cls,
const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
- struct GNUNET_TIME_Absolute *paid_until,
+ struct GNUNET_TIME_Timestamp *paid_until,
struct GNUNET_HashCode *recovery_data_hash,
uint32_t *version)
{
@@ -2065,8 +2060,8 @@ postgres_lookup_account (
postgres_preflight (pg));
{
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("expiration_date",
- paid_until),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ paid_until),
GNUNET_PQ_result_spec_auto_from_type ("recovery_data_hash",
recovery_data_hash),
GNUNET_PQ_result_spec_uint32 ("version",
@@ -2095,8 +2090,8 @@ postgres_lookup_account (
/* check if account exists */
{
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_absolute_time ("expiration_date",
- paid_until),
+ GNUNET_PQ_result_spec_timestamp ("expiration_date",
+ paid_until),
GNUNET_PQ_result_spec_end
};
@@ -2180,6 +2175,129 @@ postgres_get_latest_recovery_document (
/**
+ * Closure for meta_iterator().
+ */
+struct MetaIteratorContext
+{
+ /**
+ * Function to call on each result.
+ */
+ ANASTASIS_DB_RecoveryMetaCallback cb;
+
+ /**
+ * Closure for @e cb.
+ */
+ void *cb_cls;
+
+ /**
+ * Set to true on database failure.
+ */
+ bool db_failure;
+};
+
+
+/**
+ * Helper function for #postgres_get_recovery_meta_data().
+ * To be called with the results of a SELECT statement
+ * that has returned @a num_results results.
+ *
+ * @param cls closure of type `struct MetaIteratorContext *`
+ * @param result the postgres result
+ * @param num_results the number of results in @a result
+ */
+static void
+meta_iterator (void *cls,
+ PGresult *result,
+ unsigned int num_results)
+{
+ struct MetaIteratorContext *ctx = cls;
+
+ for (unsigned int i = 0; i<num_results; i++)
+ {
+ uint32_t version;
+ void *meta_data;
+ size_t meta_data_size;
+ struct GNUNET_TIME_Timestamp ts;
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_uint32 ("version",
+ &version),
+ GNUNET_PQ_result_spec_timestamp ("creation_date",
+ &ts),
+ GNUNET_PQ_result_spec_variable_size ("recovery_meta_data",
+ &meta_data,
+ &meta_data_size),
+ GNUNET_PQ_result_spec_end
+ };
+ enum GNUNET_GenericReturnValue ret;
+
+ if (GNUNET_OK !=
+ GNUNET_PQ_extract_result (result,
+ rs,
+ i))
+ {
+ GNUNET_break (0);
+ ctx->db_failure = true;
+ return;
+ }
+ ret = ctx->cb (ctx->cb_cls,
+ version,
+ ts,
+ meta_data,
+ meta_data_size);
+ GNUNET_PQ_cleanup_result (rs);
+ if (GNUNET_OK != ret)
+ break;
+ }
+}
+
+
+/**
+ * Fetch recovery document meta data for user. Returns
+ * meta data in descending order from @a max_version.
+ * The size of the result set may be limited.
+ *
+ * @param cls closure
+ * @param account_pub public key of the user's account
+ * @param max_version the maximum version number the user requests
+ * @param cb function to call on each result
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_get_recovery_meta_data (
+ void *cls,
+ const struct ANASTASIS_CRYPTO_AccountPublicKeyP *account_pub,
+ uint32_t max_version,
+ ANASTASIS_DB_RecoveryMetaCallback cb,
+ void *cb_cls)
+{
+ struct PostgresClosure *pg = cls;
+ struct MetaIteratorContext ctx = {
+ .cb = cb,
+ .cb_cls = cb_cls
+ };
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (account_pub),
+ GNUNET_PQ_query_param_uint32 (&max_version),
+ GNUNET_PQ_query_param_end
+ };
+ enum GNUNET_DB_QueryStatus qs;
+
+ check_connection (pg);
+ qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
+ "recoverydocument_select_meta",
+ params,
+ &meta_iterator,
+ &ctx);
+ if (qs < 0)
+ return qs;
+ if (ctx.db_failure)
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ return qs;
+}
+
+
+/**
* Fetch recovery document for user according given version.
*
* @param cls closure
@@ -2307,6 +2425,10 @@ check_valid_code (void *cls,
cvc->db_failure = true;
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Found issued challenge %llu (client: %s)\n",
+ (unsigned long long) server_code,
+ GNUNET_h2s (cvc->hashed_code));
{
struct GNUNET_HashCode shashed_code;
@@ -2316,6 +2438,9 @@ check_valid_code (void *cls,
GNUNET_memcmp (&shashed_code,
cvc->hashed_code))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Challenge is valid challenge (%s)\n",
+ (0 != sat) ? "satisfied" : "not satisfied");
cvc->valid = true;
cvc->code = server_code;
cvc->satisfied = (0 != sat);
@@ -2370,17 +2495,16 @@ postgres_verify_challenge_code (
.hashed_code = hashed_code,
.pg = pg
};
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
- TALER_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
*satisfied = false;
check_connection (pg);
- GNUNET_TIME_round_abs (&now);
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"challengecode_select",
params,
@@ -2445,13 +2569,13 @@ postgres_test_challenge_code_satisfied (
void *cls,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
const uint64_t code,
- struct GNUNET_TIME_Absolute after)
+ struct GNUNET_TIME_Timestamp after)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
GNUNET_PQ_query_param_uint64 (&code),
- GNUNET_PQ_query_param_absolute_time (&after),
+ GNUNET_PQ_query_param_timestamp (&after),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -2481,12 +2605,13 @@ postgres_lookup_challenge_payment (
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- struct GNUNET_TIME_Absolute recent
- = GNUNET_TIME_absolute_subtract (now,
- ANASTASIS_CHALLENGE_OFFER_LIFETIME);
+ struct GNUNET_TIME_Timestamp recent
+ = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_absolute_subtract (now,
+ ANASTASIS_CHALLENGE_OFFER_LIFETIME));
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
- GNUNET_PQ_query_param_absolute_time (&recent),
+ GNUNET_PQ_query_param_timestamp (&recent),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -2553,20 +2678,18 @@ postgres_create_challenge_code (
struct GNUNET_TIME_Relative rotation_period,
struct GNUNET_TIME_Relative validity_period,
uint32_t retry_counter,
- struct GNUNET_TIME_Absolute *retransmission_date,
+ struct GNUNET_TIME_Timestamp *retransmission_date,
uint64_t *code)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- struct GNUNET_TIME_Absolute expiration_date;
+ struct GNUNET_TIME_Timestamp now = GNUNET_TIME_timestamp_get ();
+ struct GNUNET_TIME_Timestamp expiration_date;
struct GNUNET_TIME_Absolute ex_rot;
check_connection (pg);
- GNUNET_TIME_round_abs (&now);
- expiration_date = GNUNET_TIME_absolute_add (now,
- validity_period);
- ex_rot = GNUNET_TIME_absolute_subtract (now,
+ expiration_date = GNUNET_TIME_relative_to_timestamp (validity_period);
+ ex_rot = GNUNET_TIME_absolute_subtract (now.abs_time,
rotation_period);
for (unsigned int retries = 0; retries<MAX_RETRIES; retries++)
{
@@ -2582,8 +2705,8 @@ postgres_create_challenge_code (
uint32_t old_retry_counter;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
- TALER_PQ_query_param_absolute_time (&now),
- TALER_PQ_query_param_absolute_time (&ex_rot),
+ GNUNET_PQ_query_param_timestamp (&now),
+ GNUNET_PQ_query_param_absolute_time (&ex_rot),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -2591,8 +2714,8 @@ postgres_create_challenge_code (
code),
GNUNET_PQ_result_spec_uint32 ("retry_counter",
&old_retry_counter),
- GNUNET_PQ_result_spec_absolute_time ("retransmission_date",
- retransmission_date),
+ GNUNET_PQ_result_spec_timestamp ("retransmission_date",
+ retransmission_date),
GNUNET_PQ_result_spec_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -2619,26 +2742,27 @@ postgres_create_challenge_code (
rollback (pg);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Active challenge %llu has zero tries left, refusing to create another one\n",
- (unsigned long long) code);
+ (unsigned long long) *code);
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
rollback (pg);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Active challenge has %u tries left, returning old challenge\n",
- (unsigned int) old_retry_counter);
+ "Active challenge has %u tries left, returning old challenge %llu\n",
+ (unsigned int) old_retry_counter,
+ (unsigned long long) *code);
return qs;
}
}
*code = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_NONCE,
- NONCE_MAX_VALUE);
- *retransmission_date = GNUNET_TIME_UNIT_ZERO_ABS;
+ ANASTASIS_PIN_MAX_VALUE);
+ *retransmission_date = GNUNET_TIME_UNIT_ZERO_TS;
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
GNUNET_PQ_query_param_uint64 (code),
- TALER_PQ_query_param_absolute_time (&now),
- TALER_PQ_query_param_absolute_time (&expiration_date),
+ GNUNET_PQ_query_param_timestamp (&now),
+ GNUNET_PQ_query_param_timestamp (&expiration_date),
GNUNET_PQ_query_param_uint32 (&retry_counter),
GNUNET_PQ_query_param_end
};
@@ -2697,22 +2821,24 @@ postgres_mark_challenge_sent (
check_connection (pg);
{
- struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Timestamp now;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
GNUNET_PQ_query_param_uint64 (&code),
- TALER_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_timestamp (&now),
GNUNET_PQ_query_param_end
};
- now = GNUNET_TIME_absolute_get ();
- GNUNET_TIME_round_abs (&now);
+ now = GNUNET_TIME_timestamp_get ();
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
"challengecode_mark_sent",
params);
if (qs <= 0)
return qs;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Marking challenge %llu as issued\n",
+ (unsigned long long) code);
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (truth_uuid),
@@ -2739,9 +2865,9 @@ enum GNUNET_DB_QueryStatus
postgres_challenge_gc (void *cls)
{
struct PostgresClosure *pg = cls;
- struct GNUNET_TIME_Absolute time_now = GNUNET_TIME_absolute_get ();
+ struct GNUNET_TIME_Timestamp time_now = GNUNET_TIME_timestamp_get ();
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_absolute_time (&time_now),
+ GNUNET_PQ_query_param_timestamp (&time_now),
GNUNET_PQ_query_param_end
};
@@ -2784,7 +2910,8 @@ libanastasis_plugin_db_postgres_init (void *cls)
}
plugin = GNUNET_new (struct ANASTASIS_DatabasePlugin);
plugin->cls = pg;
- plugin->connect = &postgres_connect;
+ /* FIXME: Should this be the same? */
+ plugin->connect = &postgres_preflight;
plugin->create_tables = &postgres_create_tables;
plugin->drop_tables = &postgres_drop_tables;
plugin->gc = &postgres_gc;
@@ -2800,6 +2927,7 @@ libanastasis_plugin_db_postgres_init (void *cls)
plugin->get_escrow_challenge = &postgres_get_escrow_challenge;
plugin->get_key_share = &postgres_get_key_share;
plugin->get_latest_recovery_document = &postgres_get_latest_recovery_document;
+ plugin->get_recovery_meta_data = &postgres_get_recovery_meta_data;
plugin->get_recovery_document = &postgres_get_recovery_document;
plugin->lookup_account = &postgres_lookup_account;
plugin->check_payment_identifier = &postgres_check_payment_identifier;
diff --git a/src/stasis/stasis-0001.sql b/src/stasis/stasis-0001.sql
index de2762a..fe08cdc 100644
--- a/src/stasis/stasis-0001.sql
+++ b/src/stasis/stasis-0001.sql
@@ -1,6 +1,6 @@
--
-- This file is part of Anastasis
--- Copyright (C) 2020, 2021 Anastasis SARL SA
+-- Copyright (C) 2020, 2021, 2022, 2023 Anastasis SARL SA
--
-- ANASTASIS 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
@@ -20,20 +20,31 @@ BEGIN;
-- Check patch versioning is in place.
SELECT _v.register_patch('stasis-0001', NULL, NULL);
+CREATE SCHEMA anastasis;
+COMMENT ON SCHEMA anastasis IS 'anastasis backend data';
+
+SET search_path TO anastasis;
+
+
+CREATE TYPE taler_amount
+ AS
+ (val INT8
+ ,frac INT4
+ );
+COMMENT ON TYPE taler_amount
+ IS 'Stores an amount, fraction is in units of 1/100000000 of the base value';
+
CREATE TABLE IF NOT EXISTS anastasis_truth_payment
(truth_uuid BYTEA PRIMARY KEY CHECK(LENGTH(truth_uuid)=32),
- amount_val INT8 NOT NULL,
- amount_frac INT4 NOT NULL,
+ amount taler_amount NOT NULL,
expiration INT8 NOT NULL);
COMMENT ON TABLE anastasis_truth_payment
IS 'Records about payments for truth uploads';
COMMENT ON COLUMN anastasis_truth_payment.truth_uuid
IS 'Identifier of the truth';
-COMMENT ON COLUMN anastasis_truth_payment.amount_val
+COMMENT ON COLUMN anastasis_truth_payment.amount
IS 'Amount we were paid';
-COMMENT ON COLUMN anastasis_truth_payment.amount_frac
- IS 'Amount we were paid fraction';
COMMENT ON COLUMN anastasis_truth_payment.expiration
IS 'At which date will the truth payment expire';
@@ -41,9 +52,9 @@ COMMENT ON COLUMN anastasis_truth_payment.expiration
CREATE TABLE IF NOT EXISTS anastasis_truth
(truth_uuid BYTEA PRIMARY KEY CHECK(LENGTH(truth_uuid)=32),
key_share_data BYTEA CHECK(LENGTH(key_share_data)=72) NOT NULL,
- method_name VARCHAR NOT NULL,
+ method_name TEXT NOT NULL,
encrypted_truth BYTEA NOT NULL,
- truth_mime VARCHAR NOT NULL,
+ truth_mime TEXT NOT NULL,
expiration INT8 NOT NULL);
COMMENT ON TABLE anastasis_truth
IS 'Truth data is needed to authenticate clients during recovery';
@@ -73,11 +84,10 @@ COMMENT ON COLUMN anastasis_user.expiration_date
CREATE TABLE IF NOT EXISTS anastasis_recdoc_payment
- (payment_id BIGSERIAL PRIMARY KEY,
+ (payment_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
user_id BYTEA NOT NULL REFERENCES anastasis_user(user_id),
post_counter INT4 NOT NULL DEFAULT 0 CHECK(post_counter >= 0),
- amount_val INT8 NOT NULL,
- amount_frac INT4 NOT NULL,
+ amount taler_amount NOT NULL,
payment_identifier BYTEA NOT NULL CHECK(LENGTH(payment_identifier)=32),
creation_date INT8 NOT NULL,
paid BOOLEAN NOT NULL DEFAULT FALSE);
@@ -89,10 +99,8 @@ COMMENT ON COLUMN anastasis_recdoc_payment.user_id
IS 'Link to the corresponding user who paid';
COMMENT ON COLUMN anastasis_recdoc_payment.post_counter
IS 'For how many posts does the user pay';
-COMMENT ON COLUMN anastasis_recdoc_payment.amount_val
+COMMENT ON COLUMN anastasis_recdoc_payment.amount
IS 'Amount we were paid';
-COMMENT ON COLUMN anastasis_recdoc_payment.amount_frac
- IS 'Amount we were paid fraction';
COMMENT ON COLUMN anastasis_recdoc_payment.payment_identifier
IS 'Payment identifier which the user has to provide';
COMMENT ON COLUMN anastasis_recdoc_payment.creation_date
@@ -102,10 +110,9 @@ COMMENT ON COLUMN anastasis_recdoc_payment.paid
CREATE TABLE IF NOT EXISTS anastasis_challenge_payment
- (payment_id BIGSERIAL PRIMARY KEY,
+ (payment_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
truth_uuid BYTEA CHECK(LENGTH(truth_uuid)=32) NOT NULL,
- amount_val INT8 NOT NULL,
- amount_frac INT4 NOT NULL,
+ amount taler_amount NOT NULL,
payment_identifier BYTEA NOT NULL CHECK(LENGTH(payment_identifier)=32),
creation_date INT8 NOT NULL,
counter INT4 NOT NULL DEFAULT 3,
@@ -118,10 +125,8 @@ COMMENT ON COLUMN anastasis_challenge_payment.payment_id
IS 'Serial number which identifies the payment';
COMMENT ON COLUMN anastasis_challenge_payment.truth_uuid
IS 'Link to the corresponding challenge which is paid';
-COMMENT ON COLUMN anastasis_challenge_payment.amount_val
+COMMENT ON COLUMN anastasis_challenge_payment.amount
IS 'Amount we were paid';
-COMMENT ON COLUMN anastasis_challenge_payment.amount_frac
- IS 'Amount we were paid fraction';
COMMENT ON COLUMN anastasis_challenge_payment.payment_identifier
IS 'Payment identifier which the user has to provide';
COMMENT ON COLUMN anastasis_challenge_payment.counter
@@ -140,6 +145,8 @@ CREATE TABLE IF NOT EXISTS anastasis_recoverydocument
account_sig BYTEA NOT NULL CHECK(LENGTH(account_sig)=64),
recovery_data_hash BYTEA NOT NULL CHECK(length(recovery_data_hash)=64),
recovery_data BYTEA NOT NULL,
+ recovery_meta_data BYTEA NOT NULL,
+ creation_date INT8 NOT NULL,
PRIMARY KEY (user_id, version));
COMMENT ON TABLE anastasis_recoverydocument
IS 'Stores a recovery document which contains the policy and the encrypted core secret';
@@ -151,8 +158,12 @@ COMMENT ON COLUMN anastasis_recoverydocument.account_sig
IS 'Signature of the recovery document';
COMMENT ON COLUMN anastasis_recoverydocument.recovery_data_hash
IS 'Hash of the recovery document to prevent unnecessary uploads';
+COMMENT ON COLUMN anastasis_recoverydocument.creation_date
+ IS 'Creation date of the recovery document (when it was uploaded)';
COMMENT ON COLUMN anastasis_recoverydocument.recovery_data
IS 'Contains the encrypted policy and core secret';
+COMMENT ON COLUMN anastasis_recoverydocument.recovery_meta_data
+ IS 'Contains an encrypted human-readable and sometimes user-generated description of the backup';
CREATE TABLE IF NOT EXISTS anastasis_challengecode
@@ -194,11 +205,10 @@ COMMENT ON INDEX anastasis_challengecode_expiration_index
CREATE TABLE IF NOT EXISTS anastasis_auth_iban_in
- (auth_in_serial_id BIGSERIAL UNIQUE
+ (auth_in_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
,wire_reference INT8 NOT NULL PRIMARY KEY
,wire_subject TEXT NOT NULL
- ,credit_val INT8 NOT NULL
- ,credit_frac INT4 NOT NULL
+ ,credit taler_amount NOT NULL
,debit_account_details TEXT NOT NULL
,credit_account_details TEXT NOT NULL
,execution_date INT8 NOT NULL
@@ -209,6 +219,8 @@ COMMENT ON COLUMN anastasis_auth_iban_in.wire_reference
IS 'Unique number identifying the wire transfer in LibEuFin/Nexus';
COMMENT ON COLUMN anastasis_auth_iban_in.wire_subject
IS 'For authentication, this contains the code, but also additional text';
+COMMENT ON COLUMN anastasis_auth_iban_in.credit
+ IS 'Amount we were credited';
COMMENT ON COLUMN anastasis_auth_iban_in.execution_date
IS 'Used both for (theoretical) garbage collection and to see if the transfer happened on time';
COMMENT ON COLUMN anastasis_auth_iban_in.credit_account_details
diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c
index 1ec9770..5ad29bc 100644
--- a/src/stasis/test_anastasis_db.c
+++ b/src/stasis/test_anastasis_db.c
@@ -3,7 +3,7 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -151,7 +151,7 @@ run (void *cls)
&paymentSecretP,
&amount));
{
- struct GNUNET_TIME_Absolute res_time;
+ struct GNUNET_TIME_Timestamp res_time;
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->increment_lifetime (plugin->cls,
@@ -192,11 +192,13 @@ run (void *cls)
&recoveryDataHash,
recovery_data,
strlen (recovery_data),
+ "meta-data",
+ strlen ("meta-data"),
&paymentSecretP,
&docVersion));
{
uint32_t vrs;
- struct GNUNET_TIME_Absolute exp;
+ struct GNUNET_TIME_Timestamp exp;
FAILIF (ANASTASIS_DB_ACCOUNT_STATUS_VALID_HASH_RETURNED !=
plugin->lookup_account (plugin->cls,
@@ -240,7 +242,7 @@ run (void *cls)
GNUNET_free (res_recovery_data);
{
- struct GNUNET_TIME_Absolute rt;
+ struct GNUNET_TIME_Timestamp rt;
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->create_challenge_code (plugin->cls,
@@ -250,10 +252,10 @@ run (void *cls)
3, /* retry counter */
&rt,
&challenge_code));
- FAILIF (0 != rt.abs_value_us);
+ FAILIF (! GNUNET_TIME_absolute_is_zero (rt.abs_time));
}
{
- struct GNUNET_TIME_Absolute rt;
+ struct GNUNET_TIME_Timestamp rt;
uint64_t c2;
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
diff --git a/src/stasis/stasis-0000.sql b/src/stasis/versioning.sql
index 116f409..444cf95 100644
--- a/src/stasis/stasis-0000.sql
+++ b/src/stasis/versioning.sql
@@ -146,12 +146,13 @@
BEGIN;
+
-- This file adds versioning support to database it will be loaded to.
-- It requires that PL/pgSQL is already loaded - will raise exception otherwise.
-- All versioning "stuff" (tables, functions) is in "_v" schema.
-- All functions are defined as 'RETURNS SETOF INT4' to be able to make them to RETURN literally nothing (0 rows).
--- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling.
+-- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql when calling
CREATE SCHEMA IF NOT EXISTS _v;
COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.';
diff --git a/src/testing/.gitignore b/src/testing/.gitignore
index a6eb294..9ac5ba4 100644
--- a/src/testing/.gitignore
+++ b/src/testing/.gitignore
@@ -1,3 +1,6 @@
test_anastasis
test_anastasisrest_api
-test_anastasis_api_home/.local/share/taler/crypto-*
+test_anastasis_api_home/taler/exchange-secmod-*
+test_anastasis_api_home/taler/auditor/
+test_anastasis_api_home/taler/exchange/offline-keys/secm_tofus.pub
+test_anastasis_api.conf.edited
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 8fc710b..22162d3 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -14,29 +14,18 @@ libanastasistesting_la_LDFLAGS = \
-no-undefined
libanastasistesting_la_SOURCES = \
testing_api_cmd_policy_store.c \
+ testing_api_cmd_truth_challenge.c \
+ testing_api_cmd_truth_solve.c \
testing_api_cmd_truth_store.c \
testing_api_cmd_policy_lookup.c \
- testing_api_cmd_keyshare_lookup.c \
testing_api_cmd_config.c \
testing_api_helpers.c \
- testing_api_trait_account_pub.c \
- testing_api_trait_account_priv.c \
- testing_api_trait_eks.c \
- testing_api_trait_payment_secret.c \
- testing_api_trait_truth_key.c \
- testing_api_trait_truth_uuid.c \
- testing_api_trait_hash.c \
- testing_api_trait_salt.c \
- testing_api_trait_code.c \
+ testing_api_traits.c \
testing_cmd_truth_upload.c \
testing_cmd_policy_create.c \
testing_cmd_secret_share.c \
testing_cmd_recover_secret.c \
- testing_cmd_challenge_answer.c \
- testing_trait_truth.c \
- testing_trait_policy.c \
- testing_trait_core_secret.c \
- testing_trait_challenge.c
+ testing_cmd_challenge_answer.c
libanastasistesting_la_LIBADD = \
$(top_builddir)/src/restclient/libanastasisrest.la \
$(top_builddir)/src/lib/libanastasis.la \
@@ -49,7 +38,6 @@ libanastasistesting_la_LIBADD = \
-lgnunetjson \
-lgnunetutil \
-ljansson \
- -luuid \
-ltalertesting \
$(XLIB)
@@ -83,9 +71,8 @@ test_anastasis_LDADD = \
EXTRA_DIST = \
test_anastasis_api.conf \
- test_anastasis_api_home/.config/taler/exchange/account-2.json \
- test_anastasis_api_home/.local/share/taler/exchange/offline-keys/master.priv \
+ test_anastasis_api_home/taler/exchange/offline-keys/master.priv \
sms_authentication.sh
MOSTLYCLEANFILES = \
- test_anastasis_api_home/.local/share/taler/exchange/offline-keys/secm_tofus.pub
+ test_anastasis_api_home/taler/exchange/offline-keys/secm_tofus.pub
diff --git a/src/testing/test_anastasis.c b/src/testing/test_anastasis.c
index f821f20..f28d9a9 100644
--- a/src/testing/test_anastasis.c
+++ b/src/testing/test_anastasis.c
@@ -1,16 +1,16 @@
/*
This file is part of Anastasis
- Copyright (C) 2020, 2021 Anastasis SARL
+ Copyright (C) 2020-2023 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -52,34 +52,29 @@
#define MERCHANT_ACCOUNT_NAME "3"
/**
- * Configuration of the bank.
+ * Credentials for the test.
*/
-static struct TALER_TESTING_BankConfiguration bc;
-
-/**
- * Configuration of the exchange.
- */
-static struct TALER_TESTING_ExchangeConfiguration ec;
+static struct TALER_TESTING_Credentials cred;
/**
* Payto URI of the customer (payer).
*/
-static char *payer_payto;
+static const char *payer_payto;
/**
* Payto URI of the exchange (escrow account).
*/
-static char *exchange_payto;
+static const char *exchange_payto;
/**
* Payto URI of the merchant (receiver).
*/
-static char *merchant_payto;
+static const char *merchant_payto;
/**
* Merchant base URL.
*/
-static char *merchant_url;
+static const char *merchant_url;
/**
* Anastasis base URL.
@@ -92,11 +87,6 @@ static char *anastasis_url;
static char *file_secret;
/**
- * Merchant process.
- */
-static struct GNUNET_OS_Process *merchantd;
-
-/**
* Anastasis process.
*/
static struct GNUNET_OS_Process *anastasisd;
@@ -135,7 +125,7 @@ cmd_transfer_to_exchange (const char *label,
{
return TALER_TESTING_cmd_admin_add_incoming (label,
amount,
- &bc.exchange_auth,
+ &cred.ba,
payer_payto);
}
@@ -164,10 +154,12 @@ run (void *cls,
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
"create-reserve-1",
"EUR:5",
+ 0, /* age */
MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
"create-reserve-1",
"EUR:5",
+ 0, /* age */
MHD_HTTP_OK),
/**
* Check the reserve is depleted.
@@ -278,7 +270,7 @@ run (void *cls,
0, /* challenge index */
"SomeTruth1",
0, /* mode */
- ANASTASIS_CHALLENGE_STATUS_SOLVED),
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED),
#if 0
ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-2",
NULL, /* payment ref */
@@ -286,13 +278,13 @@ run (void *cls,
1, /* challenge index */
"SomeTruth2",
0, /* mode */
- ANASTASIS_CHALLENGE_STATUS_SOLVED),
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED),
#endif
ANASTASIS_TESTING_cmd_challenge_start ("challenge-start-3-pay",
NULL, /* payment ref */
"recover-secret-1",
2, /* challenge index */
- ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED),
+ ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED),
TALER_TESTING_cmd_merchant_claim_order ("fetch-challenge-pay-proposal",
merchant_url,
MHD_HTTP_OK,
@@ -310,14 +302,14 @@ run (void *cls,
"challenge-start-3-pay", /* payment ref */
"recover-secret-1",
2, /* challenge index */
- ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS),
+ ANASTASIS_CHALLENGE_START_STATUS_FILENAME_PROVIDED),
ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-3",
"challenge-start-3-pay", /* payment ref */
"recover-secret-1",
2, /* challenge index */
"challenge-start-3-paid", /* answer */
1, /* mode */
- ANASTASIS_CHALLENGE_STATUS_SOLVED),
+ ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED),
ANASTASIS_TESTING_cmd_recover_secret_finish ("recover-finish-1",
"recover-secret-1",
GNUNET_TIME_UNIT_SECONDS),
@@ -326,27 +318,29 @@ run (void *cls,
struct TALER_TESTING_Command commands[] = {
/* general setup */
- TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
- MHD_HTTP_NO_CONTENT,
- false),
- TALER_TESTING_cmd_wire_add ("add-wire-account",
- "payto://x-taler-bank/localhost/2",
- MHD_HTTP_NO_CONTENT,
- false),
- TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
- CONFIG_FILE),
- TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
- CONFIG_FILE,
- "EUR:0.01",
- "EUR:0.01"),
- TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
- 1),
+ TALER_TESTING_cmd_run_fakebank ("run-fakebank",
+ cred.cfg,
+ "exchange-account-exchange"),
+ TALER_TESTING_cmd_system_start ("start-taler",
+ CONFIG_FILE,
+ "-em",
+ "-u", "exchange-account-exchange",
+ NULL),
+ TALER_TESTING_cmd_get_exchange ("get-exchange",
+ cred.cfg,
+ NULL,
+ true,
+ true),
TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
merchant_url,
"default",
- merchant_payto,
- "EUR",
MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_post_account (
+ "instance-create-default-account",
+ merchant_url,
+ merchant_payto,
+ NULL, NULL,
+ MHD_HTTP_OK),
TALER_TESTING_cmd_batch ("pay",
pay),
TALER_TESTING_cmd_batch ("anastasis",
@@ -354,9 +348,8 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
- TALER_TESTING_run_with_fakebank (is,
- commands,
- bc.exchange_auth.wire_gateway_url);
+ TALER_TESTING_run (is,
+ commands);
}
@@ -364,19 +357,7 @@ int
main (int argc,
char *const *argv)
{
- unsigned int ret;
- /* These environment variables get in the way... */
- unsetenv ("XDG_DATA_HOME");
- unsetenv ("XDG_CONFIG_HOME");
-
- GNUNET_log_setup ("test-anastasis",
- "DEBUG",
- NULL);
- if (GNUNET_OK !=
- TALER_TESTING_prepare_fakebank (CONFIG_FILE,
- "exchange-account-exchange",
- &bc))
- return 77;
+ int ret;
{
char dir[] = "/tmp/test-anastasis-file-XXXXXX";
@@ -391,73 +372,42 @@ main (int argc,
"%s/.secret",
dir);
}
- id_data = ANASTASIS_TESTING_make_id_data_example (
- "MaxMuster123456789");
- payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME);
- exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME);
- merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME);
- if (NULL ==
- (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
- return 77;
- TALER_TESTING_cleanup_files (CONFIG_FILE);
+ id_data = ANASTASIS_TESTING_make_id_data_example ("MaxMuster123456789");
+ payer_payto =
+ "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME
+ "?receiver-name=62";
+ exchange_payto =
+ "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME
+ "?receiver-name=exchange";
+ merchant_payto =
+ "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME
+ "?receiver-name=merchant";
+ merchant_url = "http://localhost:8080/";
if (NULL ==
(anastasis_url = ANASTASIS_TESTING_prepare_anastasis (CONFIG_FILE)))
return 77;
- TALER_TESTING_cleanup_files (CONFIG_FILE);
-
- switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
- GNUNET_YES,
- &ec))
+ if (NULL == (anastasisd =
+ ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
+ anastasis_url)))
{
- case GNUNET_SYSERR:
- GNUNET_break (0);
- return 1;
- case GNUNET_NO:
- return 77;
- case GNUNET_OK:
- if (NULL == (merchantd =
- TALER_TESTING_run_merchant (CONFIG_FILE,
- merchant_url)))
- {
- GNUNET_break (0);
- return 1;
- }
- if (NULL == (anastasisd =
- ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
- anastasis_url)))
- {
- GNUNET_break (0);
- GNUNET_OS_process_kill (merchantd,
- SIGTERM);
- GNUNET_OS_process_wait (merchantd);
- GNUNET_OS_process_destroy (merchantd);
-
- return 1;
- }
- ret = TALER_TESTING_setup_with_exchange (&run,
- NULL,
- CONFIG_FILE);
-
- GNUNET_OS_process_kill (merchantd,
- SIGTERM);
- GNUNET_OS_process_kill (anastasisd,
- SIGTERM);
- GNUNET_OS_process_wait (merchantd);
- GNUNET_OS_process_wait (anastasisd);
- GNUNET_OS_process_destroy (merchantd);
- GNUNET_OS_process_destroy (anastasisd);
- GNUNET_free (merchant_url);
- GNUNET_free (anastasis_url);
-
- if (GNUNET_OK != ret)
- return 1;
- break;
- default:
GNUNET_break (0);
return 1;
}
- return 0;
+ ret = TALER_TESTING_main (argv,
+ "INFO",
+ CONFIG_FILE,
+ "exchange-account-exchange",
+ TALER_TESTING_BS_FAKEBANK,
+ &cred,
+ &run,
+ NULL);
+ GNUNET_OS_process_kill (anastasisd,
+ SIGTERM);
+ GNUNET_OS_process_wait (anastasisd);
+ GNUNET_OS_process_destroy (anastasisd);
+ GNUNET_free (anastasis_url);
+ return ret;
}
diff --git a/src/testing/test_anastasis_api.c b/src/testing/test_anastasis_api.c
index 2767264..7d7e2ac 100644
--- a/src/testing/test_anastasis_api.c
+++ b/src/testing/test_anastasis_api.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -52,34 +52,29 @@
#define MERCHANT_ACCOUNT_NAME "3"
/**
- * Configuration of the bank.
+ * Test credentials.
*/
-static struct TALER_TESTING_BankConfiguration bc;
-
-/**
- * Configuration of the exchange.
- */
-static struct TALER_TESTING_ExchangeConfiguration ec;
+static struct TALER_TESTING_Credentials cred;
/**
* Payto URI of the customer (payer).
*/
-static char *payer_payto;
+static const char *payer_payto;
/**
* Payto URI of the exchange (escrow account).
*/
-static char *exchange_payto;
+static const char *exchange_payto;
/**
* Payto URI of the merchant (receiver).
*/
-static char *merchant_payto;
+static const char *merchant_payto;
/**
* Merchant base URL.
*/
-static char *merchant_url;
+static const char *merchant_url;
/**
* Anastasis base URL.
@@ -87,11 +82,6 @@ static char *merchant_url;
static char *anastasis_url;
/**
- * Merchant process.
- */
-static struct GNUNET_OS_Process *merchantd;
-
-/**
* Anastasis process.
*/
static struct GNUNET_OS_Process *anastasisd;
@@ -129,7 +119,7 @@ cmd_transfer_to_exchange (const char *label,
{
return TALER_TESTING_cmd_admin_add_incoming (label,
amount,
- &bc.exchange_auth,
+ &cred.ba,
payer_payto);
}
@@ -150,10 +140,12 @@ run (void *cls,
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-1",
"create-reserve-1",
"EUR:5",
+ 0, /* age */
MHD_HTTP_OK),
TALER_TESTING_cmd_withdraw_amount ("withdraw-coin-2",
"create-reserve-1",
"EUR:5",
+ 0, /* age */
MHD_HTTP_OK),
TALER_TESTING_cmd_status ("withdraw-status-1",
"create-reserve-1",
@@ -207,14 +199,14 @@ run (void *cls,
"The-Answer",
ANASTASIS_TESTING_TSO_NONE,
MHD_HTTP_NO_CONTENT),
- ANASTASIS_TESTING_cmd_keyshare_lookup (
+ ANASTASIS_TESTING_cmd_truth_solve (
"keyshare-lookup-1",
anastasis_url,
"The-Answer",
NULL, /* payment ref */
"truth-store-1",
0,
- ANASTASIS_KSD_SUCCESS),
+ MHD_HTTP_OK),
ANASTASIS_TESTING_cmd_truth_store (
"truth-store-2",
anastasis_url,
@@ -225,22 +217,20 @@ run (void *cls,
file_secret,
ANASTASIS_TESTING_TSO_NONE,
MHD_HTTP_NO_CONTENT),
- ANASTASIS_TESTING_cmd_keyshare_lookup (
+ ANASTASIS_TESTING_cmd_truth_solve (
"challenge-fail-1",
anastasis_url,
"Wrong-Answer",
- NULL,
- "truth-store-1",
- 0,
- ANASTASIS_KSD_INVALID_ANSWER),
- ANASTASIS_TESTING_cmd_keyshare_lookup (
+ NULL, /* payment ref */
+ "truth-store-1", /* upload ref */
+ 0, /* security question mode */
+ MHD_HTTP_FORBIDDEN),
+ ANASTASIS_TESTING_cmd_truth_challenge (
"file-challenge-run-1",
anastasis_url,
- NULL, /* no answer */
NULL, /* payment ref */
"truth-store-2", /* upload ref */
- 0,
- ANASTASIS_KSD_PAYMENT_REQUIRED),
+ MHD_HTTP_PAYMENT_REQUIRED),
/* what would we have to pay? */
TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
merchant_url,
@@ -257,48 +247,48 @@ run (void *cls,
"EUR:1",
NULL),
- ANASTASIS_TESTING_cmd_keyshare_lookup (
+ ANASTASIS_TESTING_cmd_truth_challenge (
"file-challenge-run-2",
anastasis_url,
- NULL, /* no answer */
"file-challenge-run-1", /* payment ref */
"truth-store-2",
- 0,
- ANASTASIS_KSD_INVALID_ANSWER),
- ANASTASIS_TESTING_cmd_keyshare_lookup (
+ MHD_HTTP_OK),
+ ANASTASIS_TESTING_cmd_truth_solve (
"file-challenge-run-3",
anastasis_url,
"file-challenge-run-2", /* answer */
"file-challenge-run-1", /* payment ref */
"truth-store-2",
1,
- ANASTASIS_KSD_SUCCESS),
+ MHD_HTTP_OK),
TALER_TESTING_cmd_end ()
};
struct TALER_TESTING_Command commands[] = {
/* general setup */
- TALER_TESTING_cmd_auditor_add ("add-auditor-OK",
- MHD_HTTP_NO_CONTENT,
- false),
- TALER_TESTING_cmd_wire_add ("add-wire-account",
- "payto://x-taler-bank/localhost/2",
- MHD_HTTP_NO_CONTENT,
- false),
- TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
- CONFIG_FILE),
- TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-fees",
- CONFIG_FILE,
- "EUR:0.01",
- "EUR:0.01"),
- TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
- 1),
+ TALER_TESTING_cmd_run_fakebank ("run-fakebank",
+ cred.cfg,
+ "exchange-account-exchange"),
+ TALER_TESTING_cmd_system_start ("start-taler",
+ CONFIG_FILE,
+ "-em",
+ "-u", "exchange-account-exchange",
+ NULL),
+ TALER_TESTING_cmd_get_exchange ("get-exchange",
+ cred.cfg,
+ NULL,
+ true,
+ true),
TALER_TESTING_cmd_merchant_post_instances ("instance-create-default",
merchant_url,
"default",
- merchant_payto,
- "EUR",
MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_post_account (
+ "instance-create-default-account",
+ merchant_url,
+ merchant_payto,
+ NULL, NULL,
+ MHD_HTTP_OK),
ANASTASIS_TESTING_cmd_config ("salt-request-1",
anastasis_url,
MHD_HTTP_OK),
@@ -311,9 +301,8 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
- TALER_TESTING_run_with_fakebank (is,
- commands,
- bc.exchange_auth.wire_gateway_url);
+ TALER_TESTING_run (is,
+ commands);
}
@@ -323,17 +312,6 @@ main (int argc,
{
int ret;
- /* These environment variables get in the way... */
- unsetenv ("XDG_DATA_HOME");
- unsetenv ("XDG_CONFIG_HOME");
- GNUNET_log_setup ("test-anastasis-api",
- "DEBUG",
- NULL);
- if (GNUNET_OK !=
- TALER_TESTING_prepare_fakebank (CONFIG_FILE,
- "exchange-account-exchange",
- &bc))
- return 77;
{
char dir[] = "/tmp/test-anastasis-file-XXXXXX";
@@ -348,73 +326,41 @@ main (int argc,
"%s/.secret",
dir);
}
- payer_payto = ("payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME);
- exchange_payto = ("payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME);
- merchant_payto = ("payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME);
- if (NULL ==
- (merchant_url = TALER_TESTING_prepare_merchant (CONFIG_FILE)))
- return 77;
- TALER_TESTING_cleanup_files (CONFIG_FILE);
+ payer_payto =
+ "payto://x-taler-bank/localhost/" USER_ACCOUNT_NAME
+ "?receiver-name=62";
+ exchange_payto =
+ "payto://x-taler-bank/localhost/" EXCHANGE_ACCOUNT_NAME
+ "?receiver-name=exchange";
+ merchant_payto =
+ "payto://x-taler-bank/localhost/" MERCHANT_ACCOUNT_NAME
+ "?receiver-name=merchant";
+ merchant_url = "http://localhost:8080/";
if (NULL ==
(anastasis_url = ANASTASIS_TESTING_prepare_anastasis (CONFIG_FILE)))
return 77;
- TALER_TESTING_cleanup_files (CONFIG_FILE);
-
- switch (TALER_TESTING_prepare_exchange (CONFIG_FILE,
- GNUNET_YES,
- &ec))
+ if (NULL == (anastasisd =
+ ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
+ anastasis_url)))
{
- case GNUNET_SYSERR:
- GNUNET_break (0);
- return 1;
- case GNUNET_NO:
- return 77;
- case GNUNET_OK:
- if (NULL == (merchantd =
- TALER_TESTING_run_merchant (CONFIG_FILE,
- merchant_url)))
- {
- GNUNET_break (0);
- return 1;
- }
- if (NULL == (anastasisd =
- ANASTASIS_TESTING_run_anastasis (CONFIG_FILE,
- anastasis_url)))
- {
- GNUNET_break (0);
- GNUNET_OS_process_kill (merchantd,
- SIGTERM);
- GNUNET_OS_process_wait (merchantd);
- GNUNET_OS_process_destroy (merchantd);
- return 1;
- }
- ret = TALER_TESTING_setup_with_exchange (&run,
- NULL,
- CONFIG_FILE);
- GNUNET_OS_process_kill (merchantd,
- SIGTERM);
- GNUNET_OS_process_kill (anastasisd,
- SIGTERM);
- GNUNET_OS_process_wait (merchantd);
- GNUNET_OS_process_wait (anastasisd);
- GNUNET_OS_process_destroy (merchantd);
- GNUNET_OS_process_destroy (anastasisd);
- GNUNET_free (merchant_url);
- GNUNET_free (anastasis_url);
-
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Test failed in interpreter\n");
- return 1;
- }
- break;
- default:
GNUNET_break (0);
return 1;
}
- return 0;
+ ret = TALER_TESTING_main (argv,
+ "INFO",
+ CONFIG_FILE,
+ "exchange-account-exchange",
+ TALER_TESTING_BS_FAKEBANK,
+ &cred,
+ &run,
+ NULL);
+ GNUNET_OS_process_kill (anastasisd,
+ SIGTERM);
+ GNUNET_OS_process_wait (anastasisd);
+ GNUNET_OS_process_destroy (anastasisd);
+ GNUNET_free (anastasis_url);
+ return ret;
}
diff --git a/src/testing/test_anastasis_api.conf b/src/testing/test_anastasis_api.conf
index 8befd99..53801d4 100644
--- a/src/testing/test_anastasis_api.conf
+++ b/src/testing/test_anastasis_api.conf
@@ -1,231 +1,125 @@
# This file is in the public domain.
#
[PATHS]
-# Persistent data storage for the testcase
TALER_TEST_HOME = test_anastasis_api_home/
-TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/${USER:-}/taler-system-runtime/
-
-# Persistent data storage
-TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
-
-# Configuration files
-TALER_CONFIG_HOME = $TALER_TEST_HOME/.config/taler/
-
-# Cached data, no big deal if lost
-TALER_CACHE_HOME = $TALER_TEST_HOME/.cache/taler/
+TALER_HOME = ${TALER_TEST_HOME:-${HOME:-${USERPROFILE}}}
+TALER_DATA_HOME = ${TALER_TEST_HOME:-${XDG_DATA_HOME:-${TALER_HOME}/.local/share/}/.local/share/}taler/
+TALER_CONFIG_HOME = ${TALER_TEST_HOME:-${XDG_CONFIG_HOME:-${TALER_HOME}/.config/}/.config/}taler/
+TALER_CACHE_HOME = ${TALER_TEST_HOME:-${XDG_CACHE_HOME:-${TALER_HOME}/.cache/}/.cache/}taler/
+TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime/
[taler]
-# What currency do we use?
-#currency = EUR
-currency = EUR
-#CURRENCY_ROUND_UNIT = EUR:0.01
-#CURRENCY_ROUND_UNIT = EUR:0.01
+CURRENCY = EUR
+CURRENCY_ROUND_UNIT = EUR:0.01
[taler-helper-crypto-rsa]
-# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 12 days
[taler-helper-crypto-eddsa]
-# Reduce from 1 year to speed up test
LOOKAHEAD_SIGN = 12 days
-# Reduce from 12 weeks to ensure we have multiple
DURATION = 7 days
-
[bank]
HTTP_PORT = 8082
-#BASE_URL = https://bank.test.taler.net/
+BASE_URL = http://localhost:8082/
-##########################################
-# Configuration for Anastasis #
-##########################################
+[libeufin-bank]
+CURRENCY = EUR
+WIRE_TYPE = iban
+IBAN_PAYTO_BIC = SANDBOXX
+DEFAULT_CUSTOMER_DEBT_LIMIT = EUR:200
+DEFAULT_ADMIN_DEBT_LIMIT = EUR:2000
+REGISTRATION_BONUS_ENABLED = yes
+REGISTRATION_BONUS = EUR:100
+SUGGESTED_WITHDRAWAL_EXCHANGE = http://localhost:8081/
+SERVE = tcp
+PORT = 8082
[anastasis]
PORT = 8086
-
DB = postgres
-
BUSINESS_NAME = "Checker's Test Inc."
-
-# Upload limit
UPLOAD_LIMIT_MB = 1
-
ANNUAL_POLICY_UPLOAD_LIMIT = 64
-
INSURANCE = EUR:0
-
-SERVER_SALT = salty
-
-
-# Annual fee we charge.
-#ANNUAL_FEE = EUR:4.99
+PROVIDER_SALT = salty
ANNUAL_FEE = EUR:4.99
-
TRUTH_UPLOAD_FEE = EUR:0.0
-
-# Base URL of anastasis.
-# BASE_URL = http://localhost:8086/
+BASE_URL = http://localhost:8086/
[anastasis-merchant-backend]
-# Where does our payment backend run? Must match PORT under [merchant]
PAYMENT_BACKEND_URL = http://localhost:8080/
-# Authentication costs
[authorization-question]
-# Cost of authentication by question
COST = EUR:0
[authorization-file]
-# Cost of authentication by file (only for testing purposes)
COST = EUR:1
[authorization-email]
-# Cost of authentication by E-Mail
COST = EUR:0
[authorization-sms]
-# Cost of authentication by SMS
COST = EUR:0
-
-# Command which is executed for the sms authentication
COMMAND = ./sms_authentication.sh
-
-
-
-# This specifies which database the postgres backend uses.
[stasis-postgres]
CONFIG = postgres:///anastasischeck
-##########################################
-# Configuration for the merchant backend #
-##########################################
-
[merchant]
-
-# Which port do we run the backend on? (HTTP server)
PORT = 8080
-
-# How quickly do we want the exchange to send us our money?
-# Used only if the frontend does not specify a value.
WIRE_TRANSFER_DELAY = 0 s
-
-# Which plugin (backend) do we use for the DB.
DB = postgres
-# Default choice for maximum wire fee.
-DEFAULT_MAX_WIRE_FEE = EUR:0.10
-
-# Default choice for maximum deposit fee.
-DEFAULT_MAX_DEPOSIT_FEE = EUR:0.10
-
-
-# This specifies which database the postgres backend uses.
[merchantdb-postgres]
CONFIG = postgres:///talercheck
-# Sections starting with "exchange-" specify trusted exchanges
-# (by the merchant)
[merchant-exchange-default]
MASTER_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
EXCHANGE_BASE_URL = http://localhost:8081/
-#MASTER_KEY = DY95EXAHQ2BKM2WK9YHZHYG1R7PPMMJPY14FNGP662DAKE35AKQG
-#EXCHANGE_BASE_URL = https://exchange.test.taler.net/
-#CURRENCY = EUR
CURRENCY = EUR
-# only fixes skips.
[auditor]
-BASE_URL = http://the.auditor/
-#BASE_URL = https://auditor.test.taler.net/
-#AUDITOR_KEY = DSDASDXAMDAARMNAD53ZA4AFAHA2QADAMAHHASWDAWXN84SDAA11
-# If currency does not match [TALER] section, the auditor
-# will be ignored!
-CURRENCY = EUR
-
-# Where do we store the auditor's private key?
-AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
-
-# Auditors must be in sections "auditor-", the rest of the section
-# name could be anything.
-[auditor-ezb]
-# Informal name of the auditor. Just for the user.
-NAME = European Central Bank
-
-# URL of the auditor (especially for in the future, when the
-# auditor offers an automated issue reporting system).
-# Not really used today.
-URL = http://taler.ezb.eu/
-
-# This is the important bit: the signing key of the auditor.
-PUBLIC_KEY = 9QXF7XY7E9VPV47B5Z806NDFSX2VJ79SVHHD29QEQ3BG31ANHZ60
-
-# Which currency is this auditor trusted for?
-CURRENCY = EUR
-
-
-###################################################
-# Configuration for the exchange for the testcase #
-###################################################
+PORT = 8083
+BASE_URL = "http://localhost:8083/"
[exchange]
-# How to access our database
+AML_THRESHOLD = EUR:1000000
DB = postgres
-
-# HTTP port the exchange listens to
PORT = 8081
-
-# how long are the signatures with the signkey valid?
SIGNKEY_LEGAL_DURATION = 2 years
-
-# Our public key
MASTER_PUBLIC_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG
-
-# Base URL of the exchange.
BASE_URL = "http://localhost:8081/"
-#BASE_URL = https://exchange.test.taler.net/
-
-# Network configuration for the normal API/service HTTP server
-# serve via tcp socket (on PORT)
SERVE = tcp
+STEFAN_ABS = "EUR:5"
[exchange-offline]
-
-# Where do we store the offline master private key of the exchange?
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
-# Where do we store the TOFU key material?
SECM_TOFU_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/secm_tofus.pub
-
[taler-exchange-secmod-eddsa]
-# Where do we store the generated private keys.
KEY_DIR = ${TALER_DATA_HOME}/exchange-secmod-eddsa/keys
[taler-exchange-secmod-rsa]
-# Where do we store the generated private keys.
KEY_DIR = ${TALER_DATA_HOME}/exchange-secmod-rsa/keys
+[taler-exchange-secmod-cs]
+KEY_DIR = ${TALER_DATA_HOME}/exchange-secmod-cs/keys
-[exchangedb-postgres]
-CONFIG = "postgres:///talercheck"
-[auditordb-postgres]
+[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
-# Account of the EXCHANGE
[exchange-account-exchange]
-# What is the exchange's bank account (with the "Taler Bank" demo system)?
-PAYTO_URI = "payto://x-taler-bank/localhost:8082/2"
+PAYTO_URI = "payto://x-taler-bank/localhost:8082/2?receiver-name=exchange"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
[exchange-accountcredentials-exchange]
-WIRE_GATEWAY_URL = "http://localhost:8082/2/"
+WIRE_GATEWAY_URL = "http://localhost:8082/accounts/2/taler-wire-gateway/"
WIRE_GATEWAY_AUTH_METHOD = NONE
-
-
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
@@ -236,6 +130,7 @@ fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_eur_ct_10]
value = EUR:0.10
@@ -247,6 +142,7 @@ fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_eur_1]
value = EUR:1
@@ -258,6 +154,7 @@ fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
+CIPHER = RSA
[coin_eur_5]
value = EUR:5
@@ -269,3 +166,4 @@ fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
+CIPHER = RSA
diff --git a/src/testing/test_anastasis_api_home/.config/taler/exchange/account-2.json b/src/testing/test_anastasis_api_home/.config/taler/exchange/account-2.json
deleted file mode 100644
index f798275..0000000
--- a/src/testing/test_anastasis_api_home/.config/taler/exchange/account-2.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "payto_uri": "payto://x-taler-bank/localhost:8082/2",
- "master_sig": "AM32QB4RYMWK548PE63PJXJMWSA001TFFWTZZPSSD8HQ8JE4D5V5X8WTSYSX59ANF4YRTRMF5Q4Q12CE2KTA8KQ03CM11YDTK75SJ20"}
diff --git a/src/testing/test_anastasis_api_home/.local/share/taler/exchange/offline-keys/master.priv b/src/testing/test_anastasis_api_home/taler/exchange-offline/master.priv
index c20942d..c20942d 100644
--- a/src/testing/test_anastasis_api_home/.local/share/taler/exchange/offline-keys/master.priv
+++ b/src/testing/test_anastasis_api_home/taler/exchange-offline/master.priv
diff --git a/src/testing/test_anastasis_api_home/taler/exchange/offline-keys/master.priv b/src/testing/test_anastasis_api_home/taler/exchange/offline-keys/master.priv
new file mode 100644
index 0000000..c20942d
--- /dev/null
+++ b/src/testing/test_anastasis_api_home/taler/exchange/offline-keys/master.priv
@@ -0,0 +1 @@
+åÊk;d³_Uû}£A.wÔ"!Gûçv_m "_ò \ No newline at end of file
diff --git a/src/testing/testing_api_cmd_config.c b/src/testing/testing_api_cmd_config.c
index 58a58dc..542e140 100644
--- a/src/testing/testing_api_cmd_config.c
+++ b/src/testing/testing_api_cmd_config.c
@@ -3,14 +3,14 @@
Copyright (C) 2019, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -53,7 +53,7 @@ struct ConfigState
/**
* The salt value from server.
*/
- struct ANASTASIS_CRYPTO_ProviderSaltP salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
};
@@ -61,39 +61,26 @@ struct ConfigState
* Function called with the results of a #ANASTASIS_get_config().
*
* @param cls closure
- * @param http_status HTTP status of the request
* @param config config from the server
*/
static void
config_cb (void *cls,
- unsigned int http_status,
const struct ANASTASIS_Config *config)
{
struct ConfigState *ss = cls;
ss->so = NULL;
- if (http_status != ss->http_status)
+ if (config->http_status != ss->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
- ss->is->commands[ss->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (ss->is);
+ TALER_TESTING_unexpected_status (ss->is,
+ config->http_status,
+ ss->http_status);
return;
}
- if (NULL == config)
+ if (GNUNET_OK == config->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Config is NULL, command %s in %s:%u\n",
- ss->is->commands[ss->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (ss->is);
- return;
+ ss->provider_salt = config->details.ok.provider_salt;
}
- ss->salt = config->salt;
TALER_TESTING_interpreter_next (ss->is);
}
@@ -113,10 +100,11 @@ config_run (void *cls,
struct ConfigState *ss = cls;
ss->is = is;
- ss->so = ANASTASIS_get_config (is->ctx,
- ss->anastasis_url,
- &config_cb,
- ss);
+ ss->so = ANASTASIS_get_config (
+ TALER_TESTING_interpreter_get_context (is),
+ ss->anastasis_url,
+ &config_cb,
+ ss);
if (NULL == ss->so)
{
GNUNET_break (0);
@@ -167,10 +155,8 @@ config_traits (void *cls,
unsigned int index)
{
struct ConfigState *ss = cls;
-
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_salt (0,
- &ss->salt),
+ ANASTASIS_TESTING_make_trait_provider_salt (&ss->provider_salt),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_policy_lookup.c b/src/testing/testing_api_cmd_policy_lookup.c
index eaff0f2..2d854c5 100644
--- a/src/testing/testing_api_cmd_policy_lookup.c
+++ b/src/testing/testing_api_cmd_policy_lookup.c
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -72,32 +72,26 @@ struct PolicyLookupState
* Function called with the results of a #ANASTASIS_policy_lookup().
*
* @param cls closure
- * @param http_status HTTP status of the request
* @param dd details about the lookup operation
*/
static void
policy_lookup_cb (void *cls,
- unsigned int http_status,
const struct ANASTASIS_DownloadDetails *dd)
{
struct PolicyLookupState *pls = cls;
pls->plo = NULL;
- if (http_status != pls->http_status)
+ if (dd->http_status != pls->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- http_status,
- pls->is->commands[pls->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (pls->is);
+ TALER_TESTING_unexpected_status (pls->is,
+ dd->http_status,
+ pls->http_status);
return;
}
if (NULL != pls->upload_reference)
{
- if ( (MHD_HTTP_OK == http_status) &&
- (0 != GNUNET_memcmp (&dd->curr_policy_hash,
+ if ( (MHD_HTTP_OK == dd->http_status) &&
+ (0 != GNUNET_memcmp (&dd->details.ok.curr_policy_hash,
pls->upload_hash)) )
{
GNUNET_break (0);
@@ -140,7 +134,6 @@ policy_lookup_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_hash (upload_cmd,
- ANASTASIS_TESTING_TRAIT_HASH_CURRENT,
&pls->upload_hash))
{
GNUNET_break (0);
@@ -149,7 +142,6 @@ policy_lookup_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_account_pub (upload_cmd,
- 0,
&anastasis_pub))
{
GNUNET_break (0);
@@ -158,11 +150,12 @@ policy_lookup_run (void *cls,
}
pls->anastasis_pub = *anastasis_pub;
}
- pls->plo = ANASTASIS_policy_lookup (is->ctx,
- pls->anastasis_url,
- &pls->anastasis_pub,
- &policy_lookup_cb,
- pls);
+ pls->plo = ANASTASIS_policy_lookup (
+ TALER_TESTING_interpreter_get_context (is),
+ pls->anastasis_url,
+ &pls->anastasis_pub,
+ &policy_lookup_cb,
+ pls);
if (NULL == pls->plo)
{
GNUNET_break (0);
diff --git a/src/testing/testing_api_cmd_policy_store.c b/src/testing/testing_api_cmd_policy_store.c
index 4b96472..edc753d 100644
--- a/src/testing/testing_api_cmd_policy_store.c
+++ b/src/testing/testing_api_cmd_policy_store.c
@@ -3,16 +3,16 @@
Copyright (C) 2014-2019 Anastasis SARL
ANASTASIS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
+ it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or
(at your option) any later version.
ANASTASIS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public
+ You should have received a copy of the GNU General Public
License along with ANASTASIS; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
@@ -139,13 +139,9 @@ policy_store_cb (void *cls,
pss->pso = NULL;
if (ud->http_status != pss->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- ud->http_status,
- pss->is->commands[pss->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (pss->is);
+ TALER_TESTING_unexpected_status (pss->is,
+ ud->http_status,
+ pss->http_status);
return;
}
switch (ud->us)
@@ -229,7 +225,6 @@ policy_store_run (void *cls,
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_account_priv (ref,
- 0,
&priv))
{
GNUNET_break (0);
@@ -243,7 +238,6 @@ policy_store_run (void *cls,
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_account_pub (ref,
- 0,
&pub))
{
GNUNET_break (0);
@@ -257,7 +251,6 @@ policy_store_run (void *cls,
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_payment_secret (ref,
- 0,
&ps))
{
GNUNET_break (0);
@@ -279,11 +272,12 @@ policy_store_run (void *cls,
pss->recovery_data_size,
&pss->curr_hash);
pss->pso = ANASTASIS_policy_store (
- is->ctx,
+ TALER_TESTING_interpreter_get_context (is),
pss->anastasis_url,
&pss->anastasis_priv,
pss->recovery_data,
pss->recovery_data_size,
+ "metadata", strlen ("metadata"),
(0 != (ANASTASIS_TESTING_PSO_REQUEST_PAYMENT & pss->psopt)),
pss->payment_secret_set ? &pss->payment_secret_request : NULL,
GNUNET_TIME_UNIT_ZERO,
@@ -341,18 +335,12 @@ policy_store_traits (void *cls,
{
struct PolicyStoreState *pss = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_claim_token (0,
- &pss->claim_token),
- TALER_TESTING_make_trait_order_id (0,
- pss->order_id),
- ANASTASIS_TESTING_make_trait_hash (0,
- &pss->curr_hash),
- ANASTASIS_TESTING_make_trait_account_pub (0,
- &pss->anastasis_pub),
- ANASTASIS_TESTING_make_trait_account_priv (0,
- &pss->anastasis_priv),
- ANASTASIS_TESTING_make_trait_payment_secret (0,
- &pss->payment_secret_response),
+ TALER_TESTING_make_trait_claim_token (&pss->claim_token),
+ TALER_TESTING_make_trait_order_id (pss->order_id),
+ ANASTASIS_TESTING_make_trait_hash (&pss->curr_hash),
+ ANASTASIS_TESTING_make_trait_account_pub (&pss->anastasis_pub),
+ ANASTASIS_TESTING_make_trait_account_priv (&pss->anastasis_priv),
+ ANASTASIS_TESTING_make_trait_payment_secret (&pss->payment_secret_response),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_truth_challenge.c b/src/testing/testing_api_cmd_truth_challenge.c
new file mode 100644
index 0000000..c399345
--- /dev/null
+++ b/src/testing/testing_api_cmd_truth_challenge.c
@@ -0,0 +1,368 @@
+/*
+ This file is part of Anastasis
+ Copyright (C) 2020, 2022 Anastasis SARL
+
+ Anastasis 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
+ Foundation; either version 3, or (at your option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file testing/testing_api_cmd_truth_challenge.c
+ * @brief Testing of Implementation of the /truth GET
+ * @author Christian Grothoff
+ * @author Dennis Neufeld
+ * @author Dominik Meister
+ */
+
+#include "platform.h"
+#include "anastasis_testing_lib.h"
+#include <taler/taler_util.h>
+#include <taler/taler_testing_lib.h>
+#include <taler/taler_merchant_service.h>
+
+
+/**
+ * State for a "keyshare lookup" CMD.
+ */
+struct TruthChallengeState
+{
+ /**
+ * The interpreter state.
+ */
+ struct TALER_TESTING_Interpreter *is;
+
+ /**
+ * URL of the anastasis backend.
+ */
+ const char *anastasis_url;
+
+ /**
+ * Expected HTTP status code.
+ */
+ unsigned int expected_http_status;
+
+ /**
+ * The /truth GET operation handle.
+ */
+ struct ANASTASIS_TruthChallengeOperation *tco;
+
+ /**
+ * Reference to upload command we expect to lookup.
+ */
+ const char *upload_reference;
+
+ /**
+ * Reference to upload command we expect to lookup.
+ */
+ const char *payment_reference;
+
+ /**
+ * Payment secret requested by the service, if any.
+ */
+ struct ANASTASIS_PaymentSecretP payment_secret_response;
+
+ /**
+ * Taler-URI with payment request, if any.
+ */
+ char *pay_uri;
+
+ /**
+ * Order ID for payment request, if any.
+ */
+ char *order_id;
+
+ /**
+ * "code" returned by service, if any.
+ */
+ char *code;
+
+ /**
+ * "instructions" for how to solve the challenge as returned by service, if any.
+ */
+ char *instructions;
+
+};
+
+
+static void
+truth_challenge_cb (void *cls,
+ const struct ANASTASIS_TruthChallengeDetails *tcd)
+{
+ struct TruthChallengeState *ksls = cls;
+
+ ksls->tco = NULL;
+ if (tcd->http_status != ksls->expected_http_status)
+ {
+ TALER_TESTING_unexpected_status (ksls->is,
+ tcd->http_status,
+ ksls->expected_http_status);
+ return;
+ }
+ switch (tcd->http_status)
+ {
+ case MHD_HTTP_OK:
+ switch (tcd->details.success.cs)
+ {
+ case ANASTASIS_CS_FILE_WRITTEN:
+ {
+ FILE *file;
+ char code[22];
+
+ file = fopen (tcd->details.success.details.challenge_filename,
+ "r");
+ if (NULL == file)
+ {
+ GNUNET_log_strerror_file (
+ GNUNET_ERROR_TYPE_ERROR,
+ "open",
+ tcd->details.success.details.challenge_filename);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ if (0 == fscanf (file,
+ "%21s",
+ code))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "fscanf",
+ tcd->details.success.details.
+ challenge_filename);
+ GNUNET_break (0 == fclose (file));
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ GNUNET_break (0 == fclose (file));
+ ksls->code = GNUNET_strdup (code);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read code `%s'\n",
+ code);
+ }
+ break;
+ case ANASTASIS_CS_TAN_SENT:
+ ksls->instructions = GNUNET_strdup (
+ tcd->details.success.details.tan_address_hint);
+ break;
+ case ANASTASIS_CS_TAN_ALREADY_SENT:
+ break;
+ case ANASTASIS_CS_WIRE_FUNDS:
+ /* FIXME: not implemented */
+ GNUNET_break (0);
+ return;
+ }
+ break;
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ ksls->pay_uri = GNUNET_strdup (
+ tcd->details.payment_required.payment_request);
+ ksls->payment_secret_response = tcd->details.payment_required.ps;
+ {
+ struct TALER_MERCHANT_PayUriData pd;
+
+ if (GNUNET_OK !=
+ TALER_MERCHANT_parse_pay_uri (ksls->pay_uri,
+ &pd))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ ksls->order_id = GNUNET_strdup (pd.order_id);
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ }
+
+ break;
+ default:
+ break;
+ }
+ TALER_TESTING_interpreter_next (ksls->is);
+}
+
+
+static void
+truth_challenge_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
+{
+ struct TruthChallengeState *ksls = cls;
+ const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
+ const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid;
+ const struct ANASTASIS_PaymentSecretP *payment_secret;
+
+ ksls->is = is;
+ if (NULL == ksls->upload_reference)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ {
+ const struct TALER_TESTING_Command *upload_cmd;
+
+ upload_cmd = TALER_TESTING_interpreter_lookup_command (
+ is,
+ ksls->upload_reference);
+ if (NULL == upload_cmd)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ if (GNUNET_OK !=
+ ANASTASIS_TESTING_get_trait_truth_uuid (upload_cmd,
+ &truth_uuid))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ if (NULL == truth_uuid)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ if (GNUNET_OK !=
+ ANASTASIS_TESTING_get_trait_truth_key (upload_cmd,
+ &truth_key))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ if (NULL == truth_key)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ }
+
+ if (NULL != ksls->payment_reference)
+ {
+ const struct TALER_TESTING_Command *payment_cmd;
+
+ payment_cmd = TALER_TESTING_interpreter_lookup_command (
+ is,
+ ksls->payment_reference);
+ if (GNUNET_OK !=
+ ANASTASIS_TESTING_get_trait_payment_secret (payment_cmd,
+ &payment_secret))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+ }
+ else
+ {
+ payment_secret = NULL;
+ }
+
+ ksls->tco = ANASTASIS_truth_challenge (
+ TALER_TESTING_interpreter_get_context (is),
+ ksls->anastasis_url,
+ truth_uuid,
+ truth_key,
+ payment_secret,
+ &truth_challenge_cb,
+ ksls);
+ if (NULL == ksls->tco)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
+}
+
+
+static void
+truth_challenge_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
+{
+ struct TruthChallengeState *ksls = cls;
+
+ if (NULL != ksls->tco)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Command '%s' did not complete (keyshare lookup)\n",
+ cmd->label);
+ ANASTASIS_truth_challenge_cancel (ksls->tco);
+ ksls->tco = NULL;
+ }
+ GNUNET_free (ksls->pay_uri);
+ GNUNET_free (ksls->order_id);
+ GNUNET_free (ksls->code);
+ GNUNET_free (ksls->instructions);
+ GNUNET_free (ksls);
+}
+
+
+/**
+ * Offer internal data to other commands.
+ *
+ * @param cls closure
+ * @param[out] ret result (could be anything)
+ * @param[out] trait name of the trait
+ * @param index index number of the object to extract.
+ * @return #GNUNET_OK on success
+ */
+static enum GNUNET_GenericReturnValue
+truth_challenge_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ struct TruthChallengeState *ksls = cls;
+ struct TALER_TESTING_Trait traits[] = {
+ ANASTASIS_TESTING_make_trait_payment_secret (
+ &ksls->payment_secret_response),
+ TALER_TESTING_make_trait_payto_uri (ksls->pay_uri),
+ TALER_TESTING_make_trait_order_id (ksls->order_id),
+ ANASTASIS_TESTING_make_trait_code (ksls->code),
+ TALER_TESTING_trait_end ()
+ };
+
+ return TALER_TESTING_get_trait (traits,
+ ret,
+ trait,
+ index);
+}
+
+
+struct TALER_TESTING_Command
+ANASTASIS_TESTING_cmd_truth_challenge (
+ const char *label,
+ const char *anastasis_url,
+ const char *payment_ref,
+ const char *upload_ref,
+ unsigned int http_status)
+{
+ struct TruthChallengeState *ksls;
+
+ GNUNET_assert (NULL != upload_ref);
+ ksls = GNUNET_new (struct TruthChallengeState);
+ ksls->expected_http_status = http_status;
+ ksls->anastasis_url = anastasis_url;
+ ksls->upload_reference = upload_ref;
+ ksls->payment_reference = payment_ref;
+ {
+ struct TALER_TESTING_Command cmd = {
+ .cls = ksls,
+ .label = label,
+ .run = &truth_challenge_run,
+ .cleanup = &truth_challenge_cleanup,
+ .traits = &truth_challenge_traits
+ };
+
+ return cmd;
+ }
+}
+
+
+/* end of testing_api_cmd_truth_challenge.c */
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c b/src/testing/testing_api_cmd_truth_solve.c
index 04ecf43..29157ed 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_truth_solve.c
@@ -1,20 +1,20 @@
/*
This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
+ Copyright (C) 2020, 2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file testing/testing_api_cmd_keyshare_lookup.c
+ * @file testing/testing_api_cmd_truth_solve.c
* @brief Testing of Implementation of the /truth GET
* @author Christian Grothoff
* @author Dennis Neufeld
@@ -31,7 +31,7 @@
/**
* State for a "keyshare lookup" CMD.
*/
-struct KeyShareLookupState
+struct TruthSolveState
{
/**
* The interpreter state.
@@ -46,12 +46,18 @@ struct KeyShareLookupState
/**
* Expected status code.
*/
- enum ANASTASIS_KeyShareDownloadStatus expected_ksdd;
+ unsigned int expected_http_status;
+
+ /**
+ * Resulting encrypted key share.
+ * Note: currently not used.
+ */
+ struct ANASTASIS_CRYPTO_EncryptedKeyShareP eks;
/**
* The /truth GET operation handle.
*/
- struct ANASTASIS_KeyShareLookupOperation *kslo;
+ struct ANASTASIS_TruthSolveOperation *tso;
/**
* answer to a challenge
@@ -113,100 +119,31 @@ struct KeyShareLookupState
static void
-keyshare_lookup_cb (void *cls,
- const struct ANASTASIS_KeyShareDownloadDetails *dd)
+truth_solve_cb (void *cls,
+ const struct ANASTASIS_TruthSolveReply *tsr)
{
- struct KeyShareLookupState *ksls = cls;
+ struct TruthSolveState *ksls = cls;
- ksls->kslo = NULL;
- if (dd->status != ksls->expected_ksdd)
+ ksls->tso = NULL;
+ if (tsr->http_status != ksls->expected_http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- dd->status,
- ksls->is->commands[ksls->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (ksls->is);
+ TALER_TESTING_unexpected_status (ksls->is,
+ tsr->http_status,
+ ksls->expected_http_status);
return;
}
- switch (dd->status)
+ switch (tsr->http_status)
{
- case ANASTASIS_KSD_SUCCESS:
- break;
- case ANASTASIS_KSD_PAYMENT_REQUIRED:
- ksls->pay_uri = GNUNET_strdup (dd->details.payment_required.taler_pay_uri);
- ksls->payment_secret_response = dd->details.payment_required.payment_secret;
- {
- struct TALER_MERCHANT_PayUriData pd;
-
- if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (ksls->pay_uri,
- &pd))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (ksls->is);
- return;
- }
- ksls->order_id = GNUNET_strdup (pd.order_id);
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- }
-
- break;
- case ANASTASIS_KSD_INVALID_ANSWER:
- if (ksls->filename)
- {
- FILE *file;
- char code[22];
-
- file = fopen (ksls->filename,
- "r");
- if (NULL == file)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open",
- ksls->filename);
- TALER_TESTING_interpreter_fail (ksls->is);
- return;
- }
- if (0 == fscanf (file,
- "%21s",
- code))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "fscanf",
- ksls->filename);
- GNUNET_break (0 == fclose (file));
- TALER_TESTING_interpreter_fail (ksls->is);
- return;
- }
- GNUNET_break (0 == fclose (file));
- ksls->code = GNUNET_strdup (code);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Read code `%s'\n",
- code);
- }
- else
- {
- ksls->instructions = GNUNET_strndup (
- dd->details.open_challenge.body,
- dd->details.open_challenge.body_size);
- }
- break;
- case ANASTASIS_KSD_REDIRECT_FOR_AUTHENTICATION:
- ksls->redirect_uri = GNUNET_strdup (dd->details.redirect_url);
+ case MHD_HTTP_OK:
+ ksls->eks = tsr->details.success.eks;
break;
- case ANASTASIS_KSD_SERVER_ERROR:
+ case MHD_HTTP_PAYMENT_REQUIRED:
+ ksls->pay_uri = GNUNET_strdup (
+ tsr->details.payment_required.payment_request);
+ ksls->payment_secret_response = tsr->details.payment_required.ps;
+ ksls->order_id = GNUNET_strdup (tsr->details.payment_required.pd->order_id);
break;
- case ANASTASIS_KSD_CLIENT_FAILURE:
- break;
- case ANASTASIS_KSD_TRUTH_UNKNOWN:
- break;
- case ANASTASIS_KSD_RATE_LIMIT_EXCEEDED:
- break;
- case ANASTASIS_KSD_AUTHENTICATION_TIMEOUT:
- break;
- case ANASTASIS_KSD_EXTERNAL_CHALLENGE_INSTRUCTIONS:
+ default:
break;
}
TALER_TESTING_interpreter_next (ksls->is);
@@ -214,11 +151,11 @@ keyshare_lookup_cb (void *cls,
static void
-keyshare_lookup_run (void *cls,
- const struct TALER_TESTING_Command *cmd,
- struct TALER_TESTING_Interpreter *is)
+truth_solve_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
{
- struct KeyShareLookupState *ksls = cls;
+ struct TruthSolveState *ksls = cls;
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key;
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid;
const struct ANASTASIS_PaymentSecretP *payment_secret;
@@ -247,9 +184,8 @@ keyshare_lookup_run (void *cls,
const char *fn;
if (GNUNET_OK !=
- TALER_TESTING_get_trait_string (upload_cmd,
- 0,
- &fn))
+ ANASTASIS_TESTING_get_trait_filename (upload_cmd,
+ &fn))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ksls->is);
@@ -260,7 +196,6 @@ keyshare_lookup_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_truth_uuid (upload_cmd,
- 0,
&truth_uuid))
{
GNUNET_break (0);
@@ -275,7 +210,6 @@ keyshare_lookup_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_truth_key (upload_cmd,
- 0,
&truth_key))
{
GNUNET_break (0);
@@ -304,7 +238,6 @@ keyshare_lookup_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_code (download_cmd,
- 0,
&answer))
{
GNUNET_break (0);
@@ -323,17 +256,22 @@ keyshare_lookup_run (void *cls,
/* answer is the answer */
answer = ksls->answer;
}
+ if (NULL == answer)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ksls->is);
+ return;
+ }
if (NULL != ksls->payment_reference)
{
const struct TALER_TESTING_Command *payment_cmd;
- payment_cmd = TALER_TESTING_interpreter_lookup_command
- (is,
- ksls->payment_reference);
+ payment_cmd = TALER_TESTING_interpreter_lookup_command (
+ is,
+ ksls->payment_reference);
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_payment_secret (payment_cmd,
- 0,
&payment_secret))
{
GNUNET_break (0);
@@ -349,23 +287,21 @@ keyshare_lookup_run (void *cls,
{
struct GNUNET_HashCode h_answer;
- if (NULL != answer)
- GNUNET_CRYPTO_hash (answer,
- strlen (answer),
- &h_answer);
- ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
- ksls->anastasis_url,
- truth_uuid,
- truth_key,
- payment_secret,
- GNUNET_TIME_UNIT_ZERO,
- (NULL != answer)
- ? &h_answer
- : NULL,
- &keyshare_lookup_cb,
- ksls);
+ GNUNET_CRYPTO_hash (answer,
+ strlen (answer),
+ &h_answer);
+ ksls->tso = ANASTASIS_truth_solve (
+ TALER_TESTING_interpreter_get_context (is),
+ ksls->anastasis_url,
+ truth_uuid,
+ truth_key,
+ payment_secret,
+ GNUNET_TIME_UNIT_ZERO,
+ &h_answer,
+ &truth_solve_cb,
+ ksls);
}
- if (NULL == ksls->kslo)
+ if (NULL == ksls->tso)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (ksls->is);
@@ -375,22 +311,23 @@ keyshare_lookup_run (void *cls,
static void
-keyshare_lookup_cleanup (void *cls,
- const struct TALER_TESTING_Command *cmd)
+truth_solve_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
{
- struct KeyShareLookupState *ksls = cls;
+ struct TruthSolveState *ksls = cls;
- if (NULL != ksls->kslo)
+ if (NULL != ksls->tso)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command '%s' did not complete (keyshare lookup)\n",
cmd->label);
- ANASTASIS_keyshare_lookup_cancel (ksls->kslo);
- ksls->kslo = NULL;
+ ANASTASIS_truth_solve_cancel (ksls->tso);
+ ksls->tso = NULL;
}
GNUNET_free (ksls->pay_uri);
GNUNET_free (ksls->order_id);
GNUNET_free (ksls->code);
+ GNUNET_free (ksls->filename);
GNUNET_free (ksls->instructions);
GNUNET_free (ksls->redirect_uri);
GNUNET_free (ksls);
@@ -406,22 +343,19 @@ keyshare_lookup_cleanup (void *cls,
* @param index index number of the object to extract.
* @return #GNUNET_OK on success
*/
-static int
-keyshare_lookup_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
+static enum GNUNET_GenericReturnValue
+truth_solve_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
{
- struct KeyShareLookupState *ksls = cls;
+ struct TruthSolveState *ksls = cls;
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_payment_secret (0,
- &ksls->payment_secret_response),
- TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
- ksls->pay_uri),
- TALER_TESTING_make_trait_order_id (0,
- ksls->order_id),
- ANASTASIS_TESTING_make_trait_code (0,
- ksls->code),
+ ANASTASIS_TESTING_make_trait_payment_secret (
+ &ksls->payment_secret_response),
+ TALER_TESTING_make_trait_payto_uri (ksls->pay_uri),
+ TALER_TESTING_make_trait_order_id (ksls->order_id),
+ ANASTASIS_TESTING_make_trait_code (ksls->code),
TALER_TESTING_trait_end ()
};
@@ -433,20 +367,20 @@ keyshare_lookup_traits (void *cls,
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_keyshare_lookup (
+ANASTASIS_TESTING_cmd_truth_solve (
const char *label,
const char *anastasis_url,
const char *answer,
const char *payment_ref,
const char *upload_ref,
int lookup_mode,
- enum ANASTASIS_KeyShareDownloadStatus ksdd)
+ unsigned int http_status)
{
- struct KeyShareLookupState *ksls;
+ struct TruthSolveState *ksls;
GNUNET_assert (NULL != upload_ref);
- ksls = GNUNET_new (struct KeyShareLookupState);
- ksls->expected_ksdd = ksdd;
+ ksls = GNUNET_new (struct TruthSolveState);
+ ksls->expected_http_status = http_status;
ksls->anastasis_url = anastasis_url;
ksls->upload_reference = upload_ref;
ksls->payment_reference = payment_ref;
@@ -456,9 +390,9 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (
struct TALER_TESTING_Command cmd = {
.cls = ksls,
.label = label,
- .run = &keyshare_lookup_run,
- .cleanup = &keyshare_lookup_cleanup,
- .traits = &keyshare_lookup_traits
+ .run = &truth_solve_run,
+ .cleanup = &truth_solve_cleanup,
+ .traits = &truth_solve_traits
};
return cmd;
@@ -466,4 +400,4 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (
}
-/* end of testing_api_cmd_keyshare_lookup.c */
+/* end of testing_api_cmd_truth_solve.c */
diff --git a/src/testing/testing_api_cmd_truth_store.c b/src/testing/testing_api_cmd_truth_store.c
index 141ef20..f7a6ece 100644
--- a/src/testing/testing_api_cmd_truth_store.c
+++ b/src/testing/testing_api_cmd_truth_store.c
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -125,16 +125,11 @@ truth_store_cb (void *cls,
struct TruthStoreState *tss = cls;
tss->tso = NULL;
- if ( (NULL == ud) ||
- (ud->http_status != tss->http_status) )
+ if (ud->http_status != tss->http_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- (NULL != ud) ? ud->http_status : 0,
- tss->is->commands[tss->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (tss->is);
+ TALER_TESTING_unexpected_status (tss->is,
+ ud->http_status,
+ tss->http_status);
return;
}
switch (ud->us)
@@ -205,7 +200,6 @@ truth_store_run (void *cls,
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_truth_uuid (ref,
- 0,
&uuid))
{
GNUNET_break (0);
@@ -215,7 +209,6 @@ truth_store_run (void *cls,
tss->uuid = *uuid;
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_eks (ref,
- 0,
&eks))
{
GNUNET_break (0);
@@ -275,7 +268,7 @@ truth_store_run (void *cls,
GNUNET_free (t);
}
tss->tso = ANASTASIS_truth_store (
- is->ctx,
+ TALER_TESTING_interpreter_get_context (is),
tss->anastasis_url,
&tss->uuid,
tss->method,
@@ -335,7 +328,7 @@ truth_store_cleanup (void *cls,
* @param index index number of the object to extract.
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
truth_store_traits (void *cls,
const void **ret,
const char *trait,
@@ -343,18 +336,12 @@ truth_store_traits (void *cls,
{
struct TruthStoreState *tss = cls;
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_truth_uuid (0,
- &tss->uuid),
- ANASTASIS_TESTING_make_trait_truth_key (0,
- &tss->key),
- ANASTASIS_TESTING_make_trait_eks (0,
- &tss->encrypted_keyshare),
- ANASTASIS_TESTING_make_trait_payment_secret (0,
- &tss->payment_secret_response),
- TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
- tss->pay_uri),
- TALER_TESTING_make_trait_string (0,
- tss->filename),
+ ANASTASIS_TESTING_make_trait_truth_uuid (&tss->uuid),
+ ANASTASIS_TESTING_make_trait_truth_key (&tss->key),
+ ANASTASIS_TESTING_make_trait_eks (&tss->encrypted_keyshare),
+ ANASTASIS_TESTING_make_trait_payment_secret (&tss->payment_secret_response),
+ TALER_TESTING_make_trait_payto_uri (tss->pay_uri),
+ ANASTASIS_TESTING_make_trait_filename (tss->filename),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_helpers.c b/src/testing/testing_api_helpers.c
index 15fa136..f131d00 100644
--- a/src/testing/testing_api_helpers.c
+++ b/src/testing/testing_api_helpers.c
@@ -3,16 +3,16 @@
Copyright (C) 2014-2021 Anastasis SARL
ANASTASIS is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
+ it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or
(at your option) any later version.
ANASTASIS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
ANASTASISABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public
+ You should have received a copy of the GNU General Public
License along with ANASTASIS; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
diff --git a/src/testing/testing_api_trait_account_priv.c b/src/testing/testing_api_trait_account_priv.c
deleted file mode 100644
index aa8addd..0000000
--- a/src/testing/testing_api_trait_account_priv.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2019 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Privlic License for more details.
-
- You should have received a copy of the GNU Affero General Privlic
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_account_priv.c
- * @brief traits to offer a account_priv
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_ACCOUNT_PRIV "anastasis-account_priv"
-
-
-int
-ANASTASIS_TESTING_get_trait_account_priv (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPrivateKeyP **priv)
-{
- return cmd->traits (cmd->cls,
- (const void **) priv,
- ANASTASIS_TESTING_TRAIT_ACCOUNT_PRIV,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_priv (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *priv)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_ACCOUNT_PRIV,
- .ptr = (const void *) priv
- };
-
- return ret;
-}
-
-
-/* end of testing_api_trait_account_priv.c */
diff --git a/src/testing/testing_api_trait_account_pub.c b/src/testing/testing_api_trait_account_pub.c
deleted file mode 100644
index b4bc6f5..0000000
--- a/src/testing/testing_api_trait_account_pub.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2019 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_account_pub.c
- * @brief traits to offer a account_pub
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_ACCOUNT_PUB "anastasis-account_pub"
-
-
-int
-ANASTASIS_TESTING_get_trait_account_pub (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPublicKeyP **pub)
-{
- return cmd->traits (cmd->cls,
- (const void **) pub,
- ANASTASIS_TESTING_TRAIT_ACCOUNT_PUB,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_account_pub (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_AccountPublicKeyP *h)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_ACCOUNT_PUB,
- .ptr = (const void *) h
- };
-
- return ret;
-}
-
-
-/* end of testing_api_trait_account_pub.c */
diff --git a/src/testing/testing_api_trait_code.c b/src/testing/testing_api_trait_code.c
deleted file mode 100644
index bdc289b..0000000
--- a/src/testing/testing_api_trait_code.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2019 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_code.c
- * @brief traits to offers a code for a challenge
- * @author Dominik Meister
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_CODE "anastasis-code"
-
-
-int
-ANASTASIS_TESTING_get_trait_code (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const char **code)
-{
- return cmd->traits (cmd->cls,
- (const void **) code,
- ANASTASIS_TESTING_TRAIT_CODE,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_code (
- unsigned int index,
- const char *code)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_CODE,
- .ptr = (const void *) code
- };
-
- return ret;
-}
-
-
-/* end of testing_api_trait_code.c */
diff --git a/src/testing/testing_api_trait_eks.c b/src/testing/testing_api_trait_eks.c
deleted file mode 100644
index d148456..0000000
--- a/src/testing/testing_api_trait_eks.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2021 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_eks.c
- * @brief traits to offer a payment identifier
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_EKS \
- "anastasis-eks"
-
-
-int
-ANASTASIS_TESTING_get_trait_eks (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_EncryptedKeyShareP **eks)
-{
- return cmd->traits (cmd->cls,
- (const void **) eks,
- ANASTASIS_TESTING_TRAIT_EKS,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_eks (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *eks)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_EKS,
- .ptr = (const void *) eks
- };
- return ret;
-}
-
-
-/* end of testing_api_trait_eks.c */
diff --git a/src/testing/testing_api_trait_hash.c b/src/testing/testing_api_trait_hash.c
deleted file mode 100644
index 9f9d554..0000000
--- a/src/testing/testing_api_trait_hash.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2019 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file anastasis/src/testing/testing_api_trait_hash.c
- * @brief traits to offer a hash
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_HASH "anastasis-hash"
-
-
-int
-ANASTASIS_TESTING_get_trait_hash (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct GNUNET_HashCode **h)
-{
- return cmd->traits (cmd->cls,
- (const void **) h,
- ANASTASIS_TESTING_TRAIT_HASH,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_hash (
- unsigned int index,
- const struct GNUNET_HashCode *h)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_HASH,
- .ptr = (const void *) h
- };
- return ret;
-}
-
-
-/* end of testing_api_trait_hash.c */
diff --git a/src/testing/testing_api_trait_payment_secret.c b/src/testing/testing_api_trait_payment_secret.c
deleted file mode 100644
index aa580da..0000000
--- a/src/testing/testing_api_trait_payment_secret.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2019 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_payment_secret.c
- * @brief traits to offer a payment identifier
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_PAYMENT_SECRET \
- "anastasis-payment_secret"
-
-
-int
-ANASTASIS_TESTING_get_trait_payment_secret (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_PaymentSecretP **payment_secret)
-{
- return cmd->traits (cmd->cls,
- (const void **) payment_secret,
- ANASTASIS_TESTING_TRAIT_PAYMENT_SECRET,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_payment_secret (
- unsigned int index,
- const struct ANASTASIS_PaymentSecretP *h)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_PAYMENT_SECRET,
- .ptr = (const void *) h
- };
-
- return ret;
-}
-
-
-/* end of testing_api_trait_payment_secret.c */
diff --git a/src/testing/testing_api_trait_salt.c b/src/testing/testing_api_trait_salt.c
deleted file mode 100644
index 178b092..0000000
--- a/src/testing/testing_api_trait_salt.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_salt.c
- * @brief traits to offer a hash
- * @author Christian Grothoff
- * @author Dominik Meister
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_SALT "anastasis-provider-salt"
-
-
-int
-ANASTASIS_TESTING_get_trait_salt (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_ProviderSaltP **s)
-{
- return cmd->traits (cmd->cls,
- (const void **) s,
- ANASTASIS_TESTING_TRAIT_SALT,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_salt (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_ProviderSaltP *s)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_SALT,
- .ptr = (const void *) s
- };
-
- return ret;
-}
-
-
-/* end of testing_api_trait_salt.c */
diff --git a/src/testing/testing_api_trait_truth_key.c b/src/testing/testing_api_trait_truth_key.c
deleted file mode 100644
index 5de8860..0000000
--- a/src/testing/testing_api_trait_truth_key.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2019, 2021 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_truth_key.c
- * @brief traits to offer a payment identifier
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_TRUTH_KEY \
- "anastasis-truth_key"
-
-
-int
-ANASTASIS_TESTING_get_trait_truth_key
- (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthKeyP **truth_key)
-{
- return cmd->traits (cmd->cls,
- (const void **) truth_key,
- ANASTASIS_TESTING_TRAIT_TRUTH_KEY,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth_key
- (unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthKeyP *h)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_TRUTH_KEY,
- .ptr = (const void *) h
- };
- return ret;
-}
-
-
-/* end of testing_api_trait_truth_key.c */
diff --git a/src/testing/testing_api_trait_truth_uuid.c b/src/testing/testing_api_trait_truth_uuid.c
deleted file mode 100644
index 7eba4b0..0000000
--- a/src/testing/testing_api_trait_truth_uuid.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_api_trait_truth_uuid.c
- * @brief traits to offer a UUID for some truth
- * @author Christian Grothoff
- * @author Dominik Meister
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-
-#define ANASTASIS_TESTING_TRAIT_TRUTH_UUID "anastasis-truth-uuid"
-
-
-int
-ANASTASIS_TESTING_get_trait_truth_uuid (
- const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthUUIDP **tpk)
-{
- return cmd->traits (cmd->cls,
- (const void **) tpk,
- ANASTASIS_TESTING_TRAIT_TRUTH_UUID,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth_uuid (
- unsigned int index,
- const struct ANASTASIS_CRYPTO_TruthUUIDP *tpk)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_TRUTH_UUID,
- .ptr = (const void *) tpk
- };
-
- return ret;
-}
-
-
-/* end of testing_api_trait_truth_uuid.c */
diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c
new file mode 100644
index 0000000..79b78a5
--- /dev/null
+++ b/src/testing/testing_api_traits.c
@@ -0,0 +1,36 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2018, 2021 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 Foundation; either version 3, or
+ (at your option) any later version.
+
+ TALER is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with TALER; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file testing/testing_api_traits.c
+ * @brief loop for trait resolution
+ * @author Christian Grothoff
+ * @author Marcello Stanisci
+ */
+#include "platform.h"
+#include "anastasis_testing_lib.h"
+#include <taler/taler_json_lib.h>
+#include <gnunet/gnunet_curl_lib.h>
+#include <taler/taler_testing_lib.h>
+
+
+ANASTASIS_TESTING_SIMPLE_TRAITS (ANASTASIS_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
+
+ANASTASIS_TESTING_INDEXED_TRAITS (ANASTASIS_TESTING_MAKE_IMPL_INDEXED_TRAIT)
+
+/* end of testing_api_traits.c */
diff --git a/src/testing/testing_cmd_challenge_answer.c b/src/testing/testing_cmd_challenge_answer.c
index ff897f3..ad24861 100644
--- a/src/testing/testing_cmd_challenge_answer.c
+++ b/src/testing/testing_cmd_challenge_answer.c
@@ -1,16 +1,16 @@
/*
This file is part of Anastasis
- Copyright (C) 2020, 2021 Anastasis SARL
+ Copyright (C) 2020, 2021, 2022 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -20,7 +20,6 @@
* @author Dennis Neufeld
* @author Dominik Meister
*/
-
#include "platform.h"
#include "anastasis_testing_lib.h"
#include <taler/taler_util.h>
@@ -28,6 +27,8 @@
#include <taler/taler_merchant_service.h>
+// FIXME: break up into two files, one for start, one for answer!
+
/**
* State for a "challenge answer" CMD.
*/
@@ -74,9 +75,14 @@ struct ChallengeState
struct ANASTASIS_PaymentSecretP payment_order_req;
/**
- * Expected status code.
+ * Expected answer status code.
+ */
+ enum ANASTASIS_ChallengeAnswerStatus expected_acs;
+
+ /**
+ * Expected start status code.
*/
- enum ANASTASIS_ChallengeStatus expected_cs;
+ enum ANASTASIS_ChallengeStartStatus expected_scs;
/**
* Index of the challenge we are solving
@@ -91,103 +97,35 @@ struct ChallengeState
/**
* code we read in the file generated by the plugin
*/
- char code[22];
+ char *code;
};
static void
challenge_answer_cb (void *af_cls,
- const struct ANASTASIS_ChallengeStartResponse *csr)
+ const struct ANASTASIS_ChallengeAnswerResponse *csr)
{
struct ChallengeState *cs = af_cls;
cs->c = NULL;
- if (csr->cs != cs->expected_cs)
+ if (csr->cs != cs->expected_acs)
{
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Expected status %u, got %u\n",
- cs->expected_cs,
+ cs->expected_acs,
csr->cs);
TALER_TESTING_interpreter_fail (cs->is);
return;
}
switch (csr->cs)
{
- case ANASTASIS_CHALLENGE_STATUS_SOLVED:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_SOLVED:
break;
- case ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS:
- {
- FILE *file;
- char *fn;
-
- if (0 == strcasecmp (csr->details.open_challenge.content_type,
- "application/json"))
- {
- const char *filename;
- json_t *in;
-
- in = json_loadb (csr->details.open_challenge.body,
- csr->details.open_challenge.body_size,
- JSON_REJECT_DUPLICATES,
- NULL);
- if (NULL == in)
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (cs->is);
- return;
- }
- filename = json_string_value (json_object_get (in,
- "filename"));
- if (NULL == filename)
- {
- GNUNET_break (0);
- json_decref (in);
- TALER_TESTING_interpreter_fail (cs->is);
- return;
- }
- fn = GNUNET_strdup (filename);
- json_decref (in);
- }
- else
- {
- fn = GNUNET_strndup (csr->details.open_challenge.body,
- csr->details.open_challenge.body_size);
- }
- file = fopen (fn,
- "r");
- if (NULL == file)
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "open",
- fn);
- GNUNET_free (fn);
- TALER_TESTING_interpreter_fail (cs->is);
- return;
- }
- if (0 == fscanf (file,
- "%21s",
- cs->code))
- {
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "fscanf",
- fn);
- TALER_TESTING_interpreter_fail (cs->is);
- fclose (file);
- GNUNET_free (fn);
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Read challenge answer `%s' from file `%s'\n",
- cs->code,
- fn);
- TALER_TESTING_interpreter_next (cs->is);
- GNUNET_break (0 == fclose (file));
- GNUNET_free (fn);
- return;
- }
- case ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_INVALID_ANSWER:
+ break;
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_PAYMENT_REQUIRED:
if (0 != strncmp (csr->details.payment_required.taler_pay_uri,
"taler+http://pay/",
strlen ("taler+http://pay/")))
@@ -227,19 +165,13 @@ challenge_answer_cb (void *af_cls,
}
TALER_TESTING_interpreter_next (cs->is);
return;
- case ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN:
- break;
- case ANASTASIS_CHALLENGE_STATUS_REDIRECT_FOR_AUTHENTICATION:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_TRUTH_UNKNOWN:
break;
- case ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_SERVER_FAILURE:
GNUNET_break (0);
TALER_TESTING_interpreter_fail (cs->is);
return;
- case ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED:
- break;
- case ANASTASIS_CHALLENGE_STATUS_AUTH_TIMEOUT:
- break;
- case ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS:
+ case ANASTASIS_CHALLENGE_ANSWER_STATUS_RATE_LIMIT_EXCEEDED:
break;
}
TALER_TESTING_interpreter_next (cs->is);
@@ -259,7 +191,7 @@ challenge_answer_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct ChallengeState *cs = cls;
- const struct ANASTASIS_Challenge *c;
+ const struct ANASTASIS_Challenge **c;
const struct ANASTASIS_PaymentSecretP *ps;
cs->is = is;
@@ -277,14 +209,15 @@ challenge_answer_run (void *cls,
return;
}
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_challenge (ref,
- cs->challenge_index,
- &c))
+ ANASTASIS_TESTING_get_trait_challenges (ref,
+ cs->challenge_index,
+ &c))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (cs->is);
return;
}
+ cs->c = (struct ANASTASIS_Challenge *) *c;
}
if (NULL != cs->payment_ref)
@@ -301,7 +234,6 @@ challenge_answer_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_payment_secret (ref,
- 0,
&ps))
{
GNUNET_break (0);
@@ -314,8 +246,6 @@ challenge_answer_run (void *cls,
ps = NULL;
}
- cs->c = (struct ANASTASIS_Challenge *) c;
-
if (1 == cs->mode)
{
const struct TALER_TESTING_Command *ref;
@@ -333,7 +263,6 @@ challenge_answer_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_code (ref,
- 0,
&answer))
{
GNUNET_break (0);
@@ -384,6 +313,118 @@ challenge_answer_run (void *cls,
}
+static void
+challenge_start_cb (void *af_cls,
+ const struct ANASTASIS_ChallengeStartResponse *csr)
+{
+ struct ChallengeState *cs = af_cls;
+
+ cs->c = NULL;
+ if (csr->cs != cs->expected_scs)
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Expected status %u, got %u\n",
+ cs->expected_scs,
+ csr->cs);
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ switch (csr->cs)
+ {
+ case ANASTASIS_CHALLENGE_START_STATUS_FILENAME_PROVIDED:
+ {
+ FILE *file;
+ char code[22];
+
+ file = fopen (csr->details.tan_filename,
+ "r");
+ if (NULL == file)
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "open",
+ csr->details.tan_filename);
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ if (0 == fscanf (file,
+ "%21s",
+ code))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
+ "fscanf",
+ csr->details.tan_filename);
+ GNUNET_break (0 == fclose (file));
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ GNUNET_break (0 == fclose (file));
+ cs->code = GNUNET_strdup (code);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Read code `%s'\n",
+ code);
+ }
+ break;
+ case ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED:
+ GNUNET_break (0); /* FIXME: not implemented */
+ break;
+ case ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT:
+ GNUNET_break (0); /* FIXME: not implemented */
+ break;
+ case ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED:
+ GNUNET_break (0); /* FIXME: not implemented */
+ break;
+ case ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED:
+ if (0 != strncmp (csr->details.payment_required.taler_pay_uri,
+ "taler+http://pay/",
+ strlen ("taler+http://pay/")))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid payment URI `%s'\n",
+ csr->details.payment_required.taler_pay_uri);
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ cs->payment_uri = GNUNET_strdup (
+ csr->details.payment_required.taler_pay_uri);
+ {
+ struct TALER_MERCHANT_PayUriData pud;
+
+ if (GNUNET_OK !=
+ TALER_MERCHANT_parse_pay_uri (cs->payment_uri,
+ &pud))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ cs->order_id = GNUNET_strdup (pud.order_id);
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (cs->order_id,
+ strlen (cs->order_id),
+ &cs->payment_order_req,
+ sizeof (cs->payment_order_req)))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ TALER_MERCHANT_parse_pay_uri_free (&pud);
+ }
+ TALER_TESTING_interpreter_next (cs->is);
+ return;
+ case ANASTASIS_CHALLENGE_START_STATUS_TRUTH_UNKNOWN:
+ break;
+ case ANASTASIS_CHALLENGE_START_STATUS_SERVER_FAILURE:
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (cs->is);
+ return;
+ }
+ TALER_TESTING_interpreter_next (cs->is);
+}
+
+
/**
* Run a "recover secret" CMD.
*
@@ -397,7 +438,7 @@ challenge_start_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct ChallengeState *cs = cls;
- const struct ANASTASIS_Challenge *c;
+ const struct ANASTASIS_Challenge **c;
const struct TALER_TESTING_Command *ref;
const struct ANASTASIS_PaymentSecretP *ps;
@@ -412,9 +453,9 @@ challenge_start_run (void *cls,
return;
}
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_challenge (ref,
- cs->challenge_index,
- &c))
+ ANASTASIS_TESTING_get_trait_challenges (ref,
+ cs->challenge_index,
+ &c))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (cs->is);
@@ -434,7 +475,6 @@ challenge_start_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_payment_secret (ref,
- 0,
&ps))
{
GNUNET_break (0);
@@ -447,11 +487,9 @@ challenge_start_run (void *cls,
ps = NULL;
}
if (GNUNET_OK !=
- ANASTASIS_challenge_start ((struct ANASTASIS_Challenge *) c,
+ ANASTASIS_challenge_start ((struct ANASTASIS_Challenge *) *c,
ps,
- GNUNET_TIME_UNIT_ZERO,
- NULL,
- &challenge_answer_cb,
+ &challenge_start_cb,
cs))
{
GNUNET_break (0);
@@ -484,6 +522,7 @@ challenge_cleanup (void *cls,
}
GNUNET_free (cs->payment_uri);
GNUNET_free (cs->order_id);
+ GNUNET_free (cs->code);
GNUNET_free (cs);
}
@@ -497,7 +536,7 @@ challenge_cleanup (void *cls,
* @param index index number of the object to extract.
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
challenge_create_traits (void *cls,
const void **ret,
const char *trait,
@@ -505,14 +544,11 @@ challenge_create_traits (void *cls,
{
struct ChallengeState *cs = cls;
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_code (0,
- cs->code),
- ANASTASIS_TESTING_make_trait_payment_secret (0,
- &cs->payment_order_req),
- TALER_TESTING_make_trait_url (TALER_TESTING_UT_TALER_URL,
- cs->payment_uri),
- TALER_TESTING_make_trait_order_id (0,
- cs->order_id),
+ ANASTASIS_TESTING_make_trait_code (cs->code),
+ ANASTASIS_TESTING_make_trait_payment_secret (
+ &cs->payment_order_req),
+ TALER_TESTING_make_trait_payto_uri (cs->payment_uri),
+ TALER_TESTING_make_trait_order_id (cs->order_id),
TALER_TESTING_trait_end ()
};
@@ -529,12 +565,12 @@ ANASTASIS_TESTING_cmd_challenge_start (
const char *payment_ref,
const char *challenge_ref,
unsigned int challenge_index,
- enum ANASTASIS_ChallengeStatus expected_cs)
+ enum ANASTASIS_ChallengeStartStatus expected_cs)
{
struct ChallengeState *cs;
cs = GNUNET_new (struct ChallengeState);
- cs->expected_cs = expected_cs;
+ cs->expected_scs = expected_cs;
cs->challenge_ref = challenge_ref;
cs->payment_ref = payment_ref;
cs->challenge_index = challenge_index;
@@ -560,12 +596,12 @@ ANASTASIS_TESTING_cmd_challenge_answer (
unsigned int challenge_index,
const char *answer,
unsigned int mode,
- enum ANASTASIS_ChallengeStatus expected_cs)
+ enum ANASTASIS_ChallengeAnswerStatus expected_cs)
{
struct ChallengeState *cs;
cs = GNUNET_new (struct ChallengeState);
- cs->expected_cs = expected_cs;
+ cs->expected_acs = expected_cs;
cs->challenge_ref = challenge_ref;
cs->payment_ref = payment_ref;
cs->answer = answer;
diff --git a/src/testing/testing_cmd_policy_create.c b/src/testing/testing_cmd_policy_create.c
index 62ad71f..64f7060 100644
--- a/src/testing/testing_cmd_policy_create.c
+++ b/src/testing/testing_cmd_policy_create.c
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -82,7 +82,7 @@ policy_create_run (void *cls,
for (unsigned int i = 0; i < pcs->cmd_label_array_length; i++)
{
const struct TALER_TESTING_Command *ref;
- const struct ANASTASIS_Truth *truth;
+ const struct ANASTASIS_Truth **truth;
ref = TALER_TESTING_interpreter_lookup_command (is,
pcs->cmd_label_array[i]);
@@ -94,15 +94,14 @@ policy_create_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_truth (ref,
- 0,
&truth))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (pcs->is);
return;
}
- GNUNET_assert (NULL != truth);
- truths[i] = truth;
+ GNUNET_assert (NULL != *truth);
+ truths[i] = *truth;
}
}
@@ -159,8 +158,8 @@ policy_create_traits (void *cls,
{
struct PolicyCreateState *pcs = cls;
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_policy (0,
- pcs->policy),
+ ANASTASIS_TESTING_make_trait_policy (
+ (const struct ANASTASIS_Policy **) &pcs->policy),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_cmd_recover_secret.c b/src/testing/testing_cmd_recover_secret.c
index 55c0168..1f3e832 100644
--- a/src/testing/testing_cmd_recover_secret.c
+++ b/src/testing/testing_cmd_recover_secret.c
@@ -3,14 +3,14 @@
Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -67,11 +67,6 @@ struct RecoverSecretState
json_t *id_data;
/**
- * Salt to be used to derive the id
- */
- struct ANASTASIS_CRYPTO_ProviderSaltP *salt;
-
- /**
* Recovery information from the lookup
*/
struct ANASTASIS_RecoveryInformation *ri;
@@ -113,13 +108,19 @@ policy_lookup_cb (void *cls,
{
struct RecoverSecretState *rss = cls;
- rss->ri = (struct ANASTASIS_RecoveryInformation *) ri;
if (NULL == ri)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rss->is);
return;
}
+ if (0 == ri->cs_len)
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (rss->is);
+ return;
+ }
+ rss->ri = (struct ANASTASIS_RecoveryInformation *) ri;
TALER_TESTING_interpreter_next (rss->is);
}
@@ -188,14 +189,14 @@ recover_secret_run (void *cls,
{
struct RecoverSecretState *rss = cls;
const struct TALER_TESTING_Command *ref;
- const struct ANASTASIS_CRYPTO_ProviderSaltP *salt;
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt;
rss->is = is;
if (NULL != rss->download_reference)
{
- ref = TALER_TESTING_interpreter_lookup_command
- (is,
- rss->download_reference);
+ ref = TALER_TESTING_interpreter_lookup_command (
+ is,
+ rss->download_reference);
if (NULL == ref)
{
GNUNET_break (0);
@@ -203,9 +204,8 @@ recover_secret_run (void *cls,
return;
}
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_salt (ref,
- 0,
- &salt))
+ ANASTASIS_TESTING_get_trait_provider_salt (ref,
+ &provider_salt))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rss->is);
@@ -224,24 +224,25 @@ recover_secret_run (void *cls,
return;
}
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_core_secret (ref,
- 0,
- &rss->core_secret))
+ ANASTASIS_TESTING_get_trait_core_secret (
+ ref,
+ &rss->core_secret))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (rss->is);
return;
}
}
- rss->recovery = ANASTASIS_recovery_begin (is->ctx,
- rss->id_data,
- rss->version,
- rss->anastasis_url,
- salt,
- &policy_lookup_cb,
- rss,
- &core_secret_cb,
- rss);
+ rss->recovery = ANASTASIS_recovery_begin (
+ TALER_TESTING_interpreter_get_context (is),
+ rss->id_data,
+ rss->version,
+ rss->anastasis_url,
+ provider_salt,
+ &policy_lookup_cb,
+ rss,
+ &core_secret_cb,
+ rss);
if (NULL == rss->recovery)
{
GNUNET_break (0);
@@ -307,7 +308,7 @@ recover_secret_cleanup (void *cls,
* @param index index number of the object to extract.
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
recover_secret_traits (void *cls,
const void **ret,
const char *trait,
@@ -327,8 +328,9 @@ recover_secret_traits (void *cls,
}
{
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_challenge (index,
- rss->ri->cs[index]),
+ ANASTASIS_TESTING_make_trait_challenges (
+ index,
+ (const struct ANASTASIS_Challenge **) &rss->ri->cs[index]),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_cmd_secret_share.c b/src/testing/testing_cmd_secret_share.c
index d9122e8..3c401d2 100644
--- a/src/testing/testing_cmd_secret_share.c
+++ b/src/testing/testing_cmd_secret_share.c
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -135,14 +135,7 @@ secret_share_result_cb (void *cls,
sss->sso = NULL;
if (sr->ss != sss->want_status)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u to command %s in %s:%u\n",
- sr->ss,
- sss->is->commands[sss->is->ip].label,
- __FILE__,
- __LINE__);
TALER_TESTING_interpreter_fail (sss->is);
- return;
}
switch (sr->ss)
{
@@ -199,7 +192,7 @@ secret_share_run (void *cls,
for (unsigned int i = 0; i < sss->cmd_label_array_length; i++)
{
const struct TALER_TESTING_Command *ref;
- const struct ANASTASIS_Policy *policy;
+ const struct ANASTASIS_Policy **policy;
ref = TALER_TESTING_interpreter_lookup_command (is,
sss->cmd_label_array[i]);
@@ -211,15 +204,14 @@ secret_share_run (void *cls,
}
if (GNUNET_OK !=
ANASTASIS_TESTING_get_trait_policy (ref,
- 0,
&policy))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (sss->is);
return;
}
- GNUNET_assert (NULL != policy);
- policies[i] = policy;
+ GNUNET_assert (NULL != *policy);
+ policies[i] = *policy;
}
}
@@ -238,15 +230,13 @@ secret_share_run (void *cls,
}
if (GNUNET_OK !=
TALER_TESTING_get_trait_order_id (ref,
- 0,
&order_id))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (sss->is);
return;
}
- sss->payment_order_id = (char *) order_id;
-
+ sss->payment_order_id = GNUNET_strdup (order_id);
if (NULL == sss->payment_order_id)
{
GNUNET_break (0);
@@ -277,7 +267,7 @@ secret_share_run (void *cls,
pds.provider_url = sss->anastasis_url;
{
const struct TALER_TESTING_Command *ref;
- const struct ANASTASIS_CRYPTO_ProviderSaltP *salt;
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt;
ref = TALER_TESTING_interpreter_lookup_command (is,
sss->config_ref);
@@ -288,30 +278,30 @@ secret_share_run (void *cls,
return;
}
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_salt (ref,
- 0,
- &salt))
+ ANASTASIS_TESTING_get_trait_provider_salt (ref,
+ &provider_salt))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (sss->is);
return;
}
- pds.provider_salt = *salt;
+ pds.provider_salt = *provider_salt;
}
- sss->sso = ANASTASIS_secret_share (is->ctx,
- sss->id_data,
- &pds,
- 1,
- policies,
- sss->cmd_label_array_length,
- false,
- GNUNET_TIME_UNIT_ZERO,
- &secret_share_result_cb,
- sss,
- "test-case",
- sss->core_secret,
- sss->core_secret_size);
+ sss->sso = ANASTASIS_secret_share (
+ TALER_TESTING_interpreter_get_context (is),
+ sss->id_data,
+ &pds,
+ 1,
+ policies,
+ sss->cmd_label_array_length,
+ false,
+ GNUNET_TIME_UNIT_ZERO,
+ &secret_share_result_cb,
+ sss,
+ "test-case",
+ sss->core_secret,
+ sss->core_secret_size);
if (NULL == sss->sso)
{
GNUNET_break (0);
@@ -368,12 +358,9 @@ secret_share_traits (void *cls,
{
struct SecretShareState *sss = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_claim_token (0,
- &sss->token),
- ANASTASIS_TESTING_make_trait_core_secret (0,
- sss->core_secret),
- TALER_TESTING_make_trait_order_id (0,
- sss->payment_order_id),
+ TALER_TESTING_make_trait_claim_token (&sss->token),
+ ANASTASIS_TESTING_make_trait_core_secret (sss->core_secret),
+ TALER_TESTING_make_trait_order_id (sss->payment_order_id),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_cmd_truth_upload.c b/src/testing/testing_cmd_truth_upload.c
index 19692c8..2e3523b 100644
--- a/src/testing/testing_cmd_truth_upload.c
+++ b/src/testing/testing_cmd_truth_upload.c
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -181,15 +181,15 @@ truth_upload_run (void *cls,
{
struct TruthUploadState *tus = cls;
const struct TALER_TESTING_Command *ref;
- const struct ANASTASIS_CRYPTO_ProviderSaltP *salt;
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt;
struct ANASTASIS_CRYPTO_UserIdentifierP user_id;
tus->is = is;
if (NULL != tus->salt_reference)
{
- ref = TALER_TESTING_interpreter_lookup_command
- (is,
- tus->salt_reference);
+ ref = TALER_TESTING_interpreter_lookup_command (
+ is,
+ tus->salt_reference);
if (NULL == ref)
{
GNUNET_break (0);
@@ -197,33 +197,31 @@ truth_upload_run (void *cls,
return;
}
if (GNUNET_OK !=
- ANASTASIS_TESTING_get_trait_salt (ref,
- 0,
- &salt))
+ ANASTASIS_TESTING_get_trait_provider_salt (ref,
+ &provider_salt))
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (tus->is);
return;
}
}
-
ANASTASIS_CRYPTO_user_identifier_derive (tus->id_data,
- salt,
+ provider_salt,
&user_id);
-
- tus->tuo = ANASTASIS_truth_upload (is->ctx,
- &user_id,
- tus->anastasis_url,
- tus->method,
- tus->instructions,
- tus->mime_type,
- salt,
- tus->truth_data,
- tus->truth_data_size,
- false, /* force payment */
- GNUNET_TIME_UNIT_ZERO,
- &truth_upload_cb,
- tus);
+ tus->tuo = ANASTASIS_truth_upload (
+ TALER_TESTING_interpreter_get_context (is),
+ &user_id,
+ tus->anastasis_url,
+ tus->method,
+ tus->instructions,
+ tus->mime_type,
+ provider_salt,
+ tus->truth_data,
+ tus->truth_data_size,
+ false, /* force payment */
+ GNUNET_TIME_UNIT_ZERO,
+ &truth_upload_cb,
+ tus);
if (NULL == tus->tuo)
{
GNUNET_break (0);
@@ -285,10 +283,9 @@ truth_upload_traits (void *cls,
{
struct TruthUploadState *tus = cls;
struct TALER_TESTING_Trait traits[] = {
- ANASTASIS_TESTING_make_trait_truth (0,
- tus->truth),
- ANASTASIS_TESTING_make_trait_payment_secret (0,
- &tus->payment_secret_response),
+ ANASTASIS_TESTING_make_trait_truth (
+ (const struct ANASTASIS_Truth **) &tus->truth),
+ ANASTASIS_TESTING_make_trait_payment_secret (&tus->payment_secret_response),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_trait_challenge.c b/src/testing/testing_trait_challenge.c
deleted file mode 100644
index f0485a1..0000000
--- a/src/testing/testing_trait_challenge.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_trait_challenge.c
- * @brief traits to offer a challenge
- * @author Christian Grothoff
- * @author Dominik Meister
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_CHALLENGE "anastasis-challenge"
-
-
-int
-ANASTASIS_TESTING_get_trait_challenge (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_Challenge **c)
-{
- return cmd->traits (cmd->cls,
- (const void **) c,
- ANASTASIS_TESTING_TRAIT_CHALLENGE,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_challenge (unsigned int index,
- const struct ANASTASIS_Challenge *c)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_CHALLENGE,
- .ptr = (const void *) c
- };
- return ret;
-}
-
-
-/* end of testing_trait_challenge.c */
diff --git a/src/testing/testing_trait_core_secret.c b/src/testing/testing_trait_core_secret.c
deleted file mode 100644
index e6aee0f..0000000
--- a/src/testing/testing_trait_core_secret.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_trait_core_secret.c
- * @brief traits to offer the core secret
- * @author Christian Grothoff
- * @author Dominik Meister
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_CORE_SECRET "anastasis-core-secret"
-
-
-int
-ANASTASIS_TESTING_get_trait_core_secret (const struct
- TALER_TESTING_Command *cmd,
- unsigned int index,
- const void **s)
-{
- return cmd->traits (cmd->cls,
- s,
- ANASTASIS_TESTING_TRAIT_CORE_SECRET,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_core_secret (unsigned int index,
- const void *s)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_CORE_SECRET,
- .ptr = s
- };
-
- return ret;
-}
-
-
-/* end of testing_trait_core_secret.c */
diff --git a/src/testing/testing_trait_policy.c b/src/testing/testing_trait_policy.c
deleted file mode 100644
index 0944088..0000000
--- a/src/testing/testing_trait_policy.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_trait_policy.c
- * @brief traits to offer a policy
- * @author Christian Grothoff
- * @author Dominik Meister
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_POLICY "anastasis-policy"
-
-
-int
-ANASTASIS_TESTING_get_trait_policy (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_Policy **p)
-{
- return cmd->traits (cmd->cls,
- (const void **) p,
- ANASTASIS_TESTING_TRAIT_POLICY,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_policy (unsigned int index,
- const struct ANASTASIS_Policy *p)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_POLICY,
- .ptr = (const void *) p
- };
-
- return ret;
-}
-
-
-/* end of testing_trait_policy.c */
diff --git a/src/testing/testing_trait_truth.c b/src/testing/testing_trait_truth.c
deleted file mode 100644
index 559fd9e..0000000
--- a/src/testing/testing_trait_truth.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Anastasis SARL
-
- Anastasis is free software; you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public
- License along with Anastasis; see the file COPYING. If not, see
- <http://www.gnu.org/licenses/>
-*/
-/**
- * @file testing/testing_trait_truth.c
- * @brief traits to offer a truth
- * @author Christian Grothoff
- * @author Dominik Meister
- * @author Dennis Neufeld
- */
-#include "platform.h"
-#include "anastasis_testing_lib.h"
-
-#define ANASTASIS_TESTING_TRAIT_TRUTH "anastasis-truth"
-
-
-int
-ANASTASIS_TESTING_get_trait_truth (const struct TALER_TESTING_Command *cmd,
- unsigned int index,
- const struct ANASTASIS_Truth **t)
-{
- return cmd->traits (cmd->cls,
- (const void **) t,
- ANASTASIS_TESTING_TRAIT_TRUTH,
- index);
-}
-
-
-struct TALER_TESTING_Trait
-ANASTASIS_TESTING_make_trait_truth (unsigned int index,
- const struct ANASTASIS_Truth *t)
-{
- struct TALER_TESTING_Trait ret = {
- .index = index,
- .trait_name = ANASTASIS_TESTING_TRAIT_TRUTH,
- .ptr = (const void *) t
- };
-
- return ret;
-}
-
-
-/* end of testing_trait_truth.c */
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 22c7a1c..29d2b13 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -26,6 +26,9 @@ anastasis-config: anastasis-config.in
chmod a-w+x $@.tmp && \
mv $@.tmp $@
+CLEANFILES = \
+ anastasis-config
+
bin_SCRIPTS = \
anastasis-config
@@ -34,7 +37,8 @@ lib_LTLIBRARIES = \
libanastasisutil_la_SOURCES = \
anastasis_crypto.c \
- os_installation.c
+ os_installation.c \
+ pin.c
libanastasisutil_la_LIBADD = \
-lgnunetutil \
$(LIBGCRYPT_LIBS) \
diff --git a/src/util/anastasis-config.c b/src/util/anastasis-config.c
index 0c2cb29..34574d1 100644
--- a/src/util/anastasis-config.c
+++ b/src/util/anastasis-config.c
@@ -3,16 +3,16 @@
Copyright (C) 2012-2021 Anastasis Systems SA
Anastasis is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
+ under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Affero General Public License for more details.
+ General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
+ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
SPDX-License-Identifier: AGPL3.0-or-later
diff --git a/src/util/anastasis-config.in b/src/util/anastasis-config.in
index 0e94921..6657540 100644
--- a/src/util/anastasis-config.in
+++ b/src/util/anastasis-config.in
@@ -7,6 +7,7 @@ if ! type gnunet-config >/dev/null; then
exit 1
fi
-GC=`which gnunet-config`
-export LD_PRELOAD=${LD_PRELOAD:-}:%libdir%/libanastasisutil.so
+GC=$(which gnunet-config)
+SO=$(ls %libdir%/libanastasisutil.so.* | sort -n | tail -n1)
+export LD_PRELOAD=${LD_PRELOAD:-}:${SO}
exec gnunet-config "$@"
diff --git a/src/util/anastasis-crypto-tvg.c b/src/util/anastasis-crypto-tvg.c
index b426ee5..d5fc4c1 100644
--- a/src/util/anastasis-crypto-tvg.c
+++ b/src/util/anastasis-crypto-tvg.c
@@ -3,14 +3,14 @@
Copyright (C) 2020,2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
@@ -134,24 +134,6 @@ d2j_append (json_t *arr,
d, \
sizeof (*d));
-/**
- * Add a number to a test vector.
- *
- * @param vec test vector to add to
- * @param label label for the value
- * @param data data to add
- * @param size size of data
- */
-static void
-uint2j (json_t *vec,
- const char *label,
- unsigned int num)
-{
- json_t *json = json_integer (num);
-
- json_object_set_new (vec, label, json);
-}
-
static int
expect_data_fixed (json_t *vec,
@@ -356,7 +338,7 @@ output_vectors ()
{
json_t *vec = vec_for (vecs, "user_identifier_derive");
- struct ANASTASIS_CRYPTO_ProviderSaltP server_salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
struct ANASTASIS_CRYPTO_UserIdentifierP id;
json_t *id_data = json_pack ("{s:s, s:s}",
"name",
@@ -364,13 +346,13 @@ output_vectors ()
"ssn",
"AB123");
GNUNET_assert (NULL != id_data);
- random_auto (&server_salt);
+ random_auto (&provider_salt);
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- &server_salt,
+ &provider_salt,
&id);
json_object_set_new (vec, "input_id_data", id_data);
- d2j_auto (vec, "input_server_salt", &server_salt);
+ d2j_auto (vec, "input_provider_salt", &provider_salt);
d2j_auto (vec, "output_id", &id);
}
diff --git a/src/util/anastasis_crypto.c b/src/util/anastasis_crypto.c
index f5e6c77..579f097 100644
--- a/src/util/anastasis_crypto.c
+++ b/src/util/anastasis_crypto.c
@@ -3,14 +3,14 @@
Copyright (C) 2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify it under the
- terms of the GNU Lesser General Public License as published by the Free Software
+ terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public License along with
+ You should have received a copy of the GNU General Public License along with
Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
*/
/**
@@ -41,6 +41,10 @@ ANASTASIS_hash_answer (uint64_t code,
GNUNET_CRYPTO_hash (cbuf,
strlen (cbuf),
hashed_code);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Hashed answer %llu to %s\n",
+ (unsigned long long) code,
+ GNUNET_h2s (hashed_code));
}
@@ -91,28 +95,23 @@ derive_key (const void *key_material,
const char *salt,
struct ANASTASIS_CRYPTO_SymKeyP *key)
{
- if (GNUNET_YES !=
- GNUNET_CRYPTO_kdf (key,
- sizeof (struct ANASTASIS_CRYPTO_SymKeyP),
- /* salt / XTS */
- nonce,
- sizeof (struct ANASTASIS_CRYPTO_NonceP),
- /* ikm */
- key_material,
- key_m_len,
- /* info chunks */
- /* The "salt" passed here is actually not something random,
- but a protocol-specific identifier string. Thus
- we pass it as a context info to the HKDF */
- salt,
- strlen (salt),
- NULL,
- 0))
- {
- // FIXME: Huh?! Why would we continue here?
- GNUNET_break (0);
- return;
- }
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (key,
+ sizeof (*key),
+ /* salt / XTS */
+ nonce,
+ sizeof (*nonce),
+ /* ikm */
+ key_material,
+ key_m_len,
+ /* info chunks */
+ /* The "salt" passed here is actually not something random,
+ but a protocol-specific identifier string. Thus
+ we pass it as a context info to the HKDF */
+ salt,
+ strlen (salt),
+ NULL,
+ 0));
}
@@ -170,8 +169,9 @@ anastasis_encrypt (const struct ANASTASIS_CRYPTO_NonceP *nonce,
* @param salt salt value which is used for key derivation
* @param[out] res plaintext output
* @param[out] res_size size of the plaintext
+ * @return #GNUNET_OK on success
*/
-static void
+static enum GNUNET_GenericReturnValue
anastasis_decrypt (const void *key,
size_t key_len,
const void *data,
@@ -184,8 +184,11 @@ anastasis_decrypt (const void *key,
struct ANASTASIS_CRYPTO_SymKeyP skey;
size_t plaintext_size;
- GNUNET_assert (data_size >= crypto_secretbox_NONCEBYTES
- + crypto_secretbox_MACBYTES);
+ if (data_size < crypto_secretbox_NONCEBYTES + crypto_secretbox_MACBYTES)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
nonce = data;
derive_key (key,
key_len,
@@ -204,14 +207,16 @@ anastasis_decrypt (const void *key,
{
GNUNET_break (0);
GNUNET_free (*res);
+ return GNUNET_SYSERR;
}
+ return GNUNET_OK;
}
void
ANASTASIS_CRYPTO_user_identifier_derive (
const json_t *id_data,
- const struct ANASTASIS_CRYPTO_ProviderSaltP *server_salt,
+ const struct ANASTASIS_CRYPTO_ProviderSaltP *provider_salt,
struct ANASTASIS_CRYPTO_UserIdentifierP *id)
{
char *json_enc;
@@ -220,7 +225,7 @@ ANASTASIS_CRYPTO_user_identifier_derive (
json_enc = json_dumps (id_data,
JSON_COMPACT | JSON_SORT_KEYS);
GNUNET_assert (NULL != json_enc);
- GNUNET_CRYPTO_pow_hash (&server_salt->salt,
+ GNUNET_CRYPTO_pow_hash (&provider_salt->salt,
json_enc,
strlen (json_enc),
&hash);
@@ -332,9 +337,9 @@ ANASTASIS_CRYPTO_keyshare_encrypt (
sizeof (nonce));
anastasis_encrypt (&nonce,
id,
- sizeof (struct ANASTASIS_CRYPTO_UserIdentifierP),
+ sizeof (*id),
key_share,
- sizeof (struct ANASTASIS_CRYPTO_KeyShareP),
+ sizeof (*key_share),
(NULL == xsalt) ? salt : xsalt,
&eks,
&eks_size);
@@ -359,9 +364,9 @@ ANASTASIS_CRYPTO_keyshare_decrypt (
void *ks = NULL;
anastasis_decrypt (id,
- sizeof (struct ANASTASIS_CRYPTO_UserIdentifierP),
+ sizeof (*id),
enc_key_share,
- sizeof (struct ANASTASIS_CRYPTO_EncryptedKeyShareP),
+ sizeof (*enc_key_share),
(NULL == xsalt) ? salt : xsalt,
&ks,
&ks_size);
@@ -505,18 +510,6 @@ ANASTASIS_CRYPTO_core_secret_encrypt (
}
-/**
- * Decrypts the core secret with the master key. First the master key is decrypted with the provided policy key.
- * Afterwards the core secret is encrypted with the master key. The core secret is returned.
- *
- * @param encrypted_master_key master key for decrypting the core secret, is itself encrypted by the policy key
- * @param encrypted_master_key_size size of the encrypted master key
- * @param policy_key built policy key which will decrypt the master key
- * @param encrypted_core_secret the encrypted core secret from the user, will be encrypted with the policy key
- * @param encrypted_core_secret_size size of the encrypted core secret
- * @param[out] core_secret decrypted core secret will be returned
- * @param[out] core_secret_size size of core secret
- */
void
ANASTASIS_CRYPTO_core_secret_recover (
const void *encrypted_master_key,
@@ -561,11 +554,6 @@ ANASTASIS_CRYPTO_core_secret_recover (
}
-/**
- * Destroy a core secret encryption result.
- *
- * @param cser the result to destroy
- */
void
ANASTASIS_CRYPTO_destroy_encrypted_core_secret (
struct ANASTASIS_CoreSecretEncryptionResult *cser)
@@ -579,4 +567,65 @@ ANASTASIS_CRYPTO_destroy_encrypted_core_secret (
}
+const char *
+ANASTASIS_CRYPTO_uuid2s (const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid)
+{
+ static char uuids[7];
+ char *tpk;
+
+ tpk = GNUNET_STRINGS_data_to_string_alloc (uuid,
+ sizeof (*uuid));
+ memcpy (uuids,
+ tpk,
+ sizeof (uuids) - 1);
+ GNUNET_free (tpk);
+ return uuids;
+}
+
+
+void
+ANASTASIS_CRYPTO_recovery_metadata_encrypt (
+ const struct ANASTASIS_CRYPTO_UserIdentifierP *id,
+ const void *meta_data,
+ size_t meta_data_size,
+ void **enc_meta_data,
+ size_t *enc_meta_data_size)
+{
+ const char *salt = "rmd";
+ struct ANASTASIS_CRYPTO_NonceP nonce;
+
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ &nonce,
+ sizeof (nonce));
+ anastasis_encrypt (&nonce,
+ id,
+ sizeof (*id),
+ meta_data,
+ meta_data_size,
+ salt,
+ enc_meta_data,
+ enc_meta_data_size);
+}
+
+
+enum GNUNET_GenericReturnValue
+ANASTASIS_CRYPTO_recovery_metadata_decrypt (
+ const struct ANASTASIS_CRYPTO_UserIdentifierP *id,
+ const void *enc_meta_data,
+ size_t enc_meta_data_size,
+ void **meta_data,
+ size_t *meta_data_size)
+{
+ const char *salt = "rmd";
+
+ return anastasis_decrypt (id,
+ sizeof (*id),
+ enc_meta_data,
+ enc_meta_data_size,
+ salt,
+ meta_data,
+ meta_data_size);
+}
+
+
/* end of anastasis_crypto.c */
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index a23182e..cfcf3c3 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -3,7 +3,7 @@
Copyright (C) 2019, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
+ it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
@@ -12,7 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
+ You should have received a copy of the GNU General Public License
along with Anastasis; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
diff --git a/src/util/pin.c b/src/util/pin.c
new file mode 100644
index 0000000..0285bb0
--- /dev/null
+++ b/src/util/pin.c
@@ -0,0 +1,84 @@
+/*
+ This file is part of GNU Anastasis.
+ Copyright (C) 2021 Anastasis SARL
+
+ Anastasis 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 Foundation; either version 3, or (at your
+ option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Anastasis; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/**
+ * @file anastasis/src/util/pin.c
+ * @brief pin conversion functions
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "anastasis_util_lib.h"
+
+
+bool
+ANASTASIS_scan_pin (const char *as,
+ unsigned long long *pin)
+{
+ char dummy;
+ char s[16];
+
+ if ( (NULL != as) &&
+ (0 == strncasecmp ("A-", as, 2)) )
+ as += 2; /* skip "A-" prefix if present */
+ if (strlen (as) != 18)
+ return false;
+ if ( ('-' != as[5]) ||
+ ('-' != as[9]) ||
+ ('-' != as[14]) )
+ return false;
+ GNUNET_snprintf (s,
+ sizeof (s),
+ "%.5s%.3s%.4s%.3s",
+ as,
+ &as[6],
+ &as[10],
+ &as[15]);
+ if (1 != sscanf (s,
+ "%llu%c",
+ pin,
+ &dummy))
+ {
+ GNUNET_break (0);
+ return false;
+ }
+ return true;
+}
+
+
+const char *
+ANASTASIS_pin2s (uint64_t pin)
+{
+ static char buf[22];
+ char tmp[16];
+
+ GNUNET_assert (pin < ANASTASIS_PIN_MAX_VALUE);
+ GNUNET_snprintf (tmp,
+ sizeof (tmp),
+ "%015llu",
+ (unsigned long long) pin);
+ GNUNET_snprintf (buf,
+ sizeof (buf),
+ "A-%.5s-%.3s-%.4s-%.3s",
+ tmp,
+ &tmp[5],
+ &tmp[8],
+ &tmp[12]);
+ return buf;
+}
diff --git a/src/util/test_anastasis_crypto.c b/src/util/test_anastasis_crypto.c
index 428aebf..6132e35 100644
--- a/src/util/test_anastasis_crypto.c
+++ b/src/util/test_anastasis_crypto.c
@@ -3,16 +3,16 @@
Copyright (C) 2014-2020 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
+ it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or
(at your option) any later version.
Anastasis is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU Affero General Public
+ You should have received a copy of the GNU General Public
License along with Anastasis; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>
*/
@@ -41,11 +41,11 @@ test_user_identifier_derive (void)
struct ANASTASIS_CRYPTO_UserIdentifierP id_1;
struct ANASTASIS_CRYPTO_UserIdentifierP id_2;
struct ANASTASIS_CRYPTO_UserIdentifierP id_3;
- struct ANASTASIS_CRYPTO_ProviderSaltP server_salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
char *salt_str = "Server-Salt-Test";
- GNUNET_memcpy (&server_salt,
+ GNUNET_memcpy (&provider_salt,
salt_str,
strlen (salt_str));
// sample data 1
@@ -59,13 +59,13 @@ test_user_identifier_derive (void)
json_object_set_new (id_data_3, "arg1", json_string ("Hallo2"));
ANASTASIS_CRYPTO_user_identifier_derive (id_data_1,
- &server_salt,
+ &provider_salt,
&id_1);
ANASTASIS_CRYPTO_user_identifier_derive (id_data_2,
- &server_salt,
+ &provider_salt,
&id_2);
ANASTASIS_CRYPTO_user_identifier_derive (id_data_3,
- &server_salt,
+ &provider_salt,
&id_3);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"UserIdentifier_1: %s\n",
@@ -97,19 +97,19 @@ test_recovery_document (void)
void *plaintext;
size_t size_plaintext;
struct ANASTASIS_CRYPTO_UserIdentifierP id;
- struct ANASTASIS_CRYPTO_ProviderSaltP server_salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
int ret;
json_t *id_data = json_object ();
const char *test = "TEST_ERD";
char *salt_str = "Server-Salt-Test";
- GNUNET_memcpy (&server_salt,
+ GNUNET_memcpy (&provider_salt,
salt_str,
strlen (salt_str));
json_object_set_new (id_data, "arg1", json_string ("ID_DATA"));
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- &server_salt,
+ &provider_salt,
&id);
ANASTASIS_CRYPTO_recovery_document_encrypt (&id,
test,
@@ -296,17 +296,17 @@ test_public_key_derive (void)
{
struct ANASTASIS_CRYPTO_UserIdentifierP id;
struct ANASTASIS_CRYPTO_AccountPublicKeyP pub_key;
- struct ANASTASIS_CRYPTO_ProviderSaltP server_salt;
+ struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
json_t *id_data = json_object ();
const char *salt_str = "Server-Salt-Test";
- GNUNET_memcpy (&server_salt,
+ GNUNET_memcpy (&provider_salt,
salt_str,
strlen (salt_str));
json_object_set_new (id_data, "arg1", json_string ("ID_DATA"));
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
- &server_salt,
+ &provider_salt,
&id);
ANASTASIS_CRYPTO_account_public_key_derive (&id,