50 gpgme_error_t err = gpgme_new(ctx);
52 err = gpgme_ctx_set_engine_info(*ctx, GPGME_PROTOCOL_OpenPGP, NULL,
C_AutocryptDir);
55 mutt_error(
_(
"error creating GPGME context: %s"), gpgme_strerror(err));
82 gpgme_data_t dh = NULL;
83 gpgme_key_t export_keys[2] = { 0 };
84 size_t export_data_len;
86 if (gpgme_data_new(&dh))
91 if (gpgme_data_set_encoding (dh, GPGME_DATA_ENCODING_BASE64))
96 export_keys[1] = NULL;
97 if (gpgme_op_export_keys(ctx, export_keys, GPGME_EXPORT_MODE_MINIMAL, dh))
100 char *export_data = gpgme_data_release_and_get_mem(dh, &export_data_len);
104 gpgme_free(export_data);
110 gpgme_data_release(dh);
122 int mutt_autocrypt_gpgme_export_key(
const char *keyid,
struct Buffer *keydata)
125 gpgme_ctx_t ctx = NULL;
126 gpgme_key_t key = NULL;
131 if (gpgme_get_key(ctx, keyid, &key, 0))
139 gpgme_key_unref(key);
157 gpgme_ctx_t ctx = NULL;
158 gpgme_genkey_result_t keyresult = NULL;
159 gpgme_key_t primary_key = NULL;
160 char buf[1024] = { 0 };
176 gpgme_error_t err = gpgme_op_createkey(ctx, buf,
"ed25519", 0, 0, NULL,
177 GPGME_CREATE_NOPASSWD | GPGME_CREATE_FORCE |
178 GPGME_CREATE_NOEXPIRE);
183 mutt_error(
_(
"Error creating autocrypt key: %s"), gpgme_strerror(err));
186 keyresult = gpgme_op_genkey_result(ctx);
198 err = gpgme_op_createsubkey(ctx, primary_key,
"cv25519", 0, 0,
199 GPGME_CREATE_NOPASSWD | GPGME_CREATE_NOEXPIRE);
202 mutt_error(
_(
"Error creating autocrypt key: %s"), gpgme_strerror(err));
214 gpgme_key_unref(primary_key);
229 gpgme_ctx_t ctx = NULL;
230 gpgme_key_t key = NULL;
242 if (key->revoked || key->expired || key->disabled || key->invalid ||
243 !key->can_encrypt || !key->can_sign)
260 gpgme_key_unref(key);
281 const char *prompt =
_(
"(c)reate new, or (s)elect existing GPG key?");
284 const char *letters =
_(
"cs");
317 gpgme_ctx_t ctx = NULL;
318 gpgme_data_t dh = NULL;
333 if (gpgme_op_import(ctx, dh))
336 gpgme_import_result_t result = gpgme_op_import_result(ctx);
337 if (!result->imports || !result->imports->fpr)
344 gpgme_data_release(dh);
358 gpgme_ctx_t ctx = NULL;
359 gpgme_key_t key = NULL;
367 if (gpgme_get_key(ctx, keyid, &key, 0))
371 if (key->revoked || key->expired || key->disabled || key->invalid || !key->can_encrypt)
375 gpgme_key_unref(key);
Convenience wrapper for the gui headers.
char * C_AutocryptDir
Config: Location of autocrypt files, including the GPG keyring and SQLite database.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
int mutt_autocrypt_gpgme_init(void)
Initialise GPGME.
static int export_keydata(gpgme_ctx_t ctx, gpgme_key_t key, struct Buffer *keydata)
Export Key data from GPGME into a Buffer.
#define mutt_message(...)
int mutt_autocrypt_gpgme_create_key(struct Address *addr, struct Buffer *keyid, struct Buffer *keydata)
Create a GPGME key.
void pgp_gpgme_init(void)
Implements CryptModuleSpecs::init()
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
String manipulation buffer.
WHERE bool OptAutocryptGpgme
(pseudo) use Autocrypt context inside ncrypt/crypt_gpgme.c
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
void mutt_addr_free(struct Address **ptr)
Free a single Address.
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
int mutt_autocrypt_gpgme_select_key(struct Buffer *keyid, struct Buffer *keydata)
Select a Autocrypt key.
size_t mutt_b64_buffer_encode(struct Buffer *buf, const char *in, size_t len)
Convert raw bytes to null-terminated base64 string.
Convenience wrapper for the config headers.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
int mutt_autocrypt_gpgme_select_or_create_key(struct Address *addr, struct Buffer *keyid, struct Buffer *keydata)
Ask the user to select or create an Autocrypt key.
static int create_gpgme_context(gpgme_ctx_t *ctx)
Create a GPGME context.
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
Write a single Address to a buffer.
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
bool mutt_autocrypt_gpgme_is_valid_key(const char *keyid)
Is a key id valid?
int mutt_gpgme_select_secret_key(struct Buffer *keyid)
Select a private Autocrypt key for a new account.
Shared constants/structs that are private to Autocrypt.
int mutt_b64_buffer_decode(struct Buffer *buf, const char *in)
Convert null-terminated base64 string to raw bytes.
API for encryption/signing of emails.
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
User answered 'No', or assume 'No'.
Handling of global boolean variables.
#define mutt_debug(LEVEL,...)
Convenience wrapper for the library headers.
User answered 'Yes', or assume 'Yes'.
int mutt_autocrypt_gpgme_import_key(const char *keydata, struct Buffer *keyid)
Read a key from GPGME.