Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Paste
P6
get_micalg (from mutt)
Active
Public
Actions
Authored by
•
werner
on Feb 14 2018, 12:18 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
/* Find the "micalg" parameter from the last Gpgme operation on
context CTX. It is expected that this operation was a sign
operation. Return the algorithm name as a C string in buffer BUF
which must have been allocated by the caller with size BUFLEN.
Returns 0 on success or -1 in case of an error. The return string
is truncted to BUFLEN - 1. */
static int get_micalg (gpgme_ctx_t ctx, int use_smime, char *buf, size_t buflen)
{
gpgme_sign_result_t result = NULL;
const char *algorithm_name = NULL;
if (buflen < 5)
return -1;
*buf = 0;
result = gpgme_op_sign_result (ctx);
if (result && result->signatures)
{
algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo);
if (algorithm_name)
{
if (use_smime)
{
/* convert GPGME raw hash name to RFC 2633 format */
snprintf (buf, buflen, "%s", algorithm_name);
ascii_strlower (buf);
} else {
/* convert GPGME raw hash name to RFC 3156 format */
snprintf (buf, buflen, "pgp-%s", algorithm_name);
ascii_strlower (buf + 4);
}
}
}
return *buf? 0:-1;
}
Event Timeline
•
werner
created this paste.
Feb 14 2018, 12:18 PM
2018-02-14 12:18:43 (UTC+1)
Log In to Comment