diff options
| author | Werner Koch <[email protected]> | 2026-05-17 12:59:42 +0200 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2026-05-17 12:59:42 +0200 |
| commit | 8081d34e5f620a614f58617700f9b473392e6478 (patch) | |
| tree | 6322bb0a23a303ccc71e6c313856ab5dcca654ca /src/engine-gpgsm.c | |
| parent | engine:gpgconf: Increase the buffer size. (diff) | |
| download | gpgme-8081d34e5f620a614f58617700f9b473392e6478.tar.gz gpgme-8081d34e5f620a614f58617700f9b473392e6478.zip | |
Support setting attributes for CMS signatures.
* src/gpgme.h.in (GPGME_SIG_NOTATION_UNPROTECTED): New.
(struct _gpgme_sig_notation): Add field 'unprotected'.
* src/sig-notation.c (sig_notation_set_flags): Set flag.
* src/engine-gpgsm.c (gpgsm_sign): Implement setting of notations.
* tests/run-support.h: Add conversion macros.
* tests/run-sign.c (struct mystringlist_s): New.
(xmalloc): New.
(xstrtokenize): New.
(print_result): Add arg fp and adjust callers.
(main): Add options --binary and --notation.
Diffstat (limited to 'src/engine-gpgsm.c')
| -rw-r--r-- | src/engine-gpgsm.c | 43 |
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; |
