1 /* 2 * gpg.h 3 * vim: expandtab:ts=4:sts=4:sw=4 4 * 5 * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com> 6 * 7 * This file is part of Profanity. 8 * 9 * Profanity is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * Profanity is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with Profanity. If not, see <https://www.gnu.org/licenses/>. 21 * 22 * In addition, as a special exception, the copyright holders give permission to 23 * link the code of portions of this program with the OpenSSL library under 24 * certain conditions as described in each individual source file, and 25 * distribute linked combinations including the two. 26 * 27 * You must obey the GNU General Public License in all respects for all of the 28 * code used other than OpenSSL. If you modify file(s) with this exception, you 29 * may extend this exception to your version of the file(s), but you are not 30 * obligated to do so. If you do not wish to do so, delete this exception 31 * statement from your version. If you delete this exception statement from all 32 * source files in the program, then also delete it here. 33 * 34 */ 35 36 #ifndef PGP_GPG_H 37 #define PGP_GPG_H 38 39 typedef struct pgp_key_t 40 { 41 char* id; 42 char* name; 43 char* fp; 44 gboolean encrypt; 45 gboolean sign; 46 gboolean certify; 47 gboolean authenticate; 48 gboolean secret; 49 } ProfPGPKey; 50 51 typedef struct pgp_pubkeyid_t 52 { 53 char* id; 54 gboolean received; 55 } ProfPGPPubKeyId; 56 57 void p_gpg_init(void); 58 void p_gpg_close(void); 59 void p_gpg_on_connect(const char* const barejid); 60 void p_gpg_on_disconnect(void); 61 GHashTable* p_gpg_list_keys(void); 62 void p_gpg_free_keys(GHashTable* keys); 63 gboolean p_gpg_addkey(const char* const jid, const char* const keyid); 64 GHashTable* p_gpg_pubkeys(void); 65 gboolean p_gpg_valid_key(const char* const keyid, char** err_str); 66 gboolean p_gpg_available(const char* const barejid); 67 const char* p_gpg_libver(void); 68 char* p_gpg_sign(const char* const str, const char* const fp); 69 void p_gpg_verify(const char* const barejid, const char* const sign); 70 char* p_gpg_encrypt(const char* const barejid, const char* const message, const char* const fp); 71 char* p_gpg_decrypt(const char* const cipher); 72 void p_gpg_free_decrypted(char* decrypted); 73 char* p_gpg_autocomplete_key(const char* const search_str, gboolean previous, void* context); 74 void p_gpg_autocomplete_key_reset(void); 75 char* p_gpg_format_fp_str(char* fp); 76 77 char* p_ox_gpg_signcrypt(const char* const sender_barejid, const char* const recipient_barejid, const char* const message); 78 79 char* p_ox_gpg_decrypt(char* base64); 80 81 void p_ox_gpg_readkey(const char* const filename, char** key, char** fp); 82 gboolean p_ox_gpg_import(char* base64_public_key); 83 84 /*! 85 * \brief List of public keys with xmpp-URI. 86 * 87 * @returns GHashTable* with GString* xmpp-uri and ProfPGPKey* value. Empty 88 * hash, if there is no key. NULL in case of error. 89 * 90 */ 91 GHashTable* ox_gpg_public_keys(void); 92 93 gboolean ox_is_private_key_available(const char* const barejid); 94 gboolean ox_is_public_key_available(const char* const barejid); 95 96 #endif 97