anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit 7815ced57e8849465e9d821ea8c8e9d705efd0ca
parent 157efff4973ed4e6837fabd5e7397cc6e578d9a0
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 16 Nov 2021 15:05:29 +0100

generate shorter UUID strings for interaction with users (#7089)

Diffstat:
Msrc/authorization/anastasis_authorization_plugin_email.c | 20++++++--------------
Msrc/authorization/anastasis_authorization_plugin_post.c | 21++++++---------------
Msrc/authorization/anastasis_authorization_plugin_sms.c | 17++++-------------
Msrc/include/anastasis_crypto_lib.h | 13+++++++++++++
Msrc/util/anastasis_crypto.c | 25+++++++++++++++++++++++++
5 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c @@ -374,20 +374,12 @@ email_process (struct ANASTASIS_AUTHORIZATION_State *as, 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"), + (unsigned long long) as->code, + ANASTASIS_crypto_uuid2s (&as->truth_uuid)); { const char *off = as->msg; diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c @@ -448,21 +448,12 @@ post_process (struct ANASTASIS_AUTHORIZATION_State *as, 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"), + (unsigned long long) as->code, + ANASTASIS_CRYPTO_uuid2s (&as->truth_uuid)); { const char *off = as->msg; size_t left = strlen (off); diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c @@ -373,19 +373,10 @@ sms_process (struct ANASTASIS_AUTHORIZATION_State *as, 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, + "A-%llu\nAnastasis\n: %s", + (unsigned long long) as->code, + ANASTASIS_CRYPTO_uuid2s (&as->truth_uuid)); { const char *off = as->msg; size_t left = strlen (off); diff --git a/src/include/anastasis_crypto_lib.h b/src/include/anastasis_crypto_lib.h @@ -543,3 +543,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/util/anastasis_crypto.c b/src/util/anastasis_crypto.c @@ -579,4 +579,29 @@ ANASTASIS_CRYPTO_destroy_encrypted_core_secret ( } +/** + * 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) +{ + 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; +} + + /* end of anastasis_crypto.c */