messenger-cli

Command-line user interface for GNUnet Messenger
Log | Files | Refs | README | LICENSE

secret.h (1904B)


      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 <stdbool.h>
     29 #include <stdint.h>
     30 
     31 #include <libsecret/secret.h>
     32 
     33 /**
     34  * Lookup a secret from identity with
     35  * a given name.
     36  *
     37  * @param[in] name Identity name
     38  * @param[out] secret_len Length of secret
     39  * @return Secret or NULL
     40  */
     41 char*
     42 secret_lookup(const char *name,
     43               uint32_t *secret_len);
     44 
     45 /**
     46  * Stores a secret for identity with
     47  * a given name.
     48  *
     49  * @param[in] name Identity name
     50  * @param[in] secret Secret
     51  * @param[in] secret_len Length of secret
     52  * @return Whether the storage was successful
     53  */
     54 bool
     55 secret_store(const char *name,
     56              const char *secret,
     57              uint32_t secret_len);
     58 
     59 /**
     60  * Delete a secret from identity with
     61  * a given name.
     62  *
     63  * @param[in] name Identity name
     64  * @return Whether the deletion was successful
     65  */
     66 bool
     67 secret_delete(const char *name);
     68 
     69 /**
     70  * Wipe a secret from memory.
     71  *
     72  * @param[out] secret
     73  */
     74 void
     75 secret_wipe(char *secret);
     76 
     77 /**
     78  * Wipe and free a secret from memory.
     79  *
     80  * @param[out] secret
     81  */
     82 void
     83 secret_free(char *secret);
     84 
     85 #endif /* SECRET_H_ */