secret.h (3308B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2026 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 /* 21 * @author Tobias Frisch 22 * @file secret.h 23 */ 24 25 #ifndef SECRET_H_ 26 #define SECRET_H_ 27 28 #include <gnunet/gnunet_chat_lib.h> 29 #include <stdbool.h> 30 #include <stdint.h> 31 32 #include "application.h" 33 34 typedef void (*MESSENGER_SecretCallback)( 35 MESSENGER_Application *application, 36 const char *secret, 37 uint32_t secret_len, 38 gboolean success, 39 gboolean error, 40 gpointer user_data 41 ); 42 43 typedef struct MESSENGER_SecretOperation { 44 MESSENGER_Application *application; 45 46 MESSENGER_SecretCallback callback; 47 GCancellable *cancellable; 48 gpointer user_data; 49 gboolean ownership; 50 51 char *secret; 52 uint32_t secret_len; 53 } MESSENGER_SecretOperation; 54 55 /** 56 * Lookup a secret from identity with 57 * a given name. 58 * 59 * @param[in] name Identity name 60 * @param[out] secret_len Length of secret 61 * @return Secret or NULL 62 */ 63 MESSENGER_SecretOperation* 64 secret_operation_lookup(MESSENGER_Application *application, 65 const char *name, 66 MESSENGER_SecretCallback callback, 67 gpointer user_data); 68 69 /** 70 * Stores a secret for identity with 71 * a given name. 72 * 73 * @param[in] name Identity name 74 * @param[in] secret Secret 75 * @param[in] secret_len Length of secret 76 * @return Whether the storage was successful 77 */ 78 MESSENGER_SecretOperation* 79 secret_operation_store(MESSENGER_Application *application, 80 const char *name, 81 const char *secret, 82 uint32_t secret_len, 83 MESSENGER_SecretCallback callback, 84 gpointer user_data); 85 86 MESSENGER_SecretOperation* 87 secret_operation_generate(MESSENGER_Application *application, 88 const char *name, 89 MESSENGER_SecretCallback callback, 90 gpointer user_data); 91 92 /** 93 * Delete a secret from identity with 94 * a given name. 95 * 96 * @param[in] name Identity name 97 * @return Whether the deletion was successful 98 */ 99 MESSENGER_SecretOperation* 100 secret_operation_delete(MESSENGER_Application *application, 101 const char *name, 102 MESSENGER_SecretCallback callback, 103 gpointer user_data); 104 105 void 106 secret_operation_own_user_data(MESSENGER_SecretOperation *op); 107 108 void 109 secret_operation_cancel(MESSENGER_SecretOperation *op); 110 111 void 112 secret_operation_cleanup(MESSENGER_SecretOperation *op); 113 114 void 115 secret_operation_drop(MESSENGER_SecretOperation *op); 116 117 void 118 secret_operation_destroy(MESSENGER_SecretOperation *op); 119 120 #endif /* SECRET_H_ */