diff options
Diffstat (limited to 'src/include/anastasis_crypto_lib.h')
-rw-r--r-- | src/include/anastasis_crypto_lib.h | 69 |
1 files changed, 63 insertions, 6 deletions
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); |