summaryrefslogtreecommitdiffstats
path: root/src/engine-gpgsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine-gpgsm.c')
-rw-r--r--src/engine-gpgsm.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index 94edab6b..21d6329b 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -2243,6 +2243,8 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
char *assuan_cmd;
int i;
gpgme_key_t key;
+ gpgme_sig_notation_t notation;
+ int any_notations;
(void)use_textmode;
@@ -2275,6 +2277,47 @@ gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out,
return err;
}
+ /* Setup attributes. */
+ any_notations = 0;
+ for (notation = gpgme_sig_notation_get (ctx);
+ notation; notation = notation->next)
+ {
+ if (!notation->name || !*notation->name)
+ continue; /* We always require a name. */
+ if (*notation->name == '_')
+ {
+ /* System attribute - use verbatim. */
+ assuan_cmd = _gpgme_strconcat
+ (!any_notations? "SETATTR --clear ": "SETATTR ",
+ notation->name, NULL);
+ if (!assuan_cmd)
+ return gpg_error_from_syserror ();
+ }
+ else if (!notation->value || !*notation->value)
+ {
+ /* Note that a regular attribute requires a value. */
+ return gpg_error (GPG_ERR_INV_VALUE);
+ }
+ else
+ {
+ /* FIXME: Handle long attribute values. */
+ assuan_cmd = _gpgme_strconcat
+ (!any_notations? "SETATTR --clear ": "SETATTR ",
+ notation->name,
+ notation->flags & GPGME_SIG_NOTATION_UNPROTECTED? ":u:":":s:",
+ notation->value, NULL);
+ if (!assuan_cmd)
+ return gpg_error_from_syserror ();
+ }
+ err = gpgsm_assuan_simple_command (gpgsm, assuan_cmd, NULL, NULL);
+ free (assuan_cmd);
+ assuan_cmd = NULL;
+ if (err)
+ return err;
+ any_notations = 1; /* Do not use --clear the next round. */
+ }
+
+
for (i = 0; (key = gpgme_signers_enum (ctx, i)); i++)
{
const char *s = key->subkeys ? key->subkeys->fpr : NULL;