Signing data with user specified Key
Werner Koch
wk at gnupg.org
Thu Sep 14 17:48:37 CEST 2017
On Thu, 14 Sep 2017 14:26, sandhya.sharma at morpho.com said:
> I am using GPG4Win and have to sign data with a specified key through
> my code in C++.But I didn't find much help on how to specify key for
> signing data in GPG
You need to put the signer into the context. See this secion in the
gpgme manual:
7.7.4.1 Selecting Signers
.........................
The key or the keys used to create a signature are stored in the
context. The following functions can be used to manipulate this list.
If no signer has been set into the context a default key is used for
signing.
-- Function: void gpgme_signers_clear (gpgme_ctx_t CTX)
The function ‘gpgme_signers_clear’ releases a reference for each
key on the signers list and removes the list of signers from the
context CTX.
Every context starts with an empty list.
-- Function: gpgme_error_t gpgme_signers_add (gpgme_ctx_t CTX,
const gpgme_key_t KEY)
The function ‘gpgme_signers_add’ adds the key KEY to the list of
signers in the context CTX.
Calling this function acquires an additional reference for the key.
[...]
There is also an example program: gpgme/tests/run-sign.c
Shalom-Salam,
Werner
--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: </pipermail/attachments/20170914/476b911e/attachment.sig>
More information about the Gnupg-users
mailing list