2002-01-16 00:41:10 +00:00
|
|
|
\input texinfo @c -*- Texinfo -*-
|
|
|
|
@setfilename gpgme.info
|
|
|
|
@settitle The `GnuPG Made Easy' Reference Manual
|
|
|
|
|
|
|
|
@dircategory GNU Libraries
|
|
|
|
@direntry
|
2002-04-16 12:24:02 +00:00
|
|
|
* @acronym{GPGME}: (gpgme). Adding support for cryptography to your program.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end direntry
|
|
|
|
|
|
|
|
@include version.texi
|
|
|
|
|
|
|
|
@c Unify some of the indices.
|
|
|
|
@syncodeindex tp fn
|
|
|
|
@syncodeindex pg fn
|
|
|
|
|
|
|
|
@ifinfo
|
|
|
|
This file documents the @acronym{GPGME} library.
|
|
|
|
|
|
|
|
This is Edition @value{EDITION}, last updated @value{UPDATED}, of
|
|
|
|
@cite{The `GnuPG Made Easy' Reference Manual}, for Version
|
|
|
|
@value{VERSION}.
|
|
|
|
|
|
|
|
Copyright @copyright{} 2002 g10 Code GmbH.
|
|
|
|
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
|
|
under the terms of the GNU Free Documentation License, Version 1.1 or
|
|
|
|
any later version published by the Free Software Foundation; with the
|
|
|
|
Invariant Sections being ``Free Software Needs Free Documentation'' and
|
|
|
|
``GNU Lesser General Public License'', the Front-Cover texts being (a)
|
|
|
|
(see below), and with the Back-Cover Texts being (b) (see below). A
|
|
|
|
copy of the license is included in the section entitled ``GNU Free
|
|
|
|
Documentation License''.
|
|
|
|
|
|
|
|
@end ifinfo
|
|
|
|
|
|
|
|
@iftex
|
|
|
|
@shorttitlepage The `GnuPG Made Easy' Reference Manual
|
|
|
|
@end iftex
|
|
|
|
@titlepage
|
|
|
|
@center @titlefont{The `GnuPG Made Easy'}
|
|
|
|
@sp 1
|
|
|
|
@center @titlefont{Reference Manual}
|
|
|
|
@sp 6
|
|
|
|
@center Edition @value{EDITION}
|
|
|
|
@sp 1
|
|
|
|
@center last updated @value{UPDATED}
|
|
|
|
@sp 1
|
|
|
|
@center for version @value{VERSION}
|
|
|
|
@page
|
|
|
|
@vskip 0pt plus 1filll
|
2002-01-22 14:25:40 +00:00
|
|
|
Copyright @copyright{} 2002 g10 Code GmbH.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
|
|
under the terms of the GNU Free Documentation License, Version 1.1 or
|
|
|
|
any later version published by the Free Software Foundation; with the
|
|
|
|
Invariant Sections being ``Free Software Needs Free Documentation'' and
|
|
|
|
``GNU Lesser General Public License'', the Front-Cover texts being (a)
|
|
|
|
(see below), and with the Back-Cover Texts being (b) (see below). A
|
|
|
|
copy of the license is included in the section entitled ``GNU Free
|
|
|
|
Documentation License''.
|
|
|
|
@end titlepage
|
|
|
|
@page
|
|
|
|
|
|
|
|
@ifnottex
|
|
|
|
@node Top
|
|
|
|
@top Main Menu
|
|
|
|
This is Edition @value{EDITION}, last updated @value{UPDATED}, of
|
|
|
|
@cite{The `GnuPG Made Easy' Reference Manual}, for Version
|
2002-01-16 00:52:37 +00:00
|
|
|
@value{VERSION} of the @acronym{GPGME} library.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end ifnottex
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* Introduction:: How to use this manual.
|
2002-01-30 01:43:05 +00:00
|
|
|
* Preparation:: What you should do before using the library.
|
2002-01-16 00:41:10 +00:00
|
|
|
* Protocols and Engines:: Supported crypto protocols.
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
* Algorithms:: Supported algorithms.
|
2002-01-16 00:41:10 +00:00
|
|
|
* Error Handling:: Error numbers and their meanings.
|
|
|
|
* Exchanging Data:: Passing data to and from @acronym{GPGME}.
|
|
|
|
* Contexts:: Handling @acronym{GPGME} contexts.
|
|
|
|
|
|
|
|
Appendices
|
|
|
|
|
|
|
|
* Copying:: The GNU General Public License says how you
|
|
|
|
can copy and share `GnuPG Made Easy'.
|
|
|
|
* Free Documentation License:: This manual is under the GNU Free
|
|
|
|
Documentation License.
|
|
|
|
|
|
|
|
Indices
|
|
|
|
|
|
|
|
* Concept Index:: Index of concepts and programs.
|
|
|
|
* Function and Data Index:: Index of functions, variables and data types.
|
|
|
|
|
|
|
|
|
|
|
|
@detailmenu
|
|
|
|
--- The Detailed Node Listing ---
|
|
|
|
|
|
|
|
Introduction
|
|
|
|
|
|
|
|
* Getting Started:: Purpose of the manual, and how to use it.
|
|
|
|
* Features:: Reasons to install and use @acronym{GPGME}.
|
|
|
|
* Overview:: Basic architecture of the @acronym{GPGME} library.
|
|
|
|
|
2002-01-30 01:43:05 +00:00
|
|
|
Preparation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
* Header:: What header file you need to include.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Building the Source:: Compiler options to be used.
|
2002-05-09 06:49:40 +00:00
|
|
|
* Using Automake:: Compiler options to be used the easy way.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Library Version Check:: Getting and verifying the library version.
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
* Multi Threading:: How @acronym{GPGME} can be used in an MT environment.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Protocols and Engines
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Engine Version Check:: Verifying the engine version.
|
|
|
|
* Engine Information:: Obtaining more information about the engines.
|
2002-01-16 00:41:10 +00:00
|
|
|
* OpenPGP:: Support for the OpenPGP protocol.
|
|
|
|
* Cryptographic Message Syntax:: Support for the CMS.
|
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
Algorithms
|
|
|
|
|
|
|
|
* Public Key Algorithms:: A list of all public key algorithms.
|
|
|
|
* Hash Algorithms:: A list of all hash algorithms.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
Error Handling
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Error Values:: A list of all error values used.
|
|
|
|
* Error Strings:: How to get a descriptive string from a value.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Exchanging Data
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Creating Data Buffers:: Creating new data buffers.
|
|
|
|
* Destroying Data Buffers:: Releasing data buffers.
|
|
|
|
* Manipulating Data Buffers:: Operations on data buffers.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
Creating Data Buffers
|
|
|
|
|
|
|
|
* Memory Based Data Buffers:: Creating memory based data buffers.
|
|
|
|
* File Based Data Buffers:: Creating file based data buffers.
|
|
|
|
* Callback Based Data Buffers:: Creating callback based data buffers.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
Contexts
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Creating Contexts:: Creating new @acronym{GPGME} contexts.
|
|
|
|
* Destroying Contexts:: Releasing @acronym{GPGME} contexts.
|
|
|
|
* Context Attributes:: Setting properties of a context.
|
2002-01-16 00:41:10 +00:00
|
|
|
* Key Management:: Managing keys with @acronym{GPGME}.
|
|
|
|
* Trust Item Management:: Managing trust items with @acronym{GPGME}.
|
|
|
|
* Crypto Operations:: Using a context for cryptography.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Run Control:: Controlling how operations are run.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
Context Attributes
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Protocol Selection:: Selecting the protocol used by a context.
|
|
|
|
* @acronym{ASCII} Armor:: Requesting @acronym{ASCII} armored output.
|
|
|
|
* Text Mode:: Choosing canonical text mode.
|
2002-02-25 18:31:07 +00:00
|
|
|
* Included Certificates:: Including a number of certificates.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Key Listing Mode:: Selecting key listing mode.
|
|
|
|
* Passphrase Callback:: Getting the passphrase from the user.
|
|
|
|
* Progress Meter Callback:: Being informed about the progress.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Key Management
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Listing Keys:: Browsing the list of available keys.
|
|
|
|
* Information About Keys:: Requesting detailed information about keys.
|
2002-12-23 17:12:48 +00:00
|
|
|
* Key Signatures:: Listing the signatures on a key.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Manipulating Keys:: Operations on keys.
|
|
|
|
* Generating Keys:: Creating new key pairs.
|
|
|
|
* Exporting Keys:: Retrieving key data from the key ring.
|
2002-01-30 01:17:30 +00:00
|
|
|
* Importing Keys:: Adding keys to the key ring.
|
|
|
|
* Deleting Keys:: Removing keys from the key ring.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Trust Item Management
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Listing Trust Items:: Browsing the list of available trust items.
|
2003-05-18 20:45:24 +00:00
|
|
|
* Information About Trust Items:: Requesting information about trust items.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Manipulating Trust Items:: Operations on trust items.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Crypto Operations
|
|
|
|
|
|
|
|
* Decrypt:: Decrypting a ciphertext.
|
|
|
|
* Verify:: Verifying a signature.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Decrypt and Verify:: Decrypting a signed ciphertext.
|
2002-01-16 00:41:10 +00:00
|
|
|
* Sign:: Creating a signature.
|
|
|
|
* Encrypt:: Encrypting a plaintext.
|
|
|
|
|
|
|
|
Sign
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Selecting Signers:: How to choose the keys to sign with.
|
|
|
|
* Creating a Signature:: How to create a signature.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-16 00:54:39 +00:00
|
|
|
Encrypt
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Selecting Recipients:: How to choose the recipients.
|
|
|
|
* Encrypting a Plaintext:: How to encrypt a plaintext.
|
|
|
|
|
|
|
|
Run Control
|
2002-01-16 00:54:39 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
* Waiting For Completion:: Waiting until an operation is completed.
|
2002-07-03 02:22:38 +00:00
|
|
|
* Using External Event Loops:: Advanced control over what happens when.
|
|
|
|
|
|
|
|
Using External Event Loops
|
|
|
|
|
|
|
|
* I/O Callback Interface:: How I/O callbacks are registered.
|
|
|
|
* Registering I/O Callbacks:: How to use I/O callbacks for a context.
|
|
|
|
* I/O Callback Example:: An example how to use I/O callbacks.
|
|
|
|
* I/O Callback Example GTK+:: How to integrate @acronym{GPGME} in GTK+.
|
|
|
|
* I/O Callback Example GDK:: How to integrate @acronym{GPGME} in GDK.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@end detailmenu
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node Introduction
|
|
|
|
@chapter Introduction
|
|
|
|
|
|
|
|
`GnuPG Made Easy' (@acronym{GPGME}) is a C language library that
|
|
|
|
allows to add support for cryptography to a program. It is designed
|
|
|
|
to make access to crypto engines like GnuPG or GpgSM easier for
|
|
|
|
applications. @acronym{GPGME} provides a high-level crypto API for
|
|
|
|
encryption, decryption, signing, signature verification and key
|
|
|
|
management.
|
|
|
|
|
|
|
|
@acronym{GPGME} uses GnuPG and GpgSM as its backends to support
|
2002-01-30 01:43:05 +00:00
|
|
|
OpenPGP and the Cryptographic Message Syntax (CMS).
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@menu
|
|
|
|
* Getting Started:: Purpose of the manual, and how to use it.
|
|
|
|
* Features:: Reasons to install and use @acronym{GPGME}.
|
|
|
|
* Overview:: Basic architecture of the @acronym{GPGME} library.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node Getting Started
|
|
|
|
@section Getting Started
|
|
|
|
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
This manual documents the @acronym{GPGME} library programming
|
2002-01-16 00:41:10 +00:00
|
|
|
interface. All functions and data types provided by the library are
|
|
|
|
explained.
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
The reader is assumed to possess basic knowledge about cryptography in
|
2002-01-16 00:41:10 +00:00
|
|
|
general, and public key cryptography in particular. The underlying
|
|
|
|
cryptographic engines that are used by the library are not explained,
|
|
|
|
but where necessary, special features or requirements by an engine are
|
|
|
|
mentioned as far as they are relevant to @acronym{GPGME} or its users.
|
|
|
|
|
|
|
|
This manual can be used in several ways. If read from the beginning
|
|
|
|
to the end, it gives a good introduction into the library and how it
|
|
|
|
can be used in an application. Forward references are included where
|
|
|
|
necessary. Later on, the manual can be used as a reference manual to
|
|
|
|
get just the information needed about any particular interface of the
|
|
|
|
library. Experienced programmers might want to start looking at the
|
|
|
|
examples at the end of the manual, and then only read up those parts
|
|
|
|
of the interface which are unclear.
|
|
|
|
|
|
|
|
|
|
|
|
@node Features
|
|
|
|
@section Features
|
|
|
|
|
|
|
|
@acronym{GPGME} has a couple of advantages over other libraries doing
|
|
|
|
a similar job, and over implementing support for GnuPG or other crypto
|
|
|
|
engines into your application directly.
|
|
|
|
|
|
|
|
@table @asis
|
|
|
|
@item it's free software
|
|
|
|
Anybody can use, modify, and redistribute it under the terms of the GNU
|
|
|
|
General Public License (@pxref{Copying}).
|
|
|
|
|
|
|
|
@item it's flexible
|
|
|
|
@acronym{GPGME} provides transparent support for several cryptographic
|
|
|
|
protocols by different engines. Currently, @acronym{GPGME} supports
|
|
|
|
the OpenPGP protocol using GnuPG as the backend, and the Cryptographic
|
|
|
|
Message Syntax using GpgSM as the backend.
|
|
|
|
|
|
|
|
@item it's easy
|
|
|
|
@acronym{GPGME} hides the differences between the protocols and
|
|
|
|
engines from the programmer behind an easy-to-use interface. This way
|
|
|
|
the programmer can focus on the other parts of the program, and still
|
|
|
|
integrate strong cryptography in his application. Once support for
|
|
|
|
@acronym{GPGME} has been added to a program, it is easy to add support
|
|
|
|
for other crypto protocols once @acronym{GPGME} backends provide them.
|
|
|
|
@end table
|
|
|
|
|
|
|
|
|
|
|
|
@node Overview
|
|
|
|
@section Overview
|
|
|
|
|
|
|
|
@acronym{GPGME} provides a data abstraction that is used to pass data
|
|
|
|
to the crypto engine, and receive returned data from it. Data can be
|
|
|
|
read from memory or from files, but it can also be provided by a
|
|
|
|
callback function.
|
|
|
|
|
|
|
|
The actual cryptographic operations are always set within a context.
|
|
|
|
A context provides configuration parameters that define the behaviour
|
|
|
|
of all operations performed within it. Only one operation per context
|
|
|
|
is allowed at any time, but when one operation is finished, you can
|
|
|
|
run the next operation in the same context. There can be more than
|
|
|
|
one context, and all can run different operations at the same time.
|
|
|
|
|
|
|
|
Furthermore, @acronym{GPGME} has rich key management facilities
|
|
|
|
including listing keys, querying their attributes, generating,
|
|
|
|
importing, exporting and deleting keys, and acquiring information
|
|
|
|
about the trust path.
|
|
|
|
|
2002-05-09 03:38:12 +00:00
|
|
|
With some precautions, @acronym{GPGME} can be used in a multi-threaded
|
|
|
|
environment, although it is not completely thread safe and thus needs
|
|
|
|
the support of the application.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
|
2002-01-30 01:43:05 +00:00
|
|
|
@node Preparation
|
|
|
|
@chapter Preparation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
To use @acronym{GPGME}, you have to perform some changes to your
|
|
|
|
sources and the build system. The necessary changes are small and
|
|
|
|
explained in the following sections. At the end of this chapter, it
|
|
|
|
is described how the library is initialized, and how the requirements
|
|
|
|
of the library are verified.
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* Header:: What header file you need to include.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Building the Source:: Compiler options to be used.
|
2002-05-09 06:49:40 +00:00
|
|
|
* Using Automake:: Compiler options to be used the easy way.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Library Version Check:: Getting and verifying the library version.
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
* Multi Threading:: How @acronym{GPGME} can be used in an MT environment.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node Header
|
|
|
|
@section Header
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex header file
|
|
|
|
@cindex include file
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
All interfaces (data types and functions) of the library are defined
|
|
|
|
in the header file `gpgme.h'. You must include this in all programs
|
|
|
|
using the library, either directly or through some other header file,
|
|
|
|
like this:
|
|
|
|
|
|
|
|
@example
|
|
|
|
#include <gpgme.h>
|
|
|
|
@end example
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
The name space of @acronym{GPGME} is @code{gpgme_*} for function names
|
|
|
|
and data types and @code{GPGME_*} for other symbols. Symbols internal
|
|
|
|
to @acronym{GPGME} take the form @code{_gpgme_*} and @code{_GPGME_*}.
|
2002-08-20 23:25:49 +00:00
|
|
|
|
|
|
|
Because @acronym{GPGME} links to the Assuan library, linking to
|
|
|
|
@acronym{GPGME} will also use the @code{assuan_*} and @code{_assuan_*}
|
|
|
|
name space indirectly.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Building the Source
|
|
|
|
@section Building the Source
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex compiler options
|
|
|
|
@cindex compiler flags
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
If you want to compile a source file including the `gpgme.h' header
|
|
|
|
file, you must make sure that the compiler can find it in the
|
|
|
|
directory hierarchy. This is accomplished by adding the path to the
|
|
|
|
directory in which the header file is located to the compilers include
|
|
|
|
file search path (via the @option{-I} option).
|
|
|
|
|
|
|
|
However, the path to the include file is determined at the time the
|
|
|
|
source is configured. To solve this problem, gpgme ships with a small
|
|
|
|
helper program @command{gpgme-config} that knows about the path to the
|
|
|
|
include file and other configuration options. The options that need
|
|
|
|
to be added to the compiler invocation at compile time are output by
|
|
|
|
the @option{--cflags} option to @command{gpgme-config}. The following
|
|
|
|
example shows how it can be used at the command line:
|
|
|
|
|
|
|
|
@example
|
|
|
|
gcc -c foo.c `gpgme-config --cflags`
|
|
|
|
@end example
|
|
|
|
|
|
|
|
Adding the output of @samp{gpgme-config --cflags} to the compilers
|
|
|
|
command line will ensure that the compiler can find the @acronym{GPGME} header
|
|
|
|
file.
|
|
|
|
|
|
|
|
A similar problem occurs when linking the program with the library.
|
|
|
|
Again, the compiler has to find the library files. For this to work,
|
|
|
|
the path to the library files has to be added to the library search
|
|
|
|
path (via the @option{-L} option). For this, the option
|
|
|
|
@option{--libs} to @command{gpgme-config} can be used. For
|
|
|
|
convenience, this option also outputs all other options that are
|
|
|
|
required to link the program with @acronym{GPGME} (in particular, the
|
|
|
|
@samp{-lgpgme} option). The example shows how to link @file{foo.o}
|
|
|
|
with the @acronym{GPGME} library to a program @command{foo}.
|
|
|
|
|
|
|
|
@example
|
|
|
|
gcc -o foo foo.o `gpgme-config --libs`
|
|
|
|
@end example
|
|
|
|
|
|
|
|
Of course you can also combine both examples to a single command by
|
|
|
|
specifying both options to @command{gpgme-config}:
|
|
|
|
|
|
|
|
@example
|
|
|
|
gcc -o foo foo.c `gpgme-config --cflags --libs`
|
|
|
|
@end example
|
|
|
|
|
|
|
|
|
2002-05-09 06:49:40 +00:00
|
|
|
@node Using Automake
|
|
|
|
@section Using Automake
|
|
|
|
@cindex automake
|
|
|
|
@cindex autoconf
|
|
|
|
|
|
|
|
It is much easier if you use GNU Automake instead writing your own
|
|
|
|
Makefiles. If you do that you don't have to worry about finding and
|
|
|
|
invoking the @command{gpgme-config} script at all. @acronym{GPGME}
|
|
|
|
provides an extension to Automake that does all the work for you.
|
|
|
|
|
|
|
|
@c A simple macro for optional variables.
|
|
|
|
@macro ovar{varname}
|
|
|
|
@r{[}@var{\varname\}@r{]}
|
|
|
|
@end macro
|
|
|
|
@defmac AM_PATH_GPGME (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found})
|
|
|
|
Check whether @acronym{GPGME} (at least version @var{minimum-version},
|
|
|
|
if given) exists on the host system. If it is found, execute
|
|
|
|
@var{action-if-found}, otherwise do @var{action-if-not-found}, if
|
|
|
|
given.
|
|
|
|
|
|
|
|
Additionally, the function defines @code{GPGME_CFLAGS} to the flags
|
|
|
|
needed for compilation of the program to find the @file{gpgme.h}
|
|
|
|
header file, and @code{GPGME_LIBS} to the linker flags needed to link
|
|
|
|
the program to the @acronym{GPGME} library.
|
|
|
|
@end defmac
|
|
|
|
|
|
|
|
You can use the defined Autoconf variables like this in your
|
|
|
|
@file{Makefile.am}:
|
|
|
|
|
|
|
|
@example
|
|
|
|
AM_CPPFLAGS = $(GPGME_CFLAGS)
|
|
|
|
LDADD = $(GPGME_LIBS)
|
|
|
|
@end example
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Library Version Check
|
|
|
|
@section Library Version Check
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex version check, of the library
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@deftypefun {const char *} gpgme_check_version (@w{const char *@var{required_version}})
|
|
|
|
The function @code{gpgme_check_version} has three purposes. It can be
|
|
|
|
used to retrieve the version number of the library. In addition it
|
|
|
|
can verify that the version number is higher than a certain required
|
|
|
|
version number. In either case, the function initializes some
|
|
|
|
sub-systems, and for this reason alone it must be invoked early in
|
|
|
|
your program, before you make use of the other functions in
|
|
|
|
@acronym{GPGME}.
|
|
|
|
|
|
|
|
If @var{required_version} is @code{NULL}, the function returns a
|
|
|
|
pointer to a statically allocated string containing the version number
|
|
|
|
of the library.
|
|
|
|
|
|
|
|
If @var{required_version} is not @code{NULL}, it should point to a
|
|
|
|
string containing a version number, and the function checks that the
|
|
|
|
version of the library is at least as high as the version number
|
|
|
|
provided. In this case, the function returns a pointer to a
|
|
|
|
statically allocated string containing the version number of the
|
|
|
|
library. If @var{REQUIRED_VERSION} is not a valid version number, or
|
|
|
|
if the version requirement is not met, the function returns
|
|
|
|
@code{NULL}.
|
|
|
|
|
|
|
|
If you use a version of a library that is backwards compatible with
|
|
|
|
older releases, but contains additional interfaces which your program
|
|
|
|
uses, this function provides a run-time check if the necessary
|
|
|
|
features are provided by the installed version of the library.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-05-09 03:38:12 +00:00
|
|
|
@node Multi Threading
|
|
|
|
@section Multi Threading
|
|
|
|
@cindex thread-safeness
|
|
|
|
@cindex multi-threading
|
|
|
|
|
|
|
|
The @acronym{GPGME} library is not entirely thread-safe, but it can
|
|
|
|
still be used in a multi-threaded environment if some care is taken.
|
|
|
|
If the following requirements are met, there should be no race
|
|
|
|
conditions to worry about:
|
|
|
|
|
|
|
|
@itemize @bullet
|
2002-06-04 12:12:08 +00:00
|
|
|
@item
|
|
|
|
@acronym{GPGME} supports the thread libraries pthread and GNU Pth.
|
|
|
|
The support for this has to be enabled at compile time.
|
|
|
|
@acronym{GPGME} will automatically detect the location in which the
|
|
|
|
thread libraries are installed and activate the support for them.
|
|
|
|
|
|
|
|
Support for other thread libraries is very easy to add. Please
|
|
|
|
contact us if you have the need.
|
|
|
|
|
|
|
|
@item
|
|
|
|
If you link your program dynamically to @acronym{GPGME} and your
|
|
|
|
supported thread library, @acronym{GPGME} will automatically detect
|
2003-05-18 20:45:24 +00:00
|
|
|
the presence of this library and activate its use. You must link to
|
|
|
|
the thread library before linking to @acronym{GPGME}. If you link to
|
2002-06-04 12:12:08 +00:00
|
|
|
both pthread and GNU Pth, @acronym{GPGME} will use the pthread
|
|
|
|
support. This feature requires weak symbol support.
|
|
|
|
|
|
|
|
@item
|
|
|
|
If you link your program statically to @acronym{GPGME}, there is
|
|
|
|
currently no easy way to make sure that @acronym{GPGME} detects the
|
|
|
|
presence of the thread library. This will be solved in a future
|
|
|
|
version.
|
|
|
|
|
2002-05-09 03:38:12 +00:00
|
|
|
@item
|
|
|
|
The function @code{gpgme_check_version} must be called before any
|
2002-06-04 12:12:08 +00:00
|
|
|
other function in the library, because it initializes the thread
|
|
|
|
support subsystem in @acronym{GPGME}. To achieve this in all
|
|
|
|
generality, it is necessary to synchronize the call to this function
|
|
|
|
with all other calls to functions in the library, using the
|
|
|
|
synchronization mechanisms available in your thread library.
|
|
|
|
Otherwise, specific compiler or CPU memory cache optimizations could
|
|
|
|
lead to the situation where a thread is started and uses
|
|
|
|
@acronym{GPGME} before the effects of the initialization are visible
|
|
|
|
for this thread. It doesn't even suffice to call
|
|
|
|
@code{gpgme_check_version} before creating this other
|
2002-05-09 03:38:12 +00:00
|
|
|
thread@footnote{In SMP systems the new thread could be started on
|
|
|
|
another CPU before the effects of the initialization are seen by that
|
|
|
|
CPU's memory cache. Not doing proper synchronization here leads to
|
|
|
|
the same problems the double-checked locking idiom has. You might
|
|
|
|
find that if you don't do proper synchronization, it still works in
|
|
|
|
most configurations. Don't let this fool you. Someday it might lead
|
|
|
|
to subtle bugs when someone tries it on a DEC Alpha or an SMP
|
|
|
|
machine.}.
|
|
|
|
|
|
|
|
For example, if you are using POSIX threads, each thread that wants to
|
|
|
|
call functions in @acronym{GPGME} could call the following function
|
|
|
|
before any function in the library:
|
|
|
|
|
|
|
|
@example
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
initialize_gpgme (void)
|
2002-05-09 03:39:18 +00:00
|
|
|
@{
|
2002-05-09 03:38:12 +00:00
|
|
|
static int gpgme_init;
|
|
|
|
static pthread_mutext_t gpgme_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
pthread_mutex_lock (&gpgme_init_lock);
|
|
|
|
if (!gpgme_init)
|
2002-05-09 03:39:18 +00:00
|
|
|
@{
|
2002-05-09 03:38:12 +00:00
|
|
|
gpgme_check_version ();
|
|
|
|
gpgme_init = 1;
|
2002-05-09 03:39:18 +00:00
|
|
|
@}
|
2002-05-09 03:38:12 +00:00
|
|
|
pthread_mutex_unlock (&gpgme_init_lock);
|
2002-05-09 03:39:18 +00:00
|
|
|
@}
|
2002-05-09 03:38:12 +00:00
|
|
|
@end example
|
|
|
|
|
|
|
|
@item
|
2003-05-18 20:45:24 +00:00
|
|
|
Any @code{gpgme_data_t}, @code{gpgme_ctx_t} and @code{gpgme_recipients_t}
|
2002-05-09 03:38:12 +00:00
|
|
|
object must only be accessed by one thread at a time. If multiple
|
|
|
|
threads want to deal with the same object, the caller has to make sure
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
that operations on that object are fully synchronized.
|
2002-05-09 03:38:12 +00:00
|
|
|
|
|
|
|
@item
|
2002-06-28 01:14:41 +00:00
|
|
|
Only one thread at any time is allowed to call @code{gpgme_wait}. If
|
2002-05-09 03:38:12 +00:00
|
|
|
multiple threads call this function, the caller must make sure that
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
all invocations are fully synchronized. It is safe to start
|
|
|
|
asynchronous operations while a thread is running in gpgme_wait.
|
2002-05-09 03:38:12 +00:00
|
|
|
@end itemize
|
|
|
|
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@node Protocols and Engines
|
|
|
|
@chapter Protocols and Engines
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex protocol
|
|
|
|
@cindex engine
|
|
|
|
@cindex crypto engine
|
|
|
|
@cindex backend
|
|
|
|
@cindex crypto backend
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@acronym{GPGME} supports several cryptographic protocols, however, it
|
|
|
|
does not implement them. Rather it uses backends (also called
|
|
|
|
engines) which implement the protocol. @acronym{GPGME} uses
|
|
|
|
inter-process communication to pass data back and forth between the
|
|
|
|
application and the backend, but the details of the communication
|
|
|
|
protocol and invocation of the backends is completely hidden by the
|
|
|
|
interface. All complexity is handled by @acronym{GPGME}. Where an
|
|
|
|
exchange of information between the application and the backend is
|
|
|
|
necessary, @acronym{GPGME} provides the necessary callback function
|
|
|
|
hooks and further interfaces.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_protocol_t}
|
|
|
|
@tindex gpgme_protocol_t
|
|
|
|
The @code{gpgme_protocol_t} type specifies the set of possible protocol
|
2002-01-16 00:41:10 +00:00
|
|
|
values that are supported by @acronym{GPGME}. The following protocols
|
|
|
|
are supported:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_PROTOCOL_OpenPGP
|
|
|
|
This specifies the OpenPGP protocol.
|
|
|
|
@item GPGME_PROTOCOL_CMS
|
|
|
|
This specifies the Cryptographic Message Syntax.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-01-30 12:01:21 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun const char *gpgme_get_protocol_name (@w{gpgme_protocol_t @var{protocol}})
|
2003-01-30 12:01:21 +00:00
|
|
|
The function @code{gpgme_get_protocol_name} returns a statically
|
|
|
|
allocated string describing the protocol @var{protocol}, or
|
|
|
|
@code{NULL} if the protocol number is not valid.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Engine Version Check:: Verifying the engine version.
|
|
|
|
* Engine Information:: Obtaining more information about the engines.
|
2002-01-16 00:41:10 +00:00
|
|
|
* OpenPGP:: Support for the OpenPGP protocol.
|
|
|
|
* Cryptographic Message Syntax:: Support for the CMS.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Engine Version Check
|
|
|
|
@section Engine Version Check
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex version check, of the engines
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_engine_check_version (@w{gpgme_protocol_t @var{protocol}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_engine_check_version} verifies that the
|
|
|
|
engine implementing the protocol @var{PROTOCOL} is installed in the
|
|
|
|
expected path and meets the version requirement of @acronym{GPGME}.
|
|
|
|
|
|
|
|
This function returns @code{GPGME_No_Error} if the engine is available
|
|
|
|
and @code{GPGME_Invalid_Engine} if it is not.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Engine Information
|
|
|
|
@section Engine Information
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex engine, information about
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_engine_info_t}
|
|
|
|
@tindex gpgme_protocol_t
|
|
|
|
The @code{gpgme_engine_info_t} type specifies a pointer to a structure
|
2003-01-30 11:54:23 +00:00
|
|
|
describing a crypto backend engine. The structure contains the
|
|
|
|
following elements:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_engine_info_t next
|
2003-01-30 11:54:23 +00:00
|
|
|
This is a pointer to the next engine info structure in the linked
|
|
|
|
list, or @code{NULL} if this is the last element.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_protocol_t protocol
|
2003-01-30 11:54:23 +00:00
|
|
|
This is the protocol for which the crypo engine is used. You can
|
|
|
|
convert this to a string with @code{gpgme_get_protocol_name} for
|
|
|
|
printing.
|
|
|
|
|
2003-01-30 13:11:25 +00:00
|
|
|
@item const char *file_name
|
|
|
|
This is a string holding the file name of the executable of the crypto
|
2003-01-30 11:54:23 +00:00
|
|
|
engine. Currently, it is never @code{NULL}, but using @code{NULL} is
|
|
|
|
reserved for future use, so always check before you use it.
|
|
|
|
|
|
|
|
@item const char *version
|
|
|
|
This is a string containing the version number of the crypto engine.
|
|
|
|
It might be @code{NULL} if the version number can not be determined,
|
|
|
|
for example because the executable doesn't exist or is invalid.
|
|
|
|
|
|
|
|
@item const char *req_version
|
|
|
|
This is a string containing the minimum required version number of the
|
|
|
|
crypto engine for @acronym{GPGME} to work correctly. This is the
|
|
|
|
version number that @code{gpgme_engine_check_version} verifies
|
|
|
|
against. Currently, it is never @code{NULL}, but using @code{NULL} is
|
|
|
|
reserved for future use, so always check before you use it.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end table
|
2003-01-30 11:54:23 +00:00
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *info)
|
2003-01-30 11:54:23 +00:00
|
|
|
The function @code{gpgme_get_engine_info} returns a linked list of
|
|
|
|
engine info structures in @var{info}. Each info structure describes
|
|
|
|
one configured crypto backend engine.
|
|
|
|
|
|
|
|
The memory for the info structures is allocated the first time this
|
|
|
|
function is invoked, and must not be freed by the caller.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-01-30 11:54:23 +00:00
|
|
|
This function returns @code{GPGME_No_Error} if successful, and
|
|
|
|
@code{GPGME_Out_Of_Core} if not enough memory is available for the
|
|
|
|
operation.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-01-30 11:54:23 +00:00
|
|
|
Here is the example how you can provide more diagnostics if you
|
|
|
|
receive an error message which indicates that the crypto engine is
|
|
|
|
invalid.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_ctx_t ctx;
|
|
|
|
gpgme_error_t err;
|
2003-01-30 11:54:23 +00:00
|
|
|
|
|
|
|
[...]
|
|
|
|
|
|
|
|
if (err == GPGME_Invalid_Engine)
|
|
|
|
@{
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_engine_info_t info;
|
2003-01-30 11:54:23 +00:00
|
|
|
err = gpgme_get_engine_info (&info);
|
|
|
|
if (!err)
|
|
|
|
@{
|
|
|
|
while (info && info->protocol != gpgme_get_protocol (ctx))
|
|
|
|
info = info->next;
|
|
|
|
if (!info)
|
|
|
|
fprintf (stderr, "GPGME compiled without support for protocol %s",
|
|
|
|
gpgme_get_protocol_name (info->protocol));
|
|
|
|
else if (info->path && !info->version)
|
|
|
|
fprintf (stderr, "Engine %s not installed properly",
|
|
|
|
info->path);
|
|
|
|
else if (info->path && info->version && info->req_version)
|
|
|
|
fprintf (stderr, "Engine %s version %s installed, "
|
|
|
|
"but at least version %s required", info->path,
|
|
|
|
info->version, info->req_version);
|
|
|
|
else
|
|
|
|
fprintf (stderr, "Unknown problem with engine for protocol %s",
|
|
|
|
gpgme_get_protocol_name (info->protocol));
|
|
|
|
@}
|
|
|
|
@}
|
2002-01-16 00:41:10 +00:00
|
|
|
@end example
|
|
|
|
|
|
|
|
|
|
|
|
@node OpenPGP
|
|
|
|
@section OpenPGP
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex OpenPGP
|
|
|
|
@cindex GnuPG
|
|
|
|
@cindex protocol, GnuPG
|
|
|
|
@cindex engine, GnuPG
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
OpenPGP is implemented by GnuPG, the @acronym{GNU} Privacy Guard.
|
|
|
|
This is the first protocol that was supported by @acronym{GPGME}.
|
|
|
|
|
|
|
|
The OpenPGP protocol is specified by @code{GPGME_PROTOCOL_OpenPGP}.
|
|
|
|
|
|
|
|
|
|
|
|
@node Cryptographic Message Syntax
|
|
|
|
@section Cryptographic Message Syntax
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex CMS
|
|
|
|
@cindex cryptographic message syntax
|
|
|
|
@cindex GpgSM
|
|
|
|
@cindex protocol, CMS
|
|
|
|
@cindex engine, GpgSM
|
|
|
|
@cindex S/MIME
|
|
|
|
@cindex protocol, S/MIME
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@acronym{CMS} is implemented by GpgSM, the S/MIME implementation for
|
|
|
|
GnuPG.
|
|
|
|
|
|
|
|
The @acronym{CMS} protocol is specified by @code{GPGME_PROTOCOL_CMS}.
|
|
|
|
|
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
@node Algorithms
|
|
|
|
@chapter Algorithms
|
|
|
|
@cindex algorithms
|
|
|
|
|
|
|
|
The crypto backends support a variety of algorithms used in public key
|
|
|
|
cryptography. The following sections list the identifiers used to
|
|
|
|
denote such an algorithm.
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* Public Key Algorithms:: A list of all public key algorithms.
|
|
|
|
* Hash Algorithms:: A list of all hash algorithms.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node Public Key Algorithms
|
|
|
|
@section Public Key Algorithms
|
|
|
|
@cindex algorithms, public key
|
|
|
|
@cindex public key algorithms
|
|
|
|
|
|
|
|
Public key algorithms are used for encryption, decryption, signing and
|
|
|
|
verification of signatures.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_pubkey_algo_t}
|
|
|
|
@tindex gpgme_pubkey_algo_t
|
|
|
|
The @code{gpgme_pubkey_algo_t} type specifies the set of all public key
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
algorithms that are supported by @acronym{GPGME}. Possible values
|
|
|
|
are:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_PK_RSA
|
|
|
|
This value indicates the RSA (Rivest, Shamir, Adleman) algorithm.
|
|
|
|
|
|
|
|
@item GPGME_PK_RSA_E
|
|
|
|
Deprecated. This value indicates the RSA (Rivest, Shamir, Adleman)
|
|
|
|
algorithm for encryption and decryption only.
|
|
|
|
|
|
|
|
@item GPGME_PK_RSA_S
|
|
|
|
Deprecated. This value indicates the RSA (Rivest, Shamir, Adleman)
|
|
|
|
algorithm for signing and verification only.
|
|
|
|
|
|
|
|
@item GPGME_PK_DSA
|
|
|
|
This value indicates DSA, the Digital Signature Algorithm.
|
|
|
|
|
|
|
|
@item GPGME_PK_ELG
|
|
|
|
This value indicates ElGamal.
|
|
|
|
|
|
|
|
@item GPGME_PK_ELG_E
|
|
|
|
This value also indicates ElGamal and is used specifically in GnuPG.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_pubkey_algo_name (@w{gpgme_pubkey_algo_t @var{algo}})
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The function @code{gpgme_pubkey_algo_name} returns a pointer to a
|
|
|
|
statically allocated string containing a description of the public key
|
|
|
|
algorithm @var{algo}. This string can be used to output the name of
|
|
|
|
the public key algorithm to the user.
|
|
|
|
|
|
|
|
If @var{algo} is not a valid public key algorithm, @code{NULL} is
|
|
|
|
returned.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
@node Hash Algorithms
|
|
|
|
@section Hash Algorithms
|
|
|
|
@cindex algorithms, hash
|
|
|
|
@cindex algorithms, message digest
|
|
|
|
@cindex hash algorithms
|
|
|
|
@cindex message digest algorithms
|
|
|
|
|
|
|
|
Hash (message digest) algorithms are used to compress a long message
|
|
|
|
to make it suitable for public key cryptography.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_hash_algo_t}
|
|
|
|
@tindex gpgme_hash_algo_t
|
|
|
|
The @code{gpgme_hash_algo_t} type specifies the set of all hash algorithms
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
that are supported by @acronym{GPGME}. Possible values are:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_MD_MD5
|
|
|
|
@item GPGME_MD_SHA1
|
|
|
|
@item GPGME_MD_RMD160
|
|
|
|
@item GPGME_MD_MD2
|
|
|
|
@item GPGME_MD_TIGER
|
|
|
|
@item GPGME_MD_HAVAL
|
|
|
|
@item GPGME_MD_SHA256
|
|
|
|
@item GPGME_MD_SHA384
|
|
|
|
@item GPGME_MD_SHA512
|
|
|
|
@item GPGME_MD_MD4
|
|
|
|
@item GPGME_MD_CRC32
|
|
|
|
@item GPGME_MD_CRC32_RFC1510
|
|
|
|
@item GPGME_MD_CRC24_RFC2440
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_hash_algo_name (@w{gpgme_hash_algo_t @var{algo}})
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The function @code{gpgme_hash_algo_name} returns a pointer to a
|
|
|
|
statically allocated string containing a description of the hash
|
|
|
|
algorithm @var{algo}. This string can be used to output the name of
|
|
|
|
the hash algorithm to the user.
|
|
|
|
|
|
|
|
If @var{algo} is not a valid hash algorithm, @code{NULL} is returned.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@node Error Handling
|
|
|
|
@chapter Error Handling
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex error handling
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Many functions in @acronym{GPGME} can return an error if they fail.
|
|
|
|
For this reason, the application should always catch the error
|
|
|
|
condition and take appropriate measures, for example by releasing the
|
|
|
|
resources and passing the error up to the caller, or by displaying a
|
|
|
|
descriptive message to the user and cancelling the operation.
|
|
|
|
|
|
|
|
Some error values do not indicate a system error or an error in the
|
|
|
|
operation, but the result of an operation that failed properly. For
|
|
|
|
example, if you try to decrypt a tempered message, the decryption will
|
|
|
|
fail. Another error value actually means that the end of a data
|
|
|
|
buffer or list has been reached. The following descriptions explain
|
|
|
|
what each error message means in general. Some error values have
|
|
|
|
specific meanings if returned by a specific function. Such cases are
|
|
|
|
described in the documentation of those functions.
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Error Values:: A list of all error values used.
|
|
|
|
* Error Strings:: How to get a descriptive string from a value.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Error Values
|
|
|
|
@section Error Values
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex error values, list of
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_error_t}
|
|
|
|
@tindex gpgme_error_t
|
|
|
|
The @code{gpgme_error_t} type specifies the set of all error values that
|
2002-01-16 00:41:10 +00:00
|
|
|
are used by @acronym{GPGME}. Possible values are:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_EOF
|
|
|
|
This value indicates the end of a list, buffer or file.
|
|
|
|
|
|
|
|
@item GPGME_No_Error
|
|
|
|
This value indicates success. The value of this error is @code{0}.
|
|
|
|
|
|
|
|
@item GPGME_General_Error
|
|
|
|
This value means that something went wrong, but either there is not
|
|
|
|
enough information about the problem to return a more useful error
|
2002-01-30 01:43:05 +00:00
|
|
|
value, or there is no separate error value for this type of problem.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_Out_Of_Core
|
2002-01-30 01:43:05 +00:00
|
|
|
This value means that an out-of-memory condition occurred.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_Invalid_Value
|
|
|
|
This value means that some user provided data was out of range. This
|
2003-05-18 20:45:24 +00:00
|
|
|
can also refer to objects. For example, if an empty @code{gpgme_data_t}
|
2002-01-16 00:41:10 +00:00
|
|
|
object was expected, but one containing data was provided, this error
|
|
|
|
value is returned.
|
|
|
|
|
|
|
|
@item GPGME_Exec_Error
|
2002-01-30 01:43:05 +00:00
|
|
|
This value means that an error occurred when trying to spawn a child
|
2002-01-16 00:41:10 +00:00
|
|
|
process.
|
|
|
|
|
|
|
|
@item GPGME_Too_Many_Procs
|
|
|
|
This value means that there are too many active backend processes.
|
|
|
|
|
|
|
|
@item GPGME_Pipe_Error
|
|
|
|
This value means that the creation of a pipe failed.
|
|
|
|
|
2003-04-24 14:33:13 +00:00
|
|
|
@item GPGME_No_UserID
|
2002-02-26 23:39:58 +00:00
|
|
|
This value means that no valid recipients for a message have been set.
|
|
|
|
|
2003-04-24 14:33:13 +00:00
|
|
|
@item GPGME_Invalid_UserID
|
2002-02-26 23:39:58 +00:00
|
|
|
This value means that some, but not all, recipients for a message have
|
|
|
|
been invalid.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_No_Data
|
2003-05-18 20:45:24 +00:00
|
|
|
This value means that a @code{gpgme_data_t} object which was expected to
|
2002-01-16 00:41:10 +00:00
|
|
|
have content was found empty.
|
|
|
|
|
|
|
|
@item GPGME_Conflict
|
2002-01-30 01:43:05 +00:00
|
|
|
This value means that a conflict of some sort occurred.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_Not_Implemented
|
|
|
|
This value indicates that the specific function (or operation) is not
|
|
|
|
implemented. This error should never happen. It can only occur if
|
|
|
|
you use certain values or configuration options which do not work,
|
|
|
|
but for which we think that they should work at some later time.
|
|
|
|
|
|
|
|
@item GPGME_Read_Error
|
|
|
|
This value means that an I/O read operation failed.
|
|
|
|
|
|
|
|
@item GPGME_Write_Error
|
|
|
|
This value means that an I/O write operation failed.
|
|
|
|
|
|
|
|
@item GPGME_File_Error
|
|
|
|
This value means that a file I/O operation failed. The value of
|
2002-12-06 22:06:25 +00:00
|
|
|
@var{errno} contains the system error value.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_Decryption_Failed
|
|
|
|
This value indicates that a decryption operation was unsuccessful.
|
|
|
|
|
2003-04-24 14:33:13 +00:00
|
|
|
@item GPGME_Bad_Passphrase
|
|
|
|
This value means that the user did not provide a correct passphrase
|
|
|
|
when requested.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_Canceled
|
|
|
|
This value means that the operation was canceled.
|
|
|
|
|
|
|
|
@item GPGME_Invalid_Key
|
|
|
|
This value means that a key was invalid.
|
|
|
|
|
|
|
|
@item GPGME_Invalid_Engine
|
|
|
|
This value means that the engine that implements the desired protocol
|
|
|
|
is currently not available. This can either be because the sources
|
|
|
|
were configured to exclude support for this engine, or because the
|
|
|
|
engine is not installed properly.
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Deleting Keys): Document
GPGME_Ambiguous_Specification.
(Error Values): Remove GPGME_Invalid_Type and GPGME_Invalid_Mode.
Add GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* delete.c: Include <errno.h> and "gpgme.h", but not "util.h" or
"key.h".
(enum delete_problem): Move into function delete_status_handler.
(delete_status_handler): Change first argument to void *. Parse
delete problem with strtol instead atoi. Return better error
values.
(_gpgme_op_delete_start): Rename to ...
(delete_start): ... this. Rework error handling.
(gpgme_op_delete_start): Use delete_start instead
_gpgme_op_delete_start.
(gpgme_op_delete): Likewise.
* gpgme.h (GpgmeDataType): Removed.
2003-04-27 17:35:42 +00:00
|
|
|
|
|
|
|
@item GPGME_Unknown_Reason
|
|
|
|
This value indicates that a user ID was invalid but the exact reason
|
|
|
|
is not specified.
|
|
|
|
|
|
|
|
@item GPGME_Not_Found
|
|
|
|
This value indicates that a user ID was not found.
|
|
|
|
|
|
|
|
@item GPGME_Ambiguous_Specification
|
|
|
|
This value indicates that a user ID did not specify a unique key.
|
|
|
|
|
|
|
|
@item GPGME_Wrong_Key_Usage
|
|
|
|
This value indicates that a key is not used appropriately.
|
|
|
|
|
|
|
|
@item GPGME_Key_Revoked
|
|
|
|
This value indicates that a key was revoced.
|
|
|
|
|
|
|
|
@item GPGME_Key_Expired
|
|
|
|
This value indicates that a key was expired.
|
|
|
|
|
|
|
|
@item GPGME_No_CRL_Known
|
|
|
|
This value indicates that no certificate revocation list is known for
|
|
|
|
the certificate.
|
|
|
|
|
|
|
|
@item GPGME_Policy_Mismatch
|
|
|
|
This value indicates that a policy issue occured.
|
|
|
|
|
|
|
|
@item GPGME_No_Secret_Key
|
|
|
|
This value indicates that no secret key for the user ID is available.
|
|
|
|
|
|
|
|
@item GPGME_Key_Not_Trusted
|
|
|
|
This value indicates that the key with the user ID is not trusted.
|
|
|
|
|
|
|
|
@item GPGME_Issuer_Missing
|
|
|
|
This value indicates that a key could not be imported because there is
|
|
|
|
no issuer
|
|
|
|
|
|
|
|
@item GPGME_Chain_Too_Long
|
|
|
|
This value indicates that a key could not be imported because its
|
|
|
|
certificate chain is too long.
|
|
|
|
|
|
|
|
@item GPGME_Unsupported_Algorithm
|
|
|
|
This value means a verification failed because the cryptographic
|
|
|
|
algorithm is not supported by the crypto backend.
|
|
|
|
|
|
|
|
@item GPGME_Sig_Expired
|
|
|
|
This value means a verification failed because the signature expired.
|
|
|
|
|
|
|
|
@item GPGME_Bad_Signature
|
|
|
|
This value means a verification failed because the signature is bad.
|
|
|
|
|
|
|
|
@item GPGME_No_Public_Key
|
|
|
|
This value means a verification failed because the public key is not
|
|
|
|
available.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Error Strings
|
|
|
|
@section Error Strings
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex error values, printing of
|
|
|
|
@cindex error strings
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_strerror (@w{gpgme_error_t @var{err}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_strerror} returns a pointer to a statically
|
|
|
|
allocated string containing a description of the error with the error
|
|
|
|
value @var{err}. This string can be used to output a diagnostic
|
|
|
|
message to the user.
|
2002-03-06 00:33:50 +00:00
|
|
|
|
|
|
|
The following example illustrates the use of @code{gpgme_strerror}:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_ctx_t ctx;
|
|
|
|
gpgme_error_t err = gpgme_new (&ctx);
|
2002-03-06 00:33:50 +00:00
|
|
|
if (err)
|
|
|
|
@{
|
|
|
|
fprintf (stderr, "%s: creating GpgME context failed: %s\n",
|
|
|
|
argv[0], gpgme_strerror (err));
|
|
|
|
exit (1);
|
|
|
|
@}
|
|
|
|
@end example
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
@node Exchanging Data
|
|
|
|
@chapter Exchanging Data
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex data, exchanging
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
A lot of data has to be exchanged between the user and the crypto
|
|
|
|
engine, like plaintext messages, ciphertext, signatures and
|
|
|
|
information about the keys. The technical details about exchanging
|
|
|
|
the data information are completely abstracted by @acronym{GPGME}.
|
2003-05-18 20:45:24 +00:00
|
|
|
The user provides and receives the data via @code{gpgme_data_t} objects,
|
2002-01-16 00:41:10 +00:00
|
|
|
regardless of the communication protocol between @acronym{GPGME} and
|
|
|
|
the crypto engine in use.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_data_t}
|
|
|
|
The @code{gpgme_data_t} type is a handle for a container for generic
|
2002-01-16 00:41:10 +00:00
|
|
|
data, which is used by @acronym{GPGME} to exchange data with the user.
|
|
|
|
@end deftp
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Creating Data Buffers:: Creating new data buffers.
|
|
|
|
* Destroying Data Buffers:: Releasing data buffers.
|
|
|
|
* Manipulating Data Buffers:: Operations on data buffers.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Creating Data Buffers
|
|
|
|
@section Creating Data Buffers
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex data buffer, creation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
Data objects can be based on memory, files, or callback functions
|
|
|
|
provided by the user. Not all operations are supported by all
|
|
|
|
objects.
|
|
|
|
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* Memory Based Data Buffers:: Creating memory based data buffers.
|
|
|
|
* File Based Data Buffers:: Creating file based data buffers.
|
|
|
|
* Callback Based Data Buffers:: Creating callback based data buffers.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node Memory Based Data Buffers
|
|
|
|
@subsection Memory Based Data Buffers
|
|
|
|
|
|
|
|
Memory based data objects store all data in allocated memory. This is
|
|
|
|
convenient, but only practical for an amount of data that is a
|
|
|
|
fraction of the available physical memory. The data has to be copied
|
|
|
|
from its source and to its destination, which can often be avoided by
|
|
|
|
using one of the other data object
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new (@w{gpgme_data_t *@var{dh}})
|
|
|
|
The function @code{gpgme_data_new} creates a new @code{gpgme_data_t}
|
2002-01-16 00:41:10 +00:00
|
|
|
object and returns a handle for it in @var{dh}. The data object is
|
2002-12-06 22:06:25 +00:00
|
|
|
memory based and initially empty.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, @code{GPGME_Invalid_Value} if @var{dh} is not a
|
|
|
|
valid pointer, and @code{GPGME_Out_Of_Core} if not enough memory is
|
|
|
|
available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_from_mem (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{buffer}}, @w{size_t @var{size}}, @w{int @var{copy}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_new_from_mem} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and fills it with @var{size} bytes starting
|
2002-01-16 00:41:10 +00:00
|
|
|
from @var{buffer}.
|
|
|
|
|
|
|
|
If @var{copy} is not zero, a private copy of the data is made. If
|
|
|
|
@var{copy} is zero, the data is taken from the specified buffer as
|
|
|
|
needed, and the user has to ensure that the buffer remains valid for
|
|
|
|
the whole life span of the data object.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, @code{GPGME_Invalid_Value} if @var{dh} or
|
|
|
|
@var{buffer} is not a valid pointer, and @code{GPGME_Out_Of_Core} if
|
|
|
|
not enough memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_from_file (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{filename}}, @w{int @var{copy}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_new_from_file} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and fills it with the content of the file
|
2002-01-16 00:41:10 +00:00
|
|
|
@var{filename}.
|
|
|
|
|
|
|
|
If @var{copy} is not zero, the whole file is read in at initialization
|
|
|
|
time and the file is not used anymore after that. This is the only
|
|
|
|
mode supported currently. Later, a value of zero for @var{copy} might
|
|
|
|
cause all reads to be delayed until the data is needed, but this is
|
|
|
|
not yet implemented.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, @code{GPGME_Invalid_Value} if @var{dh} or
|
|
|
|
@var{filename} is not a valid pointer, @code{GPGME_File_Error} if an
|
|
|
|
I/O operation fails, @code{GPGME_Not_Implemented} if @var{code} is
|
|
|
|
zero, and @code{GPGME_Out_Of_Core} if not enough memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_from_filepart (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{filename}}, @w{FILE *@var{fp}}, @w{off_t @var{offset}}, @w{size_t @var{length}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_new_from_filepart} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and fills it with a part of the file specified
|
2002-01-16 00:41:10 +00:00
|
|
|
by @var{filename} or @var{fp}.
|
|
|
|
|
|
|
|
Exactly one of @var{filename} and @var{fp} must be non-zero, the other
|
|
|
|
must be zero. The argument that is not zero specifies the file from
|
|
|
|
which @var{length} bytes are read into the data object, starting from
|
|
|
|
@var{offset}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, @code{GPGME_Invalid_Value} if @var{dh} and
|
|
|
|
exactly one of @var{filename} and @var{fp} is not a valid pointer,
|
|
|
|
@code{GPGME_File_Error} if an I/O operation fails, and
|
|
|
|
@code{GPGME_Out_Of_Core} if not enough memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
|
|
|
|
@node File Based Data Buffers
|
|
|
|
@subsection File Based Data Buffers
|
|
|
|
|
|
|
|
File based data objects operate directly on file descriptors or
|
|
|
|
streams. Only a small amount of data is stored in core at any time,
|
|
|
|
so the size of the data objects is not limited by @acronym{GPGME}.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_from_fd (@w{gpgme_data_t *@var{dh}}, @w{int @var{fd}})
|
2002-12-06 22:06:25 +00:00
|
|
|
The function @code{gpgme_data_new_from_fd} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and uses the file descriptor @var{fd} to read
|
2002-12-06 22:06:25 +00:00
|
|
|
from (if used as an input data object) and write to (if used as an
|
|
|
|
output data object).
|
|
|
|
|
|
|
|
When using the data object as an input buffer, the function might read
|
|
|
|
a bit more from the file descriptor than is actually needed by the
|
|
|
|
crypto engine in the desired operation because of internal buffering.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, and @code{GPGME_Out_Of_Core} if not enough
|
|
|
|
memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_from_stream (@w{gpgme_data_t *@var{dh}}, @w{FILE *@var{stream}})
|
2002-12-06 22:06:25 +00:00
|
|
|
The function @code{gpgme_data_new_from_stream} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and uses the I/O stream @var{stream} to read
|
2002-12-06 22:06:25 +00:00
|
|
|
from (if used as an input data object) and write to (if used as an
|
|
|
|
output data object).
|
|
|
|
|
|
|
|
When using the data object as an input buffer, the function might read
|
|
|
|
a bit more from the stream than is actually needed by the crypto
|
|
|
|
engine in the desired operation because of internal buffering.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, and @code{GPGME_Out_Of_Core} if not enough
|
|
|
|
memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
@node Callback Based Data Buffers
|
|
|
|
@subsection Callback Based Data Buffers
|
|
|
|
|
|
|
|
If neither memory nor file based data objects are a good fit for your
|
|
|
|
application, you can implement the functions a data object provides
|
|
|
|
yourself and create a data object from these callback functions.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {ssize_t (*gpgme_data_read_cb_t) (@w{void *@var{handle}}, @w{void @var{*buffer}}, @w{size_t @var{size}})}
|
|
|
|
@tindex gpgme_data_read_cb_t
|
|
|
|
The @code{gpgme_data_read_cb_t} type is the type of functions which
|
2002-12-06 22:06:25 +00:00
|
|
|
@acronym{GPGME} calls if it wants to read data from a user-implemented
|
|
|
|
data object. The function should read up to @var{size} bytes from the
|
|
|
|
current read position into the space starting at @var{buffer}. The
|
|
|
|
@var{handle} is provided by the user at data object creation time.
|
|
|
|
|
|
|
|
The function should return the number of bytes read, 0 on EOF, and -1
|
|
|
|
on error. If an error occurs, @var{errno} should be set to describe
|
|
|
|
the type of the error.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {ssize_t (*gpgme_data_write_cb_t) (@w{void *@var{handle}}, @w{const void @var{*buffer}}, @w{size_t @var{size}})}
|
|
|
|
@tindex gpgme_data_write_cb_t
|
|
|
|
The @code{gpgme_data_write_cb_t} type is the type of functions which
|
2002-12-06 22:06:25 +00:00
|
|
|
@acronym{GPGME} calls if it wants to write data to a user-implemented
|
|
|
|
data object. The function should write up to @var{size} bytes to the
|
|
|
|
current write position from the space starting at @var{buffer}. The
|
|
|
|
@var{handle} is provided by the user at data object creation time.
|
|
|
|
|
|
|
|
The function should return the number of bytes written, and -1 on
|
|
|
|
error. If an error occurs, @var{errno} should be set to describe the
|
|
|
|
type of the error.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {off_t (*gpgme_data_seek_cb_t) (@w{void *@var{handle}}, @w{off_t @var{offset}}, @w{int @var{whence}})}
|
|
|
|
@tindex gpgme_data_seek_cb_t
|
|
|
|
The @code{gpgme_data_seek_cb_t} type is the type of functions which
|
2002-12-06 22:06:25 +00:00
|
|
|
@acronym{GPGME} calls if it wants to change the current read/write
|
|
|
|
position in a user-implemented data object, just like the @code{lseek}
|
|
|
|
function.
|
|
|
|
|
|
|
|
The function should return the new read/write position, and -1 on
|
|
|
|
error. If an error occurs, @var{errno} should be set to describe the
|
|
|
|
type of the error.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {void (*gpgme_data_release_cb_t) (@w{void *@var{handle}})}
|
|
|
|
@tindex gpgme_data_release_cb_t
|
|
|
|
The @code{gpgme_data_release_cb_t} type is the type of functions which
|
2002-12-06 22:06:25 +00:00
|
|
|
@acronym{GPGME} calls if it wants to destroy a user-implemented data
|
|
|
|
object. The @var{handle} is provided by the user at data object
|
|
|
|
creation time.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {struct gpgme_data_cbs}
|
2002-12-06 22:06:25 +00:00
|
|
|
This structure is used to store the data callback interface functions
|
|
|
|
described above. It has the following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_data_read_cb_t read
|
2002-12-06 22:06:25 +00:00
|
|
|
This is the function called by @acronym{GPGME} to read data from the
|
|
|
|
data object. It is only required for input data object.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_data_write_cb_t write
|
2002-12-06 22:06:25 +00:00
|
|
|
This is the function called by @acronym{GPGME} to write data to the
|
|
|
|
data object. It is only required for output data object.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_data_seek_cb_t seek
|
2002-12-06 22:06:25 +00:00
|
|
|
This is the function called by @acronym{GPGME} to change the current
|
|
|
|
read/write pointer in the data object (if available). It is optional.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_data_release_cb_t release
|
2002-12-06 22:06:25 +00:00
|
|
|
This is the function called by @acronym{GPGME} to release a data
|
|
|
|
object. It is optional.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_from_cbs (@w{gpgme_data_t *@var{dh}}, @w{gpgme_data_cbs_t @var{cbs}}, @w{void *@var{handle}})
|
2002-12-06 22:06:25 +00:00
|
|
|
The function @code{gpgme_data_new_from_cbs} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and uses the user-provided callback functions
|
2002-12-06 22:06:25 +00:00
|
|
|
to operate on the data object.
|
|
|
|
|
|
|
|
The handle @var{handle} is passed as first argument to the callback
|
|
|
|
functions. This can be used to identify this data object.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, and @code{GPGME_Out_Of_Core} if not enough
|
|
|
|
memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
The following interface is deprecated and only provided for backward
|
|
|
|
compatibility. Don't use it. It will be removed in a future version
|
|
|
|
of @acronym{GPGME}.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_new_with_read_cb (@w{gpgme_data_t *@var{dh}}, @w{int (*@var{readfunc})} (@w{void *@var{hook}}, @w{char *@var{buffer}}, @w{size_t @var{count}}, @w{size_t *@var{nread}}), @w{void *@var{hook_value}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_new_with_read_cb} creates a new
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_data_t} object and uses the callback function @var{readfunc}
|
2002-01-16 00:41:10 +00:00
|
|
|
to retrieve the data on demand. As the callback function can supply
|
|
|
|
the data in any way it wants, this is the most flexible data type
|
|
|
|
@acronym{GPGME} provides. However, it can not be used to write data.
|
|
|
|
|
|
|
|
The callback function receives @var{hook_value} as its first argument
|
|
|
|
whenever it is invoked. It should return up to @var{count} bytes in
|
|
|
|
@var{buffer}, and return the number of bytes actually read in
|
|
|
|
@var{nread}. It may return @code{0} in @var{nread} if no data is
|
|
|
|
currently available. To indicate @code{EOF} the function should
|
|
|
|
return with an error code of @code{-1} and set @var{nread} to
|
|
|
|
@code{0}. The callback function may support to reset its internal
|
|
|
|
read pointer if it is invoked with @var{buffer} and @var{nread} being
|
|
|
|
@code{NULL} and @var{count} being @code{0}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the data object was
|
|
|
|
successfully created, @code{GPGME_Invalid_Value} if @var{dh} or
|
|
|
|
@var{readfunc} is not a valid pointer, and @code{GPGME_Out_Of_Core} if
|
|
|
|
not enough memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Destroying Data Buffers
|
|
|
|
@section Destroying Data Buffers
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex data buffer, destruction
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_data_release (@w{gpgme_data_t @var{dh}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_release} destroys the data object with
|
|
|
|
the handle @var{dh}. It releases all associated resources that were
|
|
|
|
not provided by the user in the first place.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {char *} gpgme_data_release_and_get_mem (@w{gpgme_data_t @var{dh}}, @w{size_t *@var{length}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_release_and_get_mem} is like
|
|
|
|
@code{gpgme_data_release}, except that it returns the data buffer and
|
|
|
|
its length that was provided by the object.
|
|
|
|
|
|
|
|
The user has to release the buffer with @code{free}. In case the user
|
|
|
|
provided the data buffer in non-copy mode, a copy will be made for
|
|
|
|
this purpose.
|
|
|
|
|
|
|
|
In case an error returns, or there is no suitable data buffer that can
|
|
|
|
be returned to the user, the function will return @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Manipulating Data Buffers
|
|
|
|
@section Manipulating Data Buffers
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex data buffere, manipulation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun ssize_t gpgme_data_read (@w{gpgme_data_t @var{dh}}, @w{void *@var{buffer}}, @w{size_t @var{length}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_data_read} reads up to @var{length} bytes
|
|
|
|
from the data object with the handle @var{dh} into the space starting
|
2002-12-06 22:06:25 +00:00
|
|
|
at @var{buffer}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
If no error occurs, the actual amount read is returned. If the end of
|
|
|
|
the data object is reached, the function returns @code{GPGME_EOF} and
|
|
|
|
sets @var{nread} to zero.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
In all other cases, the function returns -1 and sets @var{errno}.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun ssize_t gpgme_data_write (@w{gpgme_data_t @var{dh}}, @w{const void *@var{buffer}}, @w{size_t @var{size}})
|
2002-12-06 22:06:25 +00:00
|
|
|
The function @code{gpgme_data_write} writes up to @var{size} bytes
|
2002-01-16 00:41:10 +00:00
|
|
|
starting from @var{buffer} into the data object with the handle
|
|
|
|
@var{dh} at the current write position.
|
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
The function returns the number of bytes actually written, or -1 if an
|
|
|
|
error occurs. If an error occurs, @var{errno} is set.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
/* Set the current position from where the next read or write starts
|
|
|
|
in the data object with the handle DH to OFFSET, relativ to
|
|
|
|
WHENCE. */
|
2003-05-18 20:45:24 +00:00
|
|
|
off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence);
|
2002-12-06 22:06:25 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun off_t gpgme_data_seek (@w{gpgme_data_t @var{dh}}, @w{off_t *@var{offset}}, @w{int @var{whence}})
|
2002-12-06 22:06:25 +00:00
|
|
|
The function @code{gpgme_data_seek} changes the current read/write
|
|
|
|
position.
|
|
|
|
|
|
|
|
The @var{whence} argument specifies how the @var{offset} should be
|
|
|
|
interpreted. It must be one of the following symbolic constants:
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@table @code
|
2002-12-06 22:06:25 +00:00
|
|
|
@item SEEK_SET
|
|
|
|
Specifies that @var{whence} is a count of characters from the
|
|
|
|
beginning of the data object.
|
|
|
|
|
|
|
|
@item SEEK_CUR
|
|
|
|
Specifies that @var{whence} is a count of characters from the current
|
|
|
|
file position. This count may be positive or negative.
|
|
|
|
|
|
|
|
@item SEEK_END
|
|
|
|
Specifies that @var{whence} is a count of characters from the end of
|
|
|
|
the data object. A negative count specifies a position within the
|
|
|
|
current extent of the data object; a positive count specifies a
|
|
|
|
position past the current end. If you set the position past the
|
|
|
|
current end, and actually write data, you will extend the data object
|
|
|
|
with zeros up to that position.
|
|
|
|
@end table
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
If successful, the function returns the resulting file position,
|
|
|
|
measured in bytes from the beginning of the data object. You can use
|
|
|
|
this feature together with @code{SEEK_CUR} to read the current
|
|
|
|
read/write position.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
If the function fails, -1 is returned and @var{errno} is set.
|
|
|
|
@end deftypefun
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
The following function is deprecated and should not be used. It will
|
|
|
|
be removed in a future version of @acronym{GPGME}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_rewind (@w{gpgme_data_t @var{dh}})
|
2002-12-06 22:06:25 +00:00
|
|
|
The function @code{gpgme_data_rewind} is equivalent to:
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-12-06 22:06:25 +00:00
|
|
|
@example
|
|
|
|
return (gpgme_data_seek (dh, 0, SEEK_SET) == -1)
|
|
|
|
? mk_error (File_Error) : 0;
|
|
|
|
@end example
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-04-27 12:17:56 +00:00
|
|
|
@c
|
2003-05-18 20:45:24 +00:00
|
|
|
@c gpgme_data_encoding_t
|
2002-04-27 12:17:56 +00:00
|
|
|
@c
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_data_encoding_t}
|
|
|
|
@tindex gpgme_data_encoding_t
|
|
|
|
The @code{gpgme_data_encoding_t} type specifies the encoding of a
|
|
|
|
@code{gpgme_data_t} object. This encoding is useful to give the backend
|
2002-05-26 20:12:51 +00:00
|
|
|
a hint on the type of data. The following data types are available:
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-04-27 12:17:56 +00:00
|
|
|
@table @code
|
|
|
|
@item GPGME_DATA_ENCODING_NONE
|
2002-05-26 20:12:51 +00:00
|
|
|
This specifies that the encoding is not known. This is the default
|
2002-07-25 15:52:23 +00:00
|
|
|
for a new data object. The backend will try its best to detect the
|
|
|
|
encoding automatically.
|
2002-04-27 12:17:56 +00:00
|
|
|
|
|
|
|
@item GPGME_DATA_ENCODING_BINARY
|
|
|
|
This specifies that the data is encoding in binary form; i.e. there is
|
|
|
|
no special encoding.
|
|
|
|
|
|
|
|
@item GPGME_DATA_ENCODING_BASE64
|
|
|
|
This specifies that the data is encoded using the Base-64 encoding
|
|
|
|
scheme as used by @acronym{MIME} and other protocols.
|
|
|
|
|
|
|
|
@item GPGME_DATA_ENCODING_ARMOR
|
|
|
|
This specifies that the data is encoded in an armored form as used by
|
|
|
|
OpenPGP and PEM.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_data_encoding_t gpgme_data_get_encoding (@w{gpgme_data_t @var{dh}})
|
2002-05-26 20:12:51 +00:00
|
|
|
The function @code{gpgme_data_get_encoding} returns the encoding of
|
|
|
|
the data object with the handle @var{dh}. If @var{dh} is not a valid
|
|
|
|
pointer (e.g. @code{NULL}) @code{GPGME_DATA_ENCODING_NONE} is
|
|
|
|
returned.
|
2002-04-27 12:17:56 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_data_set_encoding (@w{gpgme_data_t @var{dh}, gpgme_data_encoding_t @var{enc}})
|
2002-05-26 20:12:51 +00:00
|
|
|
The function @code{gpgme_data_set_encoding} changes the encoding of
|
|
|
|
the data object with the handle @var{dh} to @var{enc}.
|
2002-04-27 12:17:56 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
@c
|
|
|
|
@c Chapter Contexts
|
|
|
|
@c
|
2002-01-16 00:41:10 +00:00
|
|
|
@node Contexts
|
|
|
|
@chapter Contexts
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-30 01:43:05 +00:00
|
|
|
All cryptographic operations in @acronym{GPGME} are performed within a
|
2002-01-16 00:41:10 +00:00
|
|
|
context, which contains the internal state of the operation as well as
|
|
|
|
configuration parameters. By using several contexts you can run
|
|
|
|
several cryptographic operations in parallel, with different
|
|
|
|
configuration.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_ctx_t}
|
|
|
|
The @code{gpgme_ctx_t} type is a handle for a @acronym{GPGME} context,
|
2002-01-16 00:41:10 +00:00
|
|
|
which is used to hold the configuration, status and result of
|
|
|
|
cryptographic operations.
|
|
|
|
@end deftp
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Creating Contexts:: Creating new @acronym{GPGME} contexts.
|
|
|
|
* Destroying Contexts:: Releasing @acronym{GPGME} contexts.
|
|
|
|
* Context Attributes:: Setting properties of a context.
|
2002-01-16 00:41:10 +00:00
|
|
|
* Key Management:: Managing keys with @acronym{GPGME}.
|
|
|
|
* Trust Item Management:: Managing trust items with @acronym{GPGME}.
|
|
|
|
* Crypto Operations:: Using a context for cryptography.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Run Control:: Controlling how operations are run.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Creating Contexts
|
|
|
|
@section Creating Contexts
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context, creation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_new (@w{gpgme_ctx_t *@var{ctx}})
|
|
|
|
The function @code{gpgme_data_new} creates a new @code{gpgme_ctx_t}
|
2002-01-16 00:41:10 +00:00
|
|
|
object and returns a handle for it in @var{ctx}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the context was
|
|
|
|
successfully created, @code{GPGME_Invalid_Value} if @var{ctx} is not a
|
|
|
|
valid pointer, and @code{GPGME_Out_Of_Core} if not enough memory is
|
|
|
|
available.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Destroying Contexts
|
|
|
|
@section Destroying Contexts
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context, destruction
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_release (@w{gpgme_ctx_t @var{ctx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_release} destroys the context with the handle
|
|
|
|
@var{ctx} and releases all associated resources.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Context Attributes
|
|
|
|
@section Context Attributes
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context, attributes
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Protocol Selection:: Selecting the protocol used by a context.
|
|
|
|
* @acronym{ASCII} Armor:: Requesting @acronym{ASCII} armored output.
|
|
|
|
* Text Mode:: Choosing canonical text mode.
|
2002-02-25 18:31:07 +00:00
|
|
|
* Included Certificates:: Including a number of certificates.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Key Listing Mode:: Selecting key listing mode.
|
|
|
|
* Passphrase Callback:: Getting the passphrase from the user.
|
|
|
|
* Progress Meter Callback:: Being informed about the progress.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Protocol Selection
|
|
|
|
@subsection Protocol Selection
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context, selecting protocol
|
|
|
|
@cindex protocol, selecting
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_set_protocol (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_protocol_t @var{proto}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_set_protocol} sets the protocol used within
|
|
|
|
the context @var{ctx} to @var{proto}. All crypto operations will be
|
|
|
|
performed by the crypto engine configured for that protocol.
|
|
|
|
@xref{Protocols and Engines}.
|
|
|
|
|
|
|
|
Setting the protocol with @code{gpgme_set_protocol} does not check if
|
|
|
|
the crypto engine for that protocol is available and installed
|
2002-01-29 22:58:25 +00:00
|
|
|
correctly. @xref{Engine Version Check}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the protocol could be
|
|
|
|
set successfully, and @code{GPGME_Invalid_Value} if @var{protocol} is
|
|
|
|
not a valid protocol.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_protocol_t gpgme_get_protocol (@w{gpgme_ctx_t @var{ctx}})
|
2002-05-03 18:20:24 +00:00
|
|
|
The function @code{gpgme_get_protocol} retrieves the protocol currently
|
|
|
|
use with the context @var{ctx}.
|
|
|
|
@end deftypefun
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node @acronym{ASCII} Armor
|
|
|
|
@subsection @acronym{ASCII} Armor
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context, armor mode
|
|
|
|
@cindex @acronym{ASCII} armor
|
|
|
|
@cindex armor mode
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_armor (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_set_armor} specifies if the output should be
|
2002-01-22 14:23:56 +00:00
|
|
|
@acronym{ASCII} armored. By default, output is not @acronym{ASCII}
|
|
|
|
armored.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-22 14:23:56 +00:00
|
|
|
@acronym{ASCII} armored output is disabled if @var{yes} is zero, and
|
2002-01-16 00:41:10 +00:00
|
|
|
enabled otherwise.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun int gpgme_get_armor (@w{gpgme_ctx_t @var{ctx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_get_armor} returns 1 if the output is
|
|
|
|
@acronym{ASCII} armored, and @code{0} if it is not, or if @var{ctx} is
|
|
|
|
not a valid pointer.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Text Mode
|
|
|
|
@subsection Text Mode
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex context, text mode
|
|
|
|
@cindex text mode
|
|
|
|
@cindex canonical text mode
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_textmode (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_set_textmode} specifies if canonical text mode
|
|
|
|
should be used. By default, text mode is not used.
|
|
|
|
|
|
|
|
Text mode is for example used for the RFC2015 signatures; note that
|
|
|
|
the updated RFC 3156 mandates that the mail user agent does some
|
|
|
|
preparations so that text mode is not needed anymore.
|
|
|
|
|
2002-02-25 18:31:07 +00:00
|
|
|
This option is only relevant to the OpenPGP crypto engine, and ignored
|
|
|
|
by all other engines.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
Canonical text mode is disabled if @var{yes} is zero, and enabled
|
|
|
|
otherwise.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun int gpgme_get_textmode (@w{gpgme_ctx_t @var{ctx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_get_textmode} returns 1 if canonical text
|
|
|
|
mode is enabled, and @code{0} if it is not, or if @var{ctx} is not a
|
|
|
|
valid pointer.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-02-25 18:31:07 +00:00
|
|
|
@node Included Certificates
|
|
|
|
@subsection Included Certificates
|
|
|
|
@cindex certificates, included
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_include_certs (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{nr_of_certs}})
|
2002-02-25 18:31:07 +00:00
|
|
|
The function @code{gpgme_set_include_certs} specifies how many
|
|
|
|
certificates should be included in an S/MIME signed message. By
|
|
|
|
default, only the sender's certificate is included. The possible
|
|
|
|
values of @var{nr_of_certs} are:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item -2
|
|
|
|
Include all certificates except the root certificate.
|
|
|
|
@item -1
|
|
|
|
Include all certificates.
|
|
|
|
@item 0
|
|
|
|
Include no certificates.
|
|
|
|
@item 1
|
|
|
|
Include the sender's certificate only.
|
|
|
|
@item n
|
|
|
|
Include the first n certificates of the certificates path, starting
|
|
|
|
from the sender's certificate. The number @code{n} must be positive.
|
|
|
|
@end table
|
|
|
|
|
|
|
|
Values of @var{nr_of_certs} smaller than -2 are undefined.
|
|
|
|
|
|
|
|
This option is only relevant to the CMS crypto engine, and ignored
|
|
|
|
by all other engines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun int gpgme_get_include_certs (@w{gpgme_ctx_t @var{ctx}})
|
2002-02-25 18:31:07 +00:00
|
|
|
The function @code{gpgme_get_include_certs} returns the number of
|
|
|
|
certificates to include into an S/MIME signed message.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Key Listing Mode
|
|
|
|
@subsection Key Listing Mode
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key listing mode
|
|
|
|
@cindex key listing, mode of
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_keylist_mode (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{mode}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_set_keylist_mode} changes the default
|
2002-02-06 00:08:47 +00:00
|
|
|
behaviour of the key listing functions. The value in @var{mode} is a
|
|
|
|
bitwise-or combination of one or multiple of the following bit values:
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@table @code
|
2002-02-06 00:08:47 +00:00
|
|
|
@item GPGME_KEYLIST_MODE_LOCAL
|
|
|
|
The @code{GPGME_KEYLIST_MODE_LOCAL} symbol specifies that the local
|
|
|
|
keyring should be searched for keys in the keylisting operation. This
|
|
|
|
is the default.
|
|
|
|
|
|
|
|
@item GPGME_KEYLIST_MODE_EXTERN
|
|
|
|
The @code{GPGME_KEYLIST_MODE_EXTERN} symbol specifies that an external
|
|
|
|
source should be should be searched for keys in the keylisting
|
|
|
|
operation. The type of external source is dependant on the crypto
|
|
|
|
engine used. For example, it can be a remote keyserver or LDAP
|
|
|
|
certificate server.
|
2003-04-30 03:02:50 +00:00
|
|
|
|
|
|
|
@item GPGME_KEYLIST_MODE_SIGS
|
|
|
|
The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key
|
|
|
|
signatures should be included in the listed keys.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end table
|
2002-02-06 00:08:47 +00:00
|
|
|
|
|
|
|
At least one of @code{GPGME_KEYLIST_MODE_LOCAL} and
|
|
|
|
@code{GPGME_KEYLIST_MODE_EXTERN} must be specified. For future binary
|
|
|
|
compatibility, you should get the current mode with
|
|
|
|
@code{gpgme_get_keylist_mode} and modify it by setting or clearing the
|
|
|
|
appropriate bits, and then using that calulcated value in the
|
|
|
|
@code{gpgme_set_keylisting_mode} operation. This will leave all other
|
|
|
|
bits in the mode value intact (in particular those that are not used
|
|
|
|
in the current version of the library).
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the mode could be set
|
|
|
|
correctly, and @code{GPGME_Invalid_Value} if @var{ctx} is not a valid
|
|
|
|
pointer or @var{mode} is not a valid mode.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun int gpgme_get_keylist_mode (@w{gpgme_ctx_t @var{ctx}})
|
2002-02-06 00:08:47 +00:00
|
|
|
The function @code{gpgme_get_keylist_mode} returns the current key
|
|
|
|
listing mode of the context @var{ctx}. This value can then be
|
|
|
|
modified and used in a subsequent @code{gpgme_set_keylist_mode}
|
|
|
|
operation to only affect the desired bits (and leave all others
|
|
|
|
intact).
|
|
|
|
|
|
|
|
The function returns 0 if @var{ctx} is not a valid pointer, and the
|
|
|
|
current mode otherwise. Note that 0 is not a valid mode value.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Passphrase Callback
|
|
|
|
@subsection Passphrase Callback
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex callback, passphrase
|
|
|
|
@cindex passphrase callback
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_error_t (*gpgme_passphrase_cb_t)(void *@var{hook}, const char *@var{desc}, void **@var{r_hd}, const char **@var{result})}
|
|
|
|
@tindex gpgme_passphrase_cb_t
|
|
|
|
The @code{gpgme_passphrase_cb_t} type is the type of functions usable as
|
2002-01-16 00:41:10 +00:00
|
|
|
passphrase callback function.
|
|
|
|
|
2002-04-22 21:58:26 +00:00
|
|
|
The string @var{desc} contains a text usable to be displayed to the
|
2002-01-16 00:41:10 +00:00
|
|
|
user of the application. The function should return a passphrase for
|
2003-02-06 20:09:24 +00:00
|
|
|
the context when invoked with @var{desc} not being @code{NULL} in
|
|
|
|
*@var{result}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The user may store information about the resources associated with the
|
|
|
|
returned passphrase in @var{*r_hd}. When the passphrase is no longer
|
|
|
|
needed by @acronym{GPGME}, the passphrase callback function will be
|
|
|
|
called with @var{desc} being @var{NULL}, and @var{r_hd} being the same
|
|
|
|
as at the first invocation.
|
2003-02-06 20:09:24 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
If an error occurs, return the corresponding @code{gpgme_error_t} value.
|
2003-02-06 20:09:24 +00:00
|
|
|
You can use @code{GPGME_Canceled} to abort the operation. Otherwise,
|
|
|
|
return @code{0}.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_passphrase_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_passphrase_cb_t @var{passfunc}}, @w{void *@var{hook_value}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_set_passphrase_cb} sets the function that is
|
|
|
|
used when a passphrase needs to be provided by the user to
|
|
|
|
@var{passfunc}. The function @var{passfunc} needs to implemented by
|
|
|
|
the user, and whenever it is called, it is called with its first
|
|
|
|
argument being @var{hook_value}. By default, no passphrase callback
|
|
|
|
function is set.
|
|
|
|
|
|
|
|
Not all crypto engines require this callback to retrieve the
|
|
|
|
passphrase. It is better if the engine retrieves the passphrase from
|
|
|
|
a trusted agent (a daemon process), rather than having each user to
|
|
|
|
implement their own passphrase query.
|
|
|
|
|
|
|
|
The user can disable the use of a passphrase callback function by
|
|
|
|
calling @code{gpgme_set_passphrase_cb} with @var{passfunc} being
|
|
|
|
@code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_get_passphrase_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_passphrase_cb_t *@var{passfunc}}, @w{void **@var{hook_value}})
|
2002-04-22 21:58:26 +00:00
|
|
|
The function @code{gpgme_get_passphrase_cb} returns the function that
|
|
|
|
is used when a passphrase needs to be provided by the user in
|
|
|
|
@var{*passfunc}, and the first argument for this function in
|
|
|
|
@var{*hook_value}. If no passphrase callback is set, or @var{ctx} is
|
|
|
|
not a valid pointer, @code{NULL} is returned in both variables.
|
2002-04-22 22:06:09 +00:00
|
|
|
|
|
|
|
@var{passfunc} or @var{hook_value} can be @code{NULL}. In this case,
|
|
|
|
the corresponding value will not be returned.
|
2002-04-22 21:58:26 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Progress Meter Callback
|
|
|
|
@subsection Progress Meter Callback
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex callback, progress meter
|
|
|
|
@cindex progress meter callback
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {const char *(*gpgme_progress_cb_t)(void *@var{hook}, const char *@var{what}, int @var{type}, int @var{current}, int @var{total})}
|
|
|
|
@tindex gpgme_progress_cb_t
|
|
|
|
The @code{gpgme_progress_cb_t} type is the type of functions usable as
|
2002-01-16 00:41:10 +00:00
|
|
|
progress callback function.
|
|
|
|
|
|
|
|
The arguments are specific to the crypto engine. More information
|
|
|
|
about the progress information returned from the GnuPG engine can be
|
|
|
|
found in the GnuPG source code in the file @file{doc/DETAILS} in the
|
|
|
|
section PROGRESS.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_progress_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_progress_cb_t @var{progfunc}}, @w{void *@var{hook_value}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_set_progress_cb} sets the function that is
|
|
|
|
used when progress information about a cryptographic operation is
|
|
|
|
available. The function @var{progfunc} needs to implemented by the
|
|
|
|
user, and whenever it is called, it is called with its first argument
|
|
|
|
being @var{hook_value}. By default, no progress callback function
|
|
|
|
is set.
|
|
|
|
|
|
|
|
Setting a callback function allows an interactive program to display
|
|
|
|
progress information about a long operation to the user.
|
|
|
|
|
|
|
|
The user can disable the use of a progress callback function by
|
|
|
|
calling @code{gpgme_set_progress_cb} with @var{progfunc} being
|
|
|
|
@code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_get_progress_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_progress_cb_t *@var{progfunc}}, @w{void **@var{hook_value}})
|
2002-04-22 21:58:26 +00:00
|
|
|
The function @code{gpgme_get_progress_cb} returns the function that is
|
|
|
|
used to inform the user about the progress made in @var{*progfunc},
|
|
|
|
and the first argument for this function in @var{*hook_value}. If no
|
|
|
|
progress callback is set, or @var{ctx} is not a valid pointer,
|
|
|
|
@code{NULL} is returned in both variables.
|
2002-04-22 22:06:09 +00:00
|
|
|
|
|
|
|
@var{progfunc} or @var{hook_value} can be @code{NULL}. In this case,
|
|
|
|
the corresponding value will not be returned.
|
2002-04-22 21:58:26 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@node Key Management
|
|
|
|
@section Key Management
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key management
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
Some of the cryptographic operations require that recipients or
|
|
|
|
signers are specified. This is always done by specifying the
|
|
|
|
respective keys that should be used for the operation. The following
|
|
|
|
section describes how such keys can be selected and manipulated.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_sub_key_t
|
|
|
|
The @code{gpgme_sub_key_t} type is a pointer to a subkey structure. Sub
|
|
|
|
keys are one component of a @code{gpgme_key_t} object. In fact, subkeys
|
2003-04-30 03:02:50 +00:00
|
|
|
are those parts that contains the real information about the
|
|
|
|
individual cryptographic keys that belong to the same key object. One
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_key_t} can contain several subkeys. The first subkey in the
|
2003-04-30 03:02:50 +00:00
|
|
|
linked list is also called the primary key.
|
|
|
|
|
|
|
|
The subkey structure has the following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_sub_key_t next
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a pointer to the next subkey structure in the linked list, or
|
|
|
|
@code{NULL} if this is the last element.
|
|
|
|
|
|
|
|
@item unsigned int revoked : 1
|
|
|
|
This is true if the subkey is revoked.
|
|
|
|
|
|
|
|
@item unsigned int expired : 1
|
|
|
|
This is true if the subkey is expired.
|
|
|
|
|
|
|
|
@item unsigned int disabled : 1
|
|
|
|
This is true if the subkey is disabled.
|
|
|
|
|
|
|
|
@item unsigned int invalid : 1
|
|
|
|
This is true if the subkey is invalid.
|
|
|
|
|
|
|
|
@item unsigned int can_encrypt : 1
|
|
|
|
This is true if the subkey can be used for encryption.
|
|
|
|
|
|
|
|
@item unsigned int can_sign : 1
|
|
|
|
This is true if the subkey can be used for signing.
|
|
|
|
|
|
|
|
@item unsigned int can_certify : 1
|
|
|
|
This is true if the subkey can be used for certification.
|
|
|
|
|
|
|
|
@item unsigned int secret : 1
|
|
|
|
This is true if the subkey is a secret key.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_pubkey_algo_t pubkey_algo
|
2003-04-30 03:02:50 +00:00
|
|
|
This is the public key algorithm supported by this subkey.
|
|
|
|
|
|
|
|
@item unsigned int length
|
|
|
|
This is the length of the subkey (in bits).
|
|
|
|
|
|
|
|
@item char *keyid
|
|
|
|
This is the key ID of the subkey in hexadecimal digits.
|
|
|
|
|
|
|
|
@item char *fpr
|
|
|
|
This is the fingerprint of the subkey in hexadecimal digits, if
|
|
|
|
available. This is usually only available for the primary key.
|
|
|
|
|
|
|
|
@item long int timestamp
|
|
|
|
This is the creation timestamp of the subkey. This is -1 if the
|
|
|
|
timestamp is invalid, and 0 if it is not available.
|
|
|
|
|
|
|
|
@item long int expires
|
|
|
|
This is the expiration timestamp of the subkey, or 0 if the subkey
|
|
|
|
does not expire.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_key_sig_t
|
|
|
|
The @code{gpgme_key_sig_t} type is a pointer to a key signature structure.
|
|
|
|
Key signatures are one component of a @code{gpgme_key_t} object, and
|
2003-04-30 03:02:50 +00:00
|
|
|
validate user IDs on the key.
|
|
|
|
|
|
|
|
The signatures on a key are only available if the key was retrieved
|
|
|
|
via a listing operation with the @code{GPGME_KEYLIST_MODE_SIGS} mode
|
|
|
|
enabled, because it is expensive to retrieve all signatures of a key.
|
|
|
|
|
|
|
|
The key signature structure has the following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_key_sig_t next
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a pointer to the next key signature structure in the linked
|
|
|
|
list, or @code{NULL} if this is the last element.
|
|
|
|
|
|
|
|
@item unsigned int revoked : 1
|
|
|
|
This is true if the key signature is a revocation signature.
|
|
|
|
|
|
|
|
@item unsigned int expired : 1
|
|
|
|
This is true if the key signature is expired.
|
|
|
|
|
|
|
|
@item unsigned int invalid : 1
|
|
|
|
This is true if the key signature is invalid.
|
|
|
|
|
|
|
|
@item unsigned int disabled : 1
|
|
|
|
This is true if the key signature is exportable.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_pubkey_algo_t pubkey_algo
|
2003-04-30 03:02:50 +00:00
|
|
|
This is the public key algorithm used to create the signature.
|
|
|
|
|
|
|
|
@item char *keyid
|
|
|
|
This is the key ID of the key (in hexadecimal digits) used to create
|
|
|
|
the signature.
|
|
|
|
|
|
|
|
@item long int timestamp
|
|
|
|
This is the creation timestamp of the key signature. This is -1 if
|
|
|
|
the timestamp is invalid, and 0 if it is not available.
|
|
|
|
|
|
|
|
@item long int expires
|
|
|
|
This is the expiration timestamp of the key signature, or 0 if the key
|
|
|
|
signature does not expire.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_error_t status
|
2003-04-30 03:02:50 +00:00
|
|
|
This is the status of the signature and has the same meaning as the
|
2003-05-18 20:45:24 +00:00
|
|
|
member of the same name in a @code{gpgme_signature_t} object.
|
2003-04-30 03:02:50 +00:00
|
|
|
|
|
|
|
@item unsigned int class
|
|
|
|
This specifies the signature class of the key signature. The meaning
|
|
|
|
is specific to the crypto engine.
|
|
|
|
|
|
|
|
@item char *uid
|
|
|
|
This is the main user ID of the key used to create the signature.
|
|
|
|
|
|
|
|
@item char *name
|
|
|
|
This is the name component of @code{uid}, if available.
|
|
|
|
|
|
|
|
@item char *comment
|
|
|
|
This is the comment component of @code{uid}, if available.
|
|
|
|
|
|
|
|
@item char *email
|
|
|
|
This is the email component of @code{uid}, if available.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_user_id_t
|
|
|
|
A user ID is a component of a @code{gpgme_key_t} object. One key can
|
2003-04-30 03:02:50 +00:00
|
|
|
have many user IDs. The first one in the list is the main (or
|
|
|
|
primary) user ID.
|
|
|
|
|
|
|
|
The user ID structure has the following members.
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_user_id_t next
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a pointer to the next user ID structure in the linked list, or
|
|
|
|
@code{NULL} if this is the last element.
|
|
|
|
|
|
|
|
@item unsigned int revoked : 1
|
|
|
|
This is true if the user ID is revoked.
|
|
|
|
|
|
|
|
@item unsigned int invalid : 1
|
|
|
|
This is true if the user ID is invalid.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_validity_t validity
|
2003-04-30 03:02:50 +00:00
|
|
|
This specifies the validity of the user ID.
|
|
|
|
|
|
|
|
@item char *uid
|
|
|
|
This is the user ID string.
|
|
|
|
|
|
|
|
@item char *name
|
|
|
|
This is the name component of @code{uid}, if available.
|
|
|
|
|
|
|
|
@item char *comment
|
|
|
|
This is the comment component of @code{uid}, if available.
|
|
|
|
|
|
|
|
@item char *email
|
|
|
|
This is the email component of @code{uid}, if available.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_key_sig_t signatures
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a linked list with the signatures on this user ID.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_key_t
|
|
|
|
The @code{gpgme_key_t} type is a pointer to a key object. It has the
|
2003-04-30 03:02:50 +00:00
|
|
|
following members:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item unsigned int revoked : 1
|
|
|
|
This is true if the key is revoked.
|
|
|
|
|
|
|
|
@item unsigned int expired : 1
|
|
|
|
This is true if the key is expired.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
@item unsigned int disabled : 1
|
|
|
|
This is true if the key is disabled.
|
|
|
|
|
|
|
|
@item unsigned int invalid : 1
|
|
|
|
This is true if the key is invalid.
|
|
|
|
|
|
|
|
@item unsigned int can_encrypt : 1
|
|
|
|
This is true if the key (ie one of its subkeys) can be used for
|
|
|
|
encryption.
|
|
|
|
|
|
|
|
@item unsigned int can_sign : 1
|
|
|
|
This is true if the key (ie one of its subkeys) can be used for
|
|
|
|
signing.
|
|
|
|
|
|
|
|
@item unsigned int can_certify : 1
|
|
|
|
This is true if the key (ie one of its subkeys) can be used for
|
|
|
|
certification.
|
|
|
|
|
|
|
|
@item unsigned int secret : 1
|
|
|
|
This is true if the key is a secret key.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_protocol_t protocol
|
2003-04-30 03:02:50 +00:00
|
|
|
This is the protocol supported by this key.
|
|
|
|
|
|
|
|
@item char *issuer_serial
|
|
|
|
If @code{protocol} is @code{GPGME_PROTOCOL_CMS}, then this is the
|
|
|
|
issuer serial.
|
|
|
|
|
|
|
|
@item char *issuer_name
|
|
|
|
If @code{protocol} is @code{GPGME_PROTOCOL_CMS}, then this is the
|
|
|
|
issuer name.
|
|
|
|
|
|
|
|
@item char *chain_id
|
|
|
|
If @code{protocol} is @code{GPGME_PROTOCOL_CMS}, then this is the
|
|
|
|
chain ID, which can be used to built the certificate chain.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_validity_t owner_trust
|
2003-04-30 03:02:50 +00:00
|
|
|
If @code{protocol} is @code{GPGME_PROTOCOL_OpenPGP}, then this is the
|
|
|
|
owner trust.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_sub_key_t subkeys
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a linked list with the subkeys of the key. The first subkey
|
|
|
|
in the list is the primary key and usually available.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_user_id_t uids
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a linked list with the user IDs of the key. The first user ID
|
|
|
|
in the list is the main (or primary) user ID.
|
|
|
|
@end table
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftp
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Listing Keys:: Browsing the list of available keys.
|
|
|
|
* Information About Keys:: Requesting detailed information about keys.
|
2002-12-23 17:12:48 +00:00
|
|
|
* Key Signatures:: Listing the signatures on a key.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Manipulating Keys:: Operations on keys.
|
|
|
|
* Generating Keys:: Creating new key pairs.
|
|
|
|
* Exporting Keys:: Retrieving key data from the key ring.
|
2002-01-30 01:17:30 +00:00
|
|
|
* Importing Keys:: Adding keys to the key ring.
|
|
|
|
* Deleting Keys:: Removing keys from the key ring.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Listing Keys
|
|
|
|
@subsection Listing Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex listing keys
|
|
|
|
@cindex key listing
|
|
|
|
@cindex key listing, start
|
|
|
|
@cindex key ring, list
|
|
|
|
@cindex key ring, search
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_keylist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{secret_only}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_keylist_start} initiates a key listing
|
|
|
|
operation inside the context @var{ctx}. It sets everything up so that
|
|
|
|
subsequent invocations of @code{gpgme_op_keylist_next} return the keys
|
|
|
|
in the list.
|
|
|
|
|
|
|
|
If @var{pattern} is @code{NULL}, all available keys are returned.
|
|
|
|
Otherwise, @var{pattern} contains an engine specific expression that
|
|
|
|
is used to limit the list to all keys matching the pattern.
|
|
|
|
|
|
|
|
If @var{secret_only} is not @code{0}, the list is restricted to secret
|
|
|
|
keys only.
|
|
|
|
|
|
|
|
The context will be busy until either all keys are received (and
|
|
|
|
@code{gpgme_op_keylist_next} returns @code{GPGME_EOF}), or
|
|
|
|
@code{gpgme_op_keylist_end} is called to finish the operation.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} is not a
|
|
|
|
valid pointer, and passes through any errors that are reported by the
|
|
|
|
crypto engine support routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_keylist_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{int @var{secret_only}}, @w{int @var{reserved}})
|
2002-02-27 00:59:31 +00:00
|
|
|
The function @code{gpgme_op_keylist_ext_start} initiates an extended
|
|
|
|
key listing operation inside the context @var{ctx}. It sets
|
|
|
|
everything up so that subsequent invocations of
|
|
|
|
@code{gpgme_op_keylist_next} return the keys in the list.
|
|
|
|
|
|
|
|
If @var{pattern} or @var{*pattern} is @code{NULL}, all available keys
|
|
|
|
are returned. Otherwise, @var{pattern} is a @code{NULL} terminated
|
|
|
|
array of strings that are used to limit the list to all keys matching
|
|
|
|
at least one of the patterns verbatim.
|
|
|
|
|
|
|
|
If @var{secret_only} is not @code{0}, the list is restricted to secret
|
|
|
|
keys only.
|
|
|
|
|
|
|
|
The value of @var{reserved} must be @code{0}.
|
|
|
|
|
|
|
|
The context will be busy until either all keys are received (and
|
|
|
|
@code{gpgme_op_keylist_next} returns @code{GPGME_EOF}), or
|
|
|
|
@code{gpgme_op_keylist_end} is called to finish the operation.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} is not a
|
|
|
|
valid pointer, and passes through any errors that are reported by the
|
|
|
|
crypto engine support routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_keylist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t *@var{r_key}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_keylist_next} returns the next key in the
|
|
|
|
list created by a previous @code{gpgme_op_keylist_start} operation in
|
|
|
|
the context @var{ctx}. The key will have one reference for the user.
|
2002-01-29 22:58:25 +00:00
|
|
|
@xref{Manipulating Keys}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
This is the only way to get at @code{gpgme_key_t} objects in
|
2002-01-16 00:41:10 +00:00
|
|
|
@acronym{GPGME}.
|
|
|
|
|
|
|
|
If the last key in the list has already been returned,
|
|
|
|
@code{gpgme_op_keylist_next} returns @code{GPGME_EOF}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} or
|
2003-04-24 14:33:13 +00:00
|
|
|
@var{r_key} is not a valid pointer, and @code{GPGME_Out_Of_Core} if
|
|
|
|
there is not enough memory for the operation.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_keylist_end (@w{gpgme_ctx_t @var{ctx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_keylist_next} ends a pending key list
|
|
|
|
operation in the context @var{ctx}.
|
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
After the operation completed successfully, the result of the key
|
|
|
|
listing operation can be retrieved with
|
|
|
|
@code{gpgme_op_keylist_result}.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} is not a
|
2003-04-24 14:33:13 +00:00
|
|
|
valid pointer, and @code{GPGME_Out_Of_Core} if at some time during the
|
2002-01-16 00:41:10 +00:00
|
|
|
operation there was not enough memory available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-03-06 00:33:50 +00:00
|
|
|
The following example illustrates how all keys containing a certain
|
|
|
|
string (@code{g10code}) can be listed with their key ID and the name
|
|
|
|
and e-mail address of the main user ID:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_ctx_t ctx;
|
|
|
|
gpgme_error_t err = gpgme_new (&ctx);
|
2002-03-06 00:33:50 +00:00
|
|
|
|
|
|
|
if (!err)
|
|
|
|
@{
|
|
|
|
err = gpgme_op_keylist_start (ctx, "g10code", 0);
|
|
|
|
while (!err && (err = gpgme_op_keylist_next (ctx, &key)) != GPGME_EOF)
|
|
|
|
@{
|
|
|
|
printf ("%s: %s <%s>\n",
|
|
|
|
gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, 0, 0),
|
|
|
|
gpgme_key_get_string_attr (key, GPGME_ATTR_NAME, 0, 0),
|
|
|
|
gpgme_key_get_string_attr (key, GPGME_ATTR_EMAIL, 0, 0));
|
|
|
|
gpgme_key_release (key);
|
|
|
|
@}
|
|
|
|
gpgme_release (ctx);
|
|
|
|
@}
|
|
|
|
if (err)
|
|
|
|
@{
|
|
|
|
fprintf (stderr, "%s: can not list keys: %s\n",
|
|
|
|
argv[0], gpgme_strerror (err));
|
|
|
|
exit (1);
|
|
|
|
@}
|
|
|
|
@end example
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_keylist_result_t}
|
2003-04-30 03:02:50 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
|
|
|
@code{gpgme_op_keylist_*} operation. After successfully ending a key
|
|
|
|
listing operation, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_keylist_result}. The structure contains the following
|
|
|
|
member:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item unsigned int truncated : 1
|
|
|
|
This is true if the crypto backend had to truncate the result, and
|
|
|
|
less than the desired keys could be listed.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_keylist_result_t gpgme_op_keylist_result (@w{gpgme_ctx_t @var{ctx}})
|
2003-04-30 03:02:50 +00:00
|
|
|
The function @code{gpgme_op_keylist_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_keylist_result_t} pointer to a structure holding the result of
|
2003-04-30 03:02:50 +00:00
|
|
|
a @code{gpgme_op_keylist_*} operation. The pointer is only valid if
|
|
|
|
the last operation on the context was a key listing operation, and if
|
|
|
|
this operation finished successfully. The returned pointer is only
|
|
|
|
valid until the next operation is started on the context.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-12-23 17:12:48 +00:00
|
|
|
In a simple program, for which a blocking operation is acceptable, the
|
|
|
|
following function can be used to retrieve a single key.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_get_key (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{fpr}}, @w{gpgme_key_t *@var{r_key}}, @w{int @var{secret}})
|
2002-12-23 17:12:48 +00:00
|
|
|
The function @code{gpgme_get_key} gets the key with the fingerprint
|
2003-04-29 22:24:37 +00:00
|
|
|
(or key ID) @var{fpr} from the crypto backend and return it in
|
|
|
|
@var{r_key}. If @var{force_update} is true, force a refresh of the
|
|
|
|
key from the crypto backend and replace the key in the cache, if any.
|
|
|
|
If @var{secret} is true, get the secret key. The currently active
|
|
|
|
keylist mode is used to retrieve the key.
|
2002-12-23 17:12:48 +00:00
|
|
|
|
2003-05-04 20:49:44 +00:00
|
|
|
If the key is not found in the keyring, @code{gpgme_get_key} returns
|
|
|
|
@code{GPGME_No_Error} and *@var{r_key} will be set to @code{NULL}.
|
|
|
|
|
2002-12-23 17:12:48 +00:00
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} or
|
2003-04-24 14:33:13 +00:00
|
|
|
@var{r_key} is not a valid pointer, @code{GPGME_Invalid_Key} if
|
|
|
|
@var{fpr} is not a fingerprint or key ID, @code{GPGME_Out_Of_Core} if
|
|
|
|
at some time during the operation there was not enough memory
|
|
|
|
available.
|
2002-12-23 17:12:48 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Information About Keys
|
|
|
|
@subsection Information About Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key, information about
|
|
|
|
@cindex key, attributes
|
|
|
|
@cindex attributes, of a key
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
Please see the beginning of this section for more information about
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_key_t} objects.
|
2003-04-30 03:02:50 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_validity_t
|
|
|
|
The @code{gpgme_validity_t} type is used to specify the validity of a user ID
|
2003-04-30 03:02:50 +00:00
|
|
|
in a key. The following validities are defined:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_VALIDITY_UNKNOWN
|
|
|
|
The user ID is of unknown validity. The string representation of this
|
|
|
|
validity is ``?''.
|
|
|
|
|
|
|
|
@item GPGME_VALIDITY_UNDEFINED
|
|
|
|
The validity of the user ID is undefined. The string representation of this
|
|
|
|
validity is ``q''.
|
|
|
|
|
|
|
|
@item GPGME_VALIDITY_NEVER
|
|
|
|
The user ID is never valid. The string representation of this
|
|
|
|
validity is ``n''.
|
|
|
|
|
|
|
|
@item GPGME_VALIDITY_MARGINAL
|
|
|
|
The user ID is marginally valid. The string representation of this
|
|
|
|
validity is ``m''.
|
|
|
|
|
|
|
|
@item GPGME_VALIDITY_FULL
|
|
|
|
The user ID is fully valid. The string representation of this
|
|
|
|
validity is ``f''.
|
|
|
|
|
|
|
|
@item GPGME_VALIDITY_ULTIMATE
|
|
|
|
The user ID is ultimately valid. The string representation of this
|
|
|
|
validity is ``u''.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
|
|
|
|
The following interfaces are deprecated and only provided for backward
|
|
|
|
compatibility. Don't use them. They will be removed in a future
|
|
|
|
version of @acronym{GPGME}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_attr_t
|
|
|
|
The @code{gpgme_attr_t} type is used to specify a key or trust item
|
2002-01-16 00:41:10 +00:00
|
|
|
attribute. The following attributes are defined:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_ATTR_KEYID
|
|
|
|
This is the key ID of a sub key. It is representable as a string.
|
|
|
|
|
|
|
|
For trust items, the trust item refers to the key with this ID.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_FPR
|
|
|
|
This is the fingerprint of a sub key. It is representable as a
|
|
|
|
string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_ALGO
|
|
|
|
This is the crypto algorithm for which the sub key can be used. It
|
|
|
|
is representable as a string and as a number. The numbers correspond
|
|
|
|
to the @code{enum gcry_pk_algos} values in the gcrypt library.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_LEN
|
|
|
|
This is the key length of a sub key. It is representable as a
|
|
|
|
number.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_CREATED
|
|
|
|
This is the timestamp at creation time of a sub key. It is
|
|
|
|
representable as a number.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_EXPIRE
|
2002-03-03 17:37:34 +00:00
|
|
|
This is the expiration time of a sub key. It is representable as a
|
|
|
|
number.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_ATTR_OTRUST
|
|
|
|
XXX FIXME (also for trust items)
|
|
|
|
|
|
|
|
@item GPGME_ATTR_USERID
|
|
|
|
This is a user ID. There can be more than one user IDs in a
|
2003-05-18 20:45:24 +00:00
|
|
|
@var{gpgme_key_t} object. The first one (with index 0) is the primary
|
2002-01-16 00:41:10 +00:00
|
|
|
user ID. The user ID is representable as a number.
|
|
|
|
|
|
|
|
For trust items, this is the user ID associated with this trust item.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_NAME
|
|
|
|
This is the name belonging to a user ID. It is representable as a string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_EMAIL
|
|
|
|
This is the email address belonging to a user ID. It is representable
|
|
|
|
as a string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_COMMENT
|
|
|
|
This is the comment belonging to a user ID. It is representable as a
|
|
|
|
string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_VALIDITY
|
|
|
|
This is the validity belonging to a user ID. It is representable as a
|
|
|
|
string and as a number. See below for a list of available validities.
|
|
|
|
|
|
|
|
For trust items, this is the validity that is associated with this
|
|
|
|
trust item.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_UID_REVOKED
|
|
|
|
This specifies if a user ID is revoked. It is representable as a
|
|
|
|
number, and is @code{1} if the user ID is revoked, and @code{0}
|
|
|
|
otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_UID_INVALID
|
|
|
|
This specifies if a user ID is invalid. It is representable as a
|
|
|
|
number, and is @code{1} if the user ID is invalid, and @code{0}
|
|
|
|
otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_LEVEL
|
|
|
|
This is the trust level of a trust item.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_TYPE
|
2002-08-14 13:57:59 +00:00
|
|
|
This returns information about the type of key. For the string function
|
|
|
|
this will eother be "PGP" or "X.509". The integer function returns 0
|
|
|
|
for PGP and 1 for X.509. It is also used for the type of a trust item.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_ATTR_IS_SECRET
|
|
|
|
This specifies if the key is a secret key. It is representable as a
|
2002-12-23 22:34:25 +00:00
|
|
|
number, and is @code{1} if the key is revoked, and @code{0} otherwise.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@item GPGME_ATTR_KEY_REVOKED
|
|
|
|
This specifies if a sub key is revoked. It is representable as a
|
|
|
|
number, and is @code{1} if the key is revoked, and @code{0} otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_KEY_INVALID
|
|
|
|
This specifies if a sub key is invalid. It is representable as a
|
|
|
|
number, and is @code{1} if the key is invalid, and @code{0} otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_KEY_EXPIRED
|
|
|
|
This specifies if a sub key is expired. It is representable as a
|
|
|
|
number, and is @code{1} if the key is expired, and @code{0} otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_KEY_DISABLED
|
|
|
|
This specifies if a sub key is disabled. It is representable as a
|
|
|
|
number, and is @code{1} if the key is disabled, and @code{0} otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_KEY_CAPS
|
|
|
|
This is a description of the capabilities of a sub key. It is
|
|
|
|
representable as a string. The string contains the letter ``e'' if
|
|
|
|
the key can be used for encryption, ``s'' if the key can be used for
|
|
|
|
signatures, and ``c'' if the key can be used for certifications.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_CAN_ENCRYPT
|
|
|
|
This specifies if a sub key can be used for encryption. It is
|
|
|
|
representable as a number, and is @code{1} if the sub key can be used
|
|
|
|
for encryption, and @code{0} otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_CAN_SIGN
|
|
|
|
This specifies if a sub key can be used for signatures. It is
|
|
|
|
representable as a number, and is @code{1} if the sub key can be used
|
|
|
|
for signatures, and @code{0} otherwise.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_CAN_CERTIFY
|
|
|
|
This specifies if a sub key can be used for certifications. It is
|
|
|
|
representable as a number, and is @code{1} if the sub key can be used
|
|
|
|
for certifications, and @code{0} otherwise.
|
2002-07-25 15:50:46 +00:00
|
|
|
|
|
|
|
@item GPGME_ATTR_SERIAL
|
|
|
|
The X.509 issuer serial attribute of the key. It is representable as
|
|
|
|
a string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_ISSUE
|
|
|
|
The X.509 issuer name attribute of the key. It is representable as a
|
|
|
|
string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_CHAINID
|
|
|
|
The X.509 chain ID can be used to build the certification chain. It
|
|
|
|
is representable as a string.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_key_get_string_attr (@w{gpgme_key_t @var{key}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_key_get_string_attr} returns the value of the
|
|
|
|
string-representable attribute @var{what} of key @var{key}. If the
|
2002-06-27 16:34:10 +00:00
|
|
|
attribute is an attribute of a sub key or an user ID, @var{idx}
|
|
|
|
specifies the sub key or user ID of which the attribute value is
|
|
|
|
returned. The argument @var{reserved} is reserved for later use and
|
|
|
|
should be @code{NULL}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The string returned is only valid as long as the key is valid.
|
|
|
|
|
|
|
|
The function returns @code{0} if an attribute can't be returned as a
|
|
|
|
string, @var{key} is not a valid pointer, @var{idx} out of range,
|
|
|
|
or @var{reserved} not @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {unsigned long} gpgme_key_get_ulong_attr (@w{gpgme_key_t @var{key}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_key_get_ulong_attr} returns the value of the
|
|
|
|
number-representable attribute @var{what} of key @var{key}. If the
|
2002-06-27 16:34:10 +00:00
|
|
|
attribute is an attribute of a sub key or an user ID, @var{idx}
|
|
|
|
specifies the sub key or user ID of which the attribute value is
|
|
|
|
returned. The argument @var{reserved} is reserved for later use and
|
|
|
|
should be @code{NULL}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The function returns @code{0} if the attribute can't be returned as a
|
|
|
|
number, @var{key} is not a valid pointer, @var{idx} out of range,
|
|
|
|
or @var{reserved} not @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-12-23 17:12:48 +00:00
|
|
|
@node Key Signatures
|
|
|
|
@subsection Key Signatures
|
|
|
|
@cindex key, signatures
|
|
|
|
@cindex signatures, on a key
|
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
The following interfaces are deprecated and only provided for backward
|
|
|
|
compatibility. Don't use them. They will be removed in a future
|
|
|
|
version of @acronym{GPGME}.
|
|
|
|
|
2002-12-23 17:12:48 +00:00
|
|
|
The signatures on a key are only available if the key was retrieved
|
|
|
|
via a listing operation with the @code{GPGME_KEYLIST_MODE_SIGS} mode
|
|
|
|
enabled, because it is expensive to retrieve all signatures of a key.
|
|
|
|
|
|
|
|
So, before using the below interfaces to retrieve the signatures on a
|
|
|
|
key, you have to make sure that the key was listed with signatures
|
|
|
|
enabled. One convenient, but blocking, way to do this is to use the
|
|
|
|
function @code{gpgme_get_key}.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_attr_t
|
|
|
|
The @code{gpgme_attr_t} type is used to specify a key signature
|
2002-12-23 17:12:48 +00:00
|
|
|
attribute. The following attributes are defined:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_ATTR_KEYID
|
|
|
|
This is the key ID of the key which was used for the signature. It is
|
|
|
|
representable as a string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_ALGO
|
|
|
|
This is the crypto algorithm used to create the signature. It is
|
|
|
|
representable as a string and as a number. The numbers correspond to
|
|
|
|
the @code{enum gcry_pk_algos} values in the gcrypt library.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_CREATED
|
|
|
|
This is the timestamp at creation time of the signature. It is
|
|
|
|
representable as a number.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_EXPIRE
|
|
|
|
This is the expiration time of the signature. It is representable as
|
|
|
|
a number.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_USERID
|
|
|
|
This is the user ID associated with the signing key. The user ID is
|
|
|
|
representable as a number.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_NAME
|
|
|
|
This is the name belonging to a user ID. It is representable as a string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_EMAIL
|
|
|
|
This is the email address belonging to a user ID. It is representable
|
|
|
|
as a string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_COMMENT
|
|
|
|
This is the comment belonging to a user ID. It is representable as a
|
|
|
|
string.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_KEY_REVOKED
|
|
|
|
This specifies if a key signature is a revocation signature. It is
|
|
|
|
representable as a number, and is @code{1} if the key is revoked, and
|
|
|
|
@code{0} otherwise.
|
|
|
|
|
|
|
|
@c @item GPGME_ATTR_KEY_EXPIRED
|
|
|
|
@c This specifies if a key signature is expired. It is representable as
|
|
|
|
@c a number, and is @code{1} if the key is revoked, and @code{0}
|
|
|
|
@c otherwise.
|
|
|
|
@c
|
|
|
|
@item GPGME_ATTR_SIG_CLASS
|
|
|
|
This specifies the signature class of a key signature. It is
|
|
|
|
representable as a number. The meaning is specific to the crypto
|
|
|
|
engine.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_SIG_CLASS
|
|
|
|
This specifies the signature class of a key signature. It is
|
|
|
|
representable as a number. The meaning is specific to the crypto
|
|
|
|
engine.
|
|
|
|
|
|
|
|
@item GPGME_ATTR_SIG_STATUS
|
|
|
|
This is the same value as returned by @code{gpgme_get_sig_status}.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_key_sig_get_string_attr (@w{gpgme_key_t @var{key}}, @w{int @var{uid_idx}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}})
|
2002-12-23 17:12:48 +00:00
|
|
|
The function @code{gpgme_key_sig_get_string_attr} returns the value of
|
|
|
|
the string-representable attribute @var{what} of the signature
|
|
|
|
@var{idx} on the user ID @var{uid_idx} in the key @var{key}. The
|
|
|
|
argument @var{reserved} is reserved for later use and should be
|
|
|
|
@code{NULL}.
|
|
|
|
|
|
|
|
The string returned is only valid as long as the key is valid.
|
|
|
|
|
|
|
|
The function returns @code{0} if an attribute can't be returned as a
|
|
|
|
string, @var{key} is not a valid pointer, @var{uid_idx} or @var{idx}
|
|
|
|
out of range, or @var{reserved} not @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {unsigned long} gpgme_key_sig_get_ulong_attr (@w{gpgme_key_t @var{key}}, @w{int @var{uid_idx}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}})
|
2002-12-23 17:12:48 +00:00
|
|
|
The function @code{gpgme_key_sig_get_ulong_attr} returns the value of
|
|
|
|
the number-representable attribute @var{what} of the signature
|
|
|
|
@var{idx} on the user ID @var{uid_idx} in the key @var{key}. The
|
|
|
|
argument @var{reserved} is reserved for later use and should be
|
|
|
|
@code{NULL}.
|
|
|
|
|
|
|
|
The function returns @code{0} if an attribute can't be returned as a
|
|
|
|
string, @var{key} is not a valid pointer, @var{uid_idx} or @var{idx}
|
|
|
|
out of range, or @var{reserved} not @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Manipulating Keys
|
|
|
|
@subsection Manipulating Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key, manipulation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_key_ref (@w{gpgme_key_t @var{key}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_key_ref} acquires an additional reference for
|
|
|
|
the key @var{key}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_key_unref (@w{gpgme_key_t @var{key}})
|
2003-04-29 21:53:58 +00:00
|
|
|
The function @code{gpgme_key_unref} releases a reference for the key
|
2002-01-16 00:41:10 +00:00
|
|
|
@var{key}. If this was the last reference, the key will be destroyed
|
|
|
|
and all resources associated to it will be released.
|
2003-04-30 03:02:50 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
The following interface is deprecated and only provided for backward
|
|
|
|
compatibility. Don't use it. It will be removed in a future version
|
|
|
|
of @acronym{GPGME}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_key_release (@w{gpgme_key_t @var{key}})
|
2003-04-30 03:02:50 +00:00
|
|
|
The function @code{gpgme_key_release} is equivalent to
|
2002-01-16 00:41:10 +00:00
|
|
|
@code{gpgme_key_unref}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Generating Keys
|
|
|
|
@subsection Generating Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key, creation
|
|
|
|
@cindex key ring, add
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_genkey (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{parms}}, @w{gpgme_data_t @var{public}}, @w{gpgme_data_t @var{secret}})
|
2002-01-22 14:23:56 +00:00
|
|
|
The function @code{gpgme_op_genkey} generates a new key pair in the
|
2003-04-25 12:48:48 +00:00
|
|
|
context @var{ctx}. The meaning of @var{public} and @var{secret}
|
|
|
|
depends on the crypto backend.
|
|
|
|
|
|
|
|
GnuPG does not support @var{public} and @var{secret}, they should be
|
|
|
|
@code{NULL}. GnuPG will generate a key pair and add it to the
|
|
|
|
standard key ring. The fingerprint of the generated key is available
|
|
|
|
with @code{gpgme_op_genkey_result}.
|
|
|
|
|
|
|
|
GpgSM requires @var{public} to be a writable data object. GpgSM will
|
|
|
|
generate a secret key (which will be stored by @command{gpg-agent},
|
|
|
|
and return a certificate request in @var{public}, which then needs to
|
|
|
|
be signed by the certification authority and imported before it can be
|
|
|
|
used. GpgSM does not make the fingerprint available.
|
2002-01-22 14:23:56 +00:00
|
|
|
|
|
|
|
The argument @var{parms} specifies parameters for the key in an XML
|
|
|
|
string. The details about the format of @var{parms} are specific to
|
2002-01-30 01:17:30 +00:00
|
|
|
the crypto engine used by @var{ctx}. Here is an example for GnuPG as
|
2002-01-22 14:23:56 +00:00
|
|
|
the crypto engine:
|
|
|
|
|
|
|
|
@example
|
|
|
|
<GnupgKeyParms format="internal">
|
|
|
|
Key-Type: DSA
|
|
|
|
Key-Length: 1024
|
|
|
|
Subkey-Type: ELG-E
|
|
|
|
Subkey-Length: 1024
|
|
|
|
Name-Real: Joe Tester
|
|
|
|
Name-Comment: with stupid passphrase
|
|
|
|
Name-Email: joe@@foo.bar
|
|
|
|
Expire-Date: 0
|
|
|
|
Passphrase: abc
|
|
|
|
</GnupgKeyParms>
|
2002-02-09 00:20:48 +00:00
|
|
|
@end example
|
|
|
|
|
|
|
|
Here is an example for GpgSM as the crypto engine:
|
2003-04-25 12:48:48 +00:00
|
|
|
|
2002-02-09 00:20:48 +00:00
|
|
|
@example
|
|
|
|
<GnupgKeyParms format="internal">
|
|
|
|
Key-Type: RSA
|
|
|
|
Key-Length: 1024
|
|
|
|
Name-DN: C=de,O=g10 code,OU=Testlab,CN=Joe 2 Tester
|
2002-02-09 00:35:04 +00:00
|
|
|
Name-Email: joe@@foo.bar
|
2002-02-09 00:20:48 +00:00
|
|
|
</GnupgKeyParms>
|
2002-01-22 14:23:56 +00:00
|
|
|
@end example
|
|
|
|
|
|
|
|
Strings should be given in UTF-8 encoding. The only format supported
|
|
|
|
for now is ``internal''. The content of the @code{GnupgKeyParms}
|
2003-04-25 12:48:48 +00:00
|
|
|
container is passed verbatim to the crypto backend. Control
|
|
|
|
statements are not allowed.
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2003-04-24 17:16:28 +00:00
|
|
|
After the operation completed successfully, the result can be
|
|
|
|
retrieved with @code{gpgme_op_genkey_result}.
|
2002-11-19 16:41:17 +00:00
|
|
|
|
2002-01-22 14:23:56 +00:00
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
2002-01-30 01:17:30 +00:00
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{parms} is not
|
2003-04-25 12:48:48 +00:00
|
|
|
a valid XML string, @code{GPGME_Not_Supported} if @var{public} or
|
|
|
|
@var{secret} is not valid, and @code{GPGME_General_Error} if no key
|
2002-02-09 00:20:48 +00:00
|
|
|
was created by the backend.
|
2002-01-30 01:17:30 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_genkey_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{parms}}, @w{gpgme_data_t @var{public}}, @w{gpgme_data_t @var{secret}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_genkey_start} initiates a
|
|
|
|
@code{gpgme_op_genkey} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{parms} is not
|
2003-04-25 12:48:48 +00:00
|
|
|
a valid XML string, and @code{GPGME_Not_Supported} if @var{public} or
|
|
|
|
@var{secret} is not @code{NULL}.
|
2002-01-22 14:23:56 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_genkey_result_t}
|
2003-04-24 17:16:28 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
|
|
|
@code{gpgme_op_genkey} operation. After successfully generating a
|
|
|
|
key, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_genkey_result}. The structure contains the following
|
|
|
|
members:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item unsigned int primary : 1
|
|
|
|
This is a flag that is set to 1 if a primary key was created and to 0
|
|
|
|
if not.
|
|
|
|
|
|
|
|
@item unsigned int sub : 1
|
|
|
|
This is a flag that is set to 1 if a subkey was created and to 0
|
|
|
|
if not.
|
|
|
|
|
|
|
|
@item char *fpr
|
|
|
|
This is the fingerprint of the key that was created. If both a
|
|
|
|
primary and a sub key were generated, the fingerprint of the primary
|
|
|
|
key will be returned. If the crypto engine does not provide the
|
|
|
|
fingerprint, @code{fpr} will be a null pointer.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_genkey_result_t gpgme_op_genkey_result (@w{gpgme_ctx_t @var{ctx}})
|
2003-04-24 17:16:28 +00:00
|
|
|
The function @code{gpgme_op_genkey_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_genkey_result_t} pointer to a structure holding the result of
|
2003-04-24 17:16:28 +00:00
|
|
|
a @code{gpgme_op_genkey} operation. The pointer is only valid if the
|
|
|
|
last operation on the context was a @code{gpgme_op_genkey} or
|
|
|
|
@code{gpgme_op_genkey_start} operation, and if this operation finished
|
|
|
|
successfully. The returned pointer is only valid until the next
|
|
|
|
operation is started on the context.
|
|
|
|
@end deftypefun
|
2002-01-22 14:23:56 +00:00
|
|
|
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Exporting Keys
|
|
|
|
@subsection Exporting Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key, export
|
|
|
|
@cindex key ring, export from
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_export (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_recipients_t @var{recipients}}, @w{gpgme_data_t @var{keydata}})
|
2002-01-22 14:23:56 +00:00
|
|
|
The function @code{gpgme_op_export} extracts the public keys of the
|
|
|
|
user IDs in @var{recipients} and returns them in the data buffer
|
|
|
|
@var{keydata}. The type of the public keys returned is determined by
|
|
|
|
the @acronym{ASCII} armor attribute set for the context @var{ctx}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation completed
|
|
|
|
successfully, @code{GPGME_Invalid_Value} if @var{recipients} is
|
|
|
|
@code{NULL} or @var{keydata} is not a valid empty data buffer, and
|
|
|
|
passes through any errors that are reported by the crypto engine
|
|
|
|
support routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_export_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_recipients_t @var{recipients}}, @w{gpgme_data_t @var{keydata}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_export_start} initiates a
|
|
|
|
@code{gpgme_op_export} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, and @code{GPGME_Invalid_Value} if
|
|
|
|
@var{recipients} is @code{NULL} or @var{keydata} is not a valid empty
|
|
|
|
data buffer.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Importing Keys
|
|
|
|
@subsection Importing Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key, import
|
|
|
|
@cindex key ring, import to
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_import (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}})
|
2002-01-22 14:23:56 +00:00
|
|
|
The function @code{gpgme_op_import} adds the keys in the data buffer
|
|
|
|
@var{keydata} to the key ring of the crypto engine used by @var{ctx}.
|
|
|
|
The format of @var{keydata} can be @var{ASCII} armored, for example,
|
|
|
|
but the details are specific to the crypto engine.
|
2002-01-30 21:52:32 +00:00
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
After the operation completed successfully, the result can be
|
|
|
|
retrieved with @code{gpgme_op_import_result}.
|
|
|
|
|
2002-01-22 14:23:56 +00:00
|
|
|
The function returns @code{GPGME_No_Error} if the import was completed
|
|
|
|
successfully, @code{GPGME_Invalid_Value} if @var{keydata} if @var{ctx}
|
2002-08-20 15:44:48 +00:00
|
|
|
or @var{keydata} is not a valid pointer, and @code{GPGME_No_Data} if
|
|
|
|
@var{keydata} is an empty data buffer.
|
2002-01-22 14:23:56 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_import_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_import_start} initiates a
|
|
|
|
@code{gpgme_op_import} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the import could be
|
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{keydata} if
|
|
|
|
@var{ctx} or @var{keydata} is not a valid pointer, and
|
|
|
|
@code{GPGME_No_Data} if @var{keydata} is an empty data buffer.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_import_status_t}
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
This is a pointer to a structure used to store a part of the result of
|
2003-05-04 14:57:24 +00:00
|
|
|
a @code{gpgme_op_import} operation. For each considered key one
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
status is added that contains information about the result of the
|
|
|
|
import. The structure contains the following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_import_status_t next
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
This is a pointer to the next status structure in the linked list, or
|
|
|
|
@code{NULL} if this is the last element.
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
|
|
|
|
@item char *fpr
|
|
|
|
This is the fingerprint of the key that was considered.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_error_t result
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
If the import was not successful, this is the error value that caused
|
|
|
|
the import to fail. Otherwise it is @code{GPGME_No_Error}.
|
|
|
|
|
|
|
|
@item unsigned int status
|
|
|
|
This is a bit-wise OR of the following flags that give more
|
|
|
|
information about what part of the key was imported. If the key was
|
|
|
|
already known, this might be 0.
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_IMPORT_NEW
|
|
|
|
The key was new.
|
|
|
|
|
|
|
|
@item GPGME_IMPORT_UID
|
|
|
|
The key contained new user IDs.
|
|
|
|
|
|
|
|
@item GPGME_IMPORT_SIG
|
|
|
|
The key contained new signatures.
|
|
|
|
|
|
|
|
@item GPGME_IMPORT_SUBKEY
|
|
|
|
The key contained new sub keys.
|
|
|
|
|
2003-04-25 17:08:00 +00:00
|
|
|
@item GPGME_IMPORT_SECRET
|
|
|
|
The key contained a secret key.
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
@end table
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_import_result_t}
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
2003-05-04 14:57:24 +00:00
|
|
|
@code{gpgme_op_import} operation. After a successful import
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
operation, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_import_result}. The structure contains the following
|
|
|
|
members:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item int considered
|
|
|
|
The total number of considered keys.
|
|
|
|
|
|
|
|
@item int no_user_id
|
|
|
|
The number of keys without user ID.
|
|
|
|
|
|
|
|
@item int imported
|
|
|
|
The total number of imported keys.
|
|
|
|
|
|
|
|
@item imported_rsa
|
|
|
|
The number of imported RSA keys.
|
|
|
|
|
|
|
|
@item unchanged
|
|
|
|
The number of unchanged keys.
|
|
|
|
|
|
|
|
@item new_user_ids
|
|
|
|
The number of new user IDs.
|
|
|
|
|
|
|
|
@item new_sub_keys
|
|
|
|
The number of new sub keys.
|
|
|
|
|
|
|
|
@item new_signatures
|
|
|
|
The number of new signatures.
|
|
|
|
|
|
|
|
@item new_revocations
|
|
|
|
The number of new revocations.
|
|
|
|
|
|
|
|
@item secret_read
|
|
|
|
The total number of secret keys read.
|
|
|
|
|
|
|
|
@item secret_imported
|
|
|
|
The number of imported secret keys.
|
|
|
|
|
|
|
|
@item secret_unchanged
|
|
|
|
The number of unchanged secret keys.
|
|
|
|
|
|
|
|
@item not_imported
|
|
|
|
The number of keys not imported.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_import_status_t imports
|
|
|
|
A list of gpgme_import_status_t objects which contain more information
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
about the keys for which an import was attempted.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_import_result_t gpgme_op_import_result (@w{gpgme_ctx_t @var{ctx}})
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
The function @code{gpgme_op_import_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_import_result_t} pointer to a structure holding the result of
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
a @code{gpgme_op_import} operation. The pointer is only valid if the
|
|
|
|
last operation on the context was a @code{gpgme_op_import} or
|
|
|
|
@code{gpgme_op_import_start} operation, and if this operation finished
|
|
|
|
successfully. The returned pointer is only valid until the next
|
|
|
|
operation is started on the context.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
The following interface is deprecated and only provided for backward
|
|
|
|
compatibility. Don't use it. It will be removed in a future version
|
|
|
|
of @acronym{GPGME}.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_import_ext (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}, @w{int *@var{nr}})
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
The function @code{gpgme_op_import_ext} is equivalent to:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_error_t err = gpgme_op_import (ctx, keydata);
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
if (!err)
|
|
|
|
@{
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_import_result_t result = gpgme_op_import_result (ctx);
|
doc/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Add documentation for
GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result.
gpgme/
2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID,
GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE.
(GpgmeError): GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes.
(struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure.
(GpgmeImportResult): New type.
(gpgme_op_import_result): New function.
* import.c: Include <errno.h> and "gpgme.h", but not "util.h".
(struct import_result): Change to type op_data_t.
(release_import_result): Rename to ...
(release_op_data): ... this.
(append_xml_impinfo): Function removed.
(gpgme_op_import_result): New function.
(parse_import): New function.
(parse_import_res): Likewise.
(import_status_handler): Change first argument to void *. Rewrite
to use new functions.
(_gpgme_op_import_start): Rework error handling.
2003-04-25 15:56:24 +00:00
|
|
|
*nr = result->considered;
|
|
|
|
@}
|
|
|
|
@end example
|
2002-08-20 13:38:40 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Deleting Keys
|
|
|
|
@subsection Deleting Keys
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex key, delete
|
|
|
|
@cindex key ring, delete from
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_delete (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{int @var{allow_secret}})
|
2002-01-22 14:23:56 +00:00
|
|
|
The function @code{gpgme_op_delete} deletes the key @var{key} from the
|
|
|
|
key ring of the crypto engine used by @var{ctx}. If
|
|
|
|
@var{allow_secret} is @code{0}, only public keys are deleted,
|
2002-07-25 18:50:23 +00:00
|
|
|
otherwise secret keys are deleted as well, if that is supported.
|
2002-01-22 14:23:56 +00:00
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the key was deleted
|
2002-01-30 22:48:09 +00:00
|
|
|
successfully, @code{GPGME_Invalid_Value} if @var{ctx} or @var{key} is
|
|
|
|
not a valid pointer, @code{GPGME_Invalid_Key} if @var{key} could not
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Deleting Keys): Document
GPGME_Ambiguous_Specification.
(Error Values): Remove GPGME_Invalid_Type and GPGME_Invalid_Mode.
Add GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* delete.c: Include <errno.h> and "gpgme.h", but not "util.h" or
"key.h".
(enum delete_problem): Move into function delete_status_handler.
(delete_status_handler): Change first argument to void *. Parse
delete problem with strtol instead atoi. Return better error
values.
(_gpgme_op_delete_start): Rename to ...
(delete_start): ... this. Rework error handling.
(gpgme_op_delete_start): Use delete_start instead
_gpgme_op_delete_start.
(gpgme_op_delete): Likewise.
* gpgme.h (GpgmeDataType): Removed.
2003-04-27 17:35:42 +00:00
|
|
|
be found in the keyring, @code{GPGME_Ambiguous_Specification} if the
|
|
|
|
key was not specified unambiguously, and @code{GPGME_Conflict} if the
|
|
|
|
secret key for @var{key} is available, but @var{allow_secret} is zero.
|
2002-01-22 14:23:56 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_delete_start (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{int @var{allow_secret}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_delete_start} initiates a
|
|
|
|
@code{gpgme_op_delete} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation was
|
|
|
|
started successfully, and @code{GPGME_Invalid_Value} if @var{ctx} or
|
|
|
|
@var{key} is not a valid pointer.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-22 14:23:56 +00:00
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@node Trust Item Management
|
|
|
|
@section Trust Item Management
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex trust item
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@strong{Caution:} The trust items interface is experimental.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_trust_item_t
|
|
|
|
The @code{gpgme_trust_item_t} type is a pointer to a trust item object.
|
2003-04-29 21:53:58 +00:00
|
|
|
It has the following members:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item char *keyid
|
|
|
|
This is a string describing the key to which this trust items belongs.
|
|
|
|
|
|
|
|
@item int type
|
|
|
|
This is the type of the trust item. A value of 1 refers to a key, a
|
|
|
|
value of 2 refers to a user ID.
|
|
|
|
|
|
|
|
@item int level
|
|
|
|
This is the trust level.
|
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
@item char *owner_trust
|
2003-04-29 21:53:58 +00:00
|
|
|
The owner trust if @code{type} is 1.
|
|
|
|
|
2003-04-30 03:02:50 +00:00
|
|
|
@item char *validity
|
2003-04-29 21:53:58 +00:00
|
|
|
The calculated validity.
|
|
|
|
|
|
|
|
@item char *name
|
|
|
|
The user name if @code{type} is 2.
|
|
|
|
@end table
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftp
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Listing Trust Items:: Browsing the list of available trust items.
|
2003-05-18 20:45:24 +00:00
|
|
|
* Information About Trust Items:: Requesting information about trust items.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Manipulating Trust Items:: Operations on trust items.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Listing Trust Items
|
|
|
|
@subsection Listing Trust Items
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex trust item list
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_trustlist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{max_level}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_trustlist_start} initiates a trust item
|
|
|
|
listing operation inside the context @var{ctx}. It sets everything up
|
|
|
|
so that subsequent invocations of @code{gpgme_op_trustlist_next} return
|
2002-01-30 01:43:05 +00:00
|
|
|
the trust items in the list.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The string @var{pattern} contains an engine specific expression that
|
|
|
|
is used to limit the list to all trust items matching the pattern. It
|
|
|
|
can not be the empty string.
|
|
|
|
|
|
|
|
The argument @var{max_level} is currently ignored.
|
|
|
|
|
|
|
|
The context will be busy until either all trust items are received
|
|
|
|
(and @code{gpgme_op_trustlist_next} returns @code{GPGME_EOF}), or
|
|
|
|
@code{gpgme_op_trustlist_end} is called to finish the operation.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} is not a
|
|
|
|
valid pointer, and passes through any errors that are reported by the
|
|
|
|
crypto engine support routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_trustlist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_trust_item_t *@var{r_item}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_trustlist_next} returns the next trust
|
|
|
|
item in the list created by a previous @code{gpgme_op_trustlist_start}
|
|
|
|
operation in the context @var{ctx}. The trust item can be destroyed
|
2002-01-29 22:58:25 +00:00
|
|
|
with @code{gpgme_trust_item_release}. @xref{Manipulating Trust Items}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
This is the only way to get at @code{gpgme_trust_item_t} objects in
|
2002-01-16 00:41:10 +00:00
|
|
|
@acronym{GPGME}.
|
|
|
|
|
|
|
|
If the last trust item in the list has already been returned,
|
|
|
|
@code{gpgme_op_trustlist_next} returns @code{GPGME_EOF}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} or
|
2003-04-24 14:33:13 +00:00
|
|
|
@var{r_item} is not a valid pointer, and @code{GPGME_Out_Of_Core} if
|
|
|
|
there is not enough memory for the operation.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_trustlist_end (@w{gpgme_ctx_t @var{ctx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_trustlist_next} ends a pending key list
|
|
|
|
operation in the context @var{ctx}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_Invalid_Value} if @var{ctx} is not a
|
2003-04-24 14:33:13 +00:00
|
|
|
valid pointer, and @code{GPGME_Out_Of_Core} if at some time during the
|
2002-01-16 00:41:10 +00:00
|
|
|
operation there was not enough memory available.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Information About Trust Items
|
|
|
|
@subsection Information About Trust Items
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex trust item, information about
|
|
|
|
@cindex trust item, attributes
|
|
|
|
@cindex attributes, of a trust item
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-29 21:53:58 +00:00
|
|
|
The following interfaces are deprecated and only provided for backward
|
|
|
|
compatibility. Don't use them. They will be removed in a future
|
|
|
|
version of @acronym{GPGME}.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
Trust items have attributes which can be queried using the interfaces
|
|
|
|
below. The attribute identifiers are shared with those for key
|
2002-01-29 22:58:25 +00:00
|
|
|
attributes. @xref{Information About Keys}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_trust_item_get_string_attr (@w{gpgme_trust_item_t @var{item}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_trust_item_get_string_attr} returns the value
|
|
|
|
of the string-representable attribute @var{what} of trust item
|
2002-06-27 16:34:10 +00:00
|
|
|
@var{item}. The arguments @var{idx} and @var{reserved} are reserved
|
|
|
|
for later use and should be @code{0} and @code{NULL} respectively.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The string returned is only valid as long as the key is valid.
|
|
|
|
|
|
|
|
The function returns @code{0} if an attribute can't be returned as a
|
|
|
|
string, @var{key} is not a valid pointer, @var{idx} out of range,
|
|
|
|
or @var{reserved} not @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun int gpgme_trust_item_get_int_attr (@w{gpgme_trust_item_t @var{item}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_trust_item_get_int_attr} returns the value of
|
|
|
|
the number-representable attribute @var{what} of trust item
|
|
|
|
@var{item}. If the attribute occurs more than once in the trust item,
|
|
|
|
the index is specified by @var{idx}. However, currently no such
|
|
|
|
attribute exists, so @var{idx} should be @code{0}. The argument
|
|
|
|
@var{reserved} is reserved for later use and should be @code{NULL}.
|
|
|
|
|
|
|
|
The function returns @code{0} if the attribute can't be returned as a
|
|
|
|
number, @var{key} is not a valid pointer, @var{idx} out of range,
|
|
|
|
or @var{reserved} not @code{NULL}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Manipulating Trust Items
|
|
|
|
@subsection Manipulating Trust Items
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex trust item, manipulation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_trust_item_ref (@w{gpgme_trust_item_t @var{item}})
|
2003-04-29 21:53:58 +00:00
|
|
|
The function @code{gpgme_trust_item_ref} acquires an additional
|
|
|
|
reference for the trust item @var{item}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_trust_item_unref (@w{gpgme_trust_item_t @var{item}})
|
2003-04-29 21:53:58 +00:00
|
|
|
The function @code{gpgme_trust_item_unref} releases a reference for
|
|
|
|
the trust item @var{item}. If this was the last reference, the trust
|
|
|
|
item will be destroyed and all resources associated to it will be
|
|
|
|
released.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
The following interface is deprecated and only provided for backward
|
|
|
|
compatibility. Don't use it. It will be removed in a future version
|
|
|
|
of @acronym{GPGME}.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_trust_item_release (@w{gpgme_trust_item_t @var{item}})
|
2003-04-29 21:53:58 +00:00
|
|
|
The function @code{gpgme_trust_item_release} is an alias for
|
|
|
|
@code{gpgme_trust_item_unref}.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@node Crypto Operations
|
|
|
|
@section Crypto Operations
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex cryptographic operation
|
2002-01-16 00:41:10 +00:00
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
Sometimes, the result of a crypto operation returns a list of invalid
|
|
|
|
user IDs encountered in processing the request. The following
|
|
|
|
structure is used to hold information about such an user ID.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_invalid_user_id_t}
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
This is a pointer to a structure used to store a part of the result of
|
|
|
|
a crypto operation which takes user IDs as one input parameter. The
|
|
|
|
structure contains the following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_invalid_user_id_t next
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
This is a pointer to the next invalid user ID structure in the linked
|
|
|
|
list, or @code{NULL} if this is the last element.
|
|
|
|
|
|
|
|
@item char *id
|
|
|
|
The invalid user ID encountered.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_error_t reason
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
An error code describing the reason why the user ID was found invalid.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@menu
|
|
|
|
* Decrypt:: Decrypting a ciphertext.
|
|
|
|
* Verify:: Verifying a signature.
|
2002-01-29 22:58:25 +00:00
|
|
|
* Decrypt and Verify:: Decrypting a signed ciphertext.
|
2002-01-16 00:41:10 +00:00
|
|
|
* Sign:: Creating a signature.
|
|
|
|
* Encrypt:: Encrypting a plaintext.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node Decrypt
|
|
|
|
@subsection Decrypt
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex decryption
|
|
|
|
@cindex cryptographic operation, decryption
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_decrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_decrypt} decrypts the ciphertext in the
|
|
|
|
data object @var{cipher} and stores it into the data object
|
|
|
|
@var{plain}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the ciphertext could be
|
|
|
|
decrypted successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{cipher} or @var{plain} is not a valid pointer,
|
|
|
|
@code{GPGME_No_Data} if @var{cipher} does not contain any data to
|
|
|
|
decrypt, @code{GPGME_Decryption_Failed} if @var{cipher} is not a valid
|
2003-04-24 14:33:13 +00:00
|
|
|
cipher text, @code{GPGME_Bad_Passphrase} if the passphrase for the
|
2002-01-16 00:41:10 +00:00
|
|
|
secret key could not be retrieved, and passes through any errors that
|
|
|
|
are reported by the crypto engine support routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_decrypt_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_decrypt_start} initiates a
|
|
|
|
@code{gpgme_op_decrypt} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, and @code{GPGME_Invalid_Value} if @var{cipher}
|
|
|
|
or @var{plain} is not a valid pointer.
|
|
|
|
@end deftypefun
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_decrypt_result_t}
|
2003-04-28 21:17:15 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
|
|
|
@code{gpgme_op_decrypt} operation. After successfully encrypting
|
|
|
|
data, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_decrypt_result}. The structure contains the following
|
|
|
|
members:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item char *unsupported_algorithm
|
|
|
|
If an unsupported algorithm was encountered, this string describes the
|
|
|
|
algorithm that is not supported.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_decrypt_result_t gpgme_op_decrypt_result (@w{gpgme_ctx_t @var{ctx}})
|
2003-04-28 21:17:15 +00:00
|
|
|
The function @code{gpgme_op_decrypt_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_decrypt_result_t} pointer to a structure holding the result of
|
2003-04-28 21:17:15 +00:00
|
|
|
a @code{gpgme_op_decrypt} operation. The pointer is only valid if the
|
|
|
|
last operation on the context was a @code{gpgme_op_decrypt} or
|
|
|
|
@code{gpgme_op_decrypt_start} operation, and if this operation
|
|
|
|
finished successfully. The returned pointer is only valid until the
|
|
|
|
next operation is started on the context.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@node Verify
|
|
|
|
@subsection Verify
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex verification
|
|
|
|
@cindex signature, verification
|
|
|
|
@cindex cryptographic operation, verification
|
|
|
|
@cindex cryptographic operation, signature check
|
2002-11-21 13:45:00 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_verify (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_data_t @var{signed_text}}, @w{gpgme_data_t @var{plain}})
|
2002-03-03 16:46:33 +00:00
|
|
|
The function @code{gpgme_op_verify} verifies that the signature in the
|
2002-11-21 13:45:00 +00:00
|
|
|
data object @var{sig} is a valid signature. If @var{sig} is a
|
|
|
|
detached signature, then the signed text should be provided in
|
|
|
|
@var{signed_text} and @var{plain} should be a null pointer.
|
|
|
|
Otherwise, if @var{sig} is a normal (or cleartext) signature,
|
|
|
|
@var{signed_text} should be a null pointer and @var{plain} should be a
|
|
|
|
writable data object that will contain the plaintext after successful
|
|
|
|
verification.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The results of the individual signature verifications can be retrieved
|
2003-04-28 23:59:03 +00:00
|
|
|
with @code{gpgme_op_verify_result}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
completed successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{sig}, @var{plain} or @var{r_stat} is not a valid pointer,
|
2002-03-03 16:46:33 +00:00
|
|
|
@code{GPGME_No_Data} if @var{sig} does not contain any data to verify,
|
|
|
|
and passes through any errors that are reported by the crypto engine
|
|
|
|
support routines.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_verify_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_data_t @var{signed_text}}, @w{gpgme_data_t @var{plain}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_verify_start} initiates a
|
|
|
|
@code{gpgme_op_verify} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{sig}, @var{plain} or @var{r_stat} is not a valid pointer, and
|
|
|
|
@code{GPGME_No_Data} if @var{sig} or @var{plain} does not contain any
|
|
|
|
data to verify.
|
|
|
|
@end deftypefun
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_sig_notation_t}
|
2003-04-28 23:59:03 +00:00
|
|
|
This is a pointer to a structure used to store a part of the result of
|
|
|
|
a @code{gpgme_op_verify} operation. The structure contains the
|
|
|
|
following members:
|
2002-05-03 18:20:24 +00:00
|
|
|
|
2002-06-20 12:13:44 +00:00
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_sig_notation_t next
|
2003-04-28 23:59:03 +00:00
|
|
|
This is a pointer to the next new signature notation structure in the
|
|
|
|
linked list, or @code{NULL} if this is the last element.
|
2002-06-20 12:13:44 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
@item char *name
|
|
|
|
The name of the notation field. If this is @code{NULL}, then the
|
|
|
|
member @code{value} will contain a policy URL.
|
2002-06-20 12:13:44 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
@item char *value
|
|
|
|
The value of the notation field. If @code{name} is @code{NULL}, then
|
|
|
|
this is a policy URL.
|
2002-06-20 12:13:44 +00:00
|
|
|
@end table
|
2003-04-28 23:59:03 +00:00
|
|
|
@end deftp
|
2002-05-03 18:20:24 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_signature_t}
|
2003-04-28 23:59:03 +00:00
|
|
|
This is a pointer to a structure used to store a part of the result of
|
|
|
|
a @code{gpgme_op_verify} operation. The structure contains the
|
|
|
|
following members:
|
2002-05-03 18:20:24 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_signature_t next
|
2003-04-28 23:59:03 +00:00
|
|
|
This is a pointer to the next new signature structure in the linked
|
|
|
|
list, or @code{NULL} if this is the last element.
|
2002-05-03 18:20:24 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
@item unsigned int summary;
|
|
|
|
This is a bit vector giving a summary of the signature status. It
|
|
|
|
provides an easy interface to a defined semantic of the signature
|
|
|
|
status. Checking just one bit is sufficient to see whether a
|
|
|
|
signature is valid without any restrictions.
|
2002-06-12 14:34:15 +00:00
|
|
|
|
|
|
|
The defined bits are:
|
|
|
|
@table @code
|
|
|
|
@item GPGME_SIGSUM_VALID
|
|
|
|
The signature is fully valid.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_GREEN
|
|
|
|
The signature is good but one might want to display some extra
|
|
|
|
information. Check the other bits.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_RED
|
|
|
|
The signature is bad. It might be useful to checkother bits and
|
|
|
|
display moe information, i.e. a revoked certificate might not render a
|
|
|
|
signature invalid when the message was received prior to the cause for
|
|
|
|
the revocation.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_KEY_REVOKED
|
|
|
|
The key or at least one certificate has been revoked.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_KEY_EXPIRED
|
|
|
|
The key or one of the certificates has expired. It is probably a good
|
|
|
|
idea to display the date of the expiration.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_SIG_EXPIRED
|
|
|
|
The signature has expired.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_KEY_MISSING
|
|
|
|
Can't verifydue to a missing key o certificate.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_CRL_MISSING
|
|
|
|
The CRL (or an equivalent mechanism) is not available.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_CRL_TOO_OLD
|
|
|
|
Available CRL is too old.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_BAD_POLICY
|
|
|
|
A policy requirement was not met.
|
|
|
|
|
|
|
|
@item GPGME_SIGSUM_SYS_ERROR
|
|
|
|
A system error occured.
|
2003-04-28 23:59:03 +00:00
|
|
|
@end table
|
|
|
|
|
|
|
|
@item char *fpr
|
|
|
|
This is the fingerprint or key ID of the signature.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_error_t status
|
2003-04-28 23:59:03 +00:00
|
|
|
This is the status of the signature. In particular, the following
|
|
|
|
status codes are of interest:
|
2002-06-12 14:34:15 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
@table @code
|
|
|
|
@item GPGME_No_Error
|
|
|
|
This status indicates that the signature is valid. For the combined
|
|
|
|
result this status means that all signatures are valid.
|
|
|
|
|
|
|
|
@item GPGME_Sig_Expired
|
|
|
|
This status indicates that the signature is valid but expired. For
|
|
|
|
the combined result this status means that all signatures are valid
|
|
|
|
and expired.
|
|
|
|
|
|
|
|
@item GPGME_Key_Expired
|
|
|
|
This status indicates that the signature is valid but the key used to
|
|
|
|
verify the signature has expired. For the combined result this status
|
|
|
|
means that all signatures are valid and all keys are expired.
|
|
|
|
|
|
|
|
@item GPGME_Bad_Signature
|
|
|
|
This status indicates that the signature is invalid. For the combined
|
|
|
|
result this status means that all signatures are invalid.
|
|
|
|
|
|
|
|
@item GPGME_No_Public_Key
|
|
|
|
This status indicates that the signature could not be verified due to
|
|
|
|
a missing key. For the combined result this status means that all
|
|
|
|
signatures could not be checked due to missing keys.
|
|
|
|
|
|
|
|
@item GPGME_General_Error
|
|
|
|
This status indicates that there was some other error which prevented
|
|
|
|
the signature verification.
|
2002-06-12 14:34:15 +00:00
|
|
|
@end table
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_sig_notation_t notations
|
2003-04-28 23:59:03 +00:00
|
|
|
This is a linked list with the notation data and policy URLs.
|
|
|
|
|
|
|
|
@item unsigned long timestamp
|
|
|
|
The creation timestamp of this signature.
|
|
|
|
|
|
|
|
@item unsigned long exp_timestamp
|
|
|
|
The expiration timestamp of this signature, or 0 if the signature does
|
|
|
|
not expire.
|
|
|
|
|
|
|
|
@item int wrong_key_usage : 1;
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_validity_t validity
|
2003-04-28 23:59:03 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_error_t validity_reason
|
2003-04-28 23:59:03 +00:00
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_verify_result_t}
|
2003-04-28 23:59:03 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
|
|
|
@code{gpgme_op_verify} operation. After successfully verifying a
|
|
|
|
signature, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_verify_result}. The structure contains the following
|
|
|
|
member:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_signature_t signatures
|
2003-04-28 23:59:03 +00:00
|
|
|
A linked list with information about all signatures for which a
|
|
|
|
verification was attempted.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_sign_result_t gpgme_op_verify_result (@w{gpgme_ctx_t @var{ctx}})
|
2003-04-28 23:59:03 +00:00
|
|
|
The function @code{gpgme_op_verify_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_verify_result_t} pointer to a structure holding the result of
|
2003-04-28 23:59:03 +00:00
|
|
|
a @code{gpgme_op_verify} operation. The pointer is only valid if the
|
|
|
|
last operation on the context was a @code{gpgme_op_verify} or
|
|
|
|
@code{gpgme_op_verify_start} operation, and if this operation finished
|
|
|
|
successfully. The returned pointer is only valid until the next
|
|
|
|
operation is started on the context.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
The following interfaces are deprecated and only provided for backward
|
|
|
|
compatibility. Don't use them. They will be removed in a future
|
|
|
|
version of @acronym{GPGME}.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_sig_stat_t}
|
|
|
|
@tindex gpgme_sig_stat_t
|
|
|
|
The @code{gpgme_sig_stat_t} type holds the result of a signature check, or
|
2003-04-28 23:59:03 +00:00
|
|
|
the combined result of all signatures. The following results are
|
|
|
|
possible:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_SIG_STAT_NONE
|
|
|
|
This status should not occur in normal operation.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_GOOD
|
|
|
|
This status indicates that the signature is valid. For the combined
|
|
|
|
result this status means that all signatures are valid.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_GOOD_EXP
|
|
|
|
This status indicates that the signature is valid but expired. For
|
|
|
|
the combined result this status means that all signatures are valid
|
|
|
|
and expired.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_GOOD_EXPKEY
|
|
|
|
This status indicates that the signature is valid but the key used to
|
|
|
|
verify the signature has expired. For the combined result this status
|
|
|
|
means that all signatures are valid and all keys are expired.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_BAD
|
|
|
|
This status indicates that the signature is invalid. For the combined
|
|
|
|
result this status means that all signatures are invalid.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_NOKEY
|
|
|
|
This status indicates that the signature could not be verified due to
|
|
|
|
a missing key. For the combined result this status means that all
|
|
|
|
signatures could not be checked due to missing keys.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_NOSIG
|
|
|
|
This status indicates that the signature data provided was not a real
|
|
|
|
signature.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_ERROR
|
|
|
|
This status indicates that there was some other error which prevented
|
|
|
|
the signature verification.
|
|
|
|
|
|
|
|
@item GPGME_SIG_STAT_DIFF
|
|
|
|
For the combined result this status means that at least two signatures
|
|
|
|
have a different status. You can get each key's status with
|
|
|
|
@code{gpgme_get_sig_status}.
|
2002-05-03 18:20:24 +00:00
|
|
|
@end table
|
2003-04-28 23:59:03 +00:00
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_get_sig_status (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_sig_stat_t *@var{r_stat}}, @w{time_t *@var{r_created}})
|
2003-04-28 23:59:03 +00:00
|
|
|
The function @code{gpgme_get_sig_status} is equivalent to:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_verify_result_t result;
|
|
|
|
gpgme_signature_t sig;
|
2003-04-28 23:59:03 +00:00
|
|
|
|
|
|
|
result = gpgme_op_verify_result (ctx);
|
|
|
|
sig = result->signatures;
|
|
|
|
|
|
|
|
while (sig && idx)
|
|
|
|
@{
|
|
|
|
sig = sig->next;
|
|
|
|
idx--;
|
|
|
|
@}
|
|
|
|
if (!sig || idx)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (r_stat)
|
|
|
|
@{
|
|
|
|
switch (sig->status)
|
|
|
|
@{
|
|
|
|
case GPGME_No_Error:
|
|
|
|
*r_stat = GPGME_SIG_STAT_GOOD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPGME_Bad_Signature:
|
|
|
|
*r_stat = GPGME_SIG_STAT_BAD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPGME_No_Public_Key:
|
|
|
|
*r_stat = GPGME_SIG_STAT_NOKEY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPGME_No_Data:
|
|
|
|
*r_stat = GPGME_SIG_STAT_NOSIG;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPGME_Sig_Expired:
|
|
|
|
*r_stat = GPGME_SIG_STAT_GOOD_EXP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPGME_Key_Expired:
|
|
|
|
*r_stat = GPGME_SIG_STAT_GOOD_EXPKEY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
*r_stat = GPGME_SIG_STAT_ERROR;
|
|
|
|
break;
|
|
|
|
@}
|
|
|
|
@}
|
|
|
|
if (r_created)
|
|
|
|
*r_created = sig->timestamp;
|
|
|
|
return sig->fpr;
|
|
|
|
@end example
|
2002-05-03 18:20:24 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_get_sig_string_attr (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_attr_t @var{what}}, @w{int @var{whatidx}})
|
2003-04-28 23:59:03 +00:00
|
|
|
The function @code{gpgme_get_sig_string_attr} is equivalent to:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_verify_result_t result;
|
|
|
|
gpgme_signature_t sig;
|
2002-05-03 18:20:24 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
result = gpgme_op_verify_result (ctx);
|
|
|
|
sig = result->signatures;
|
|
|
|
|
|
|
|
while (sig && idx)
|
|
|
|
@{
|
|
|
|
sig = sig->next;
|
|
|
|
idx--;
|
|
|
|
@}
|
|
|
|
if (!sig || idx)
|
|
|
|
return NULL;
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
switch (what)
|
|
|
|
@{
|
|
|
|
case GPGME_ATTR_FPR:
|
|
|
|
return sig->fpr;
|
|
|
|
|
|
|
|
case GPGME_ATTR_ERRTOK:
|
|
|
|
if (whatidx == 1)
|
|
|
|
return sig->wrong_key_usage ? "Wrong_Key_Usage" : "";
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
@}
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
return NULL;
|
|
|
|
@end example
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_get_sig_ulong_attr (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_attr_t @var{waht}}, @w{int @var{whatidx}})
|
2003-04-28 23:59:03 +00:00
|
|
|
The function @code{gpgme_get_sig_ulong_attr} is equivalent to:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_verify_result_t result;
|
|
|
|
gpgme_signature_t sig;
|
2003-04-28 23:59:03 +00:00
|
|
|
|
|
|
|
result = gpgme_op_verify_result (ctx);
|
|
|
|
sig = result->signatures;
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
while (sig && idx)
|
|
|
|
@{
|
|
|
|
sig = sig->next;
|
|
|
|
idx--;
|
|
|
|
@}
|
|
|
|
if (!sig || idx)
|
|
|
|
return 0;
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
switch (what)
|
|
|
|
@{
|
|
|
|
case GPGME_ATTR_CREATED:
|
|
|
|
return sig->timestamp;
|
|
|
|
|
|
|
|
case GPGME_ATTR_EXPIRE:
|
|
|
|
return sig->exp_timestamp;
|
|
|
|
|
|
|
|
case GPGME_ATTR_VALIDITY:
|
|
|
|
return (unsigned long) sig->validity;
|
|
|
|
|
|
|
|
case GPGME_ATTR_SIG_STATUS:
|
|
|
|
switch (sig->status)
|
|
|
|
@{
|
|
|
|
case GPGME_No_Error:
|
|
|
|
return GPGME_SIG_STAT_GOOD;
|
|
|
|
|
|
|
|
case GPGME_Bad_Signature:
|
|
|
|
return GPGME_SIG_STAT_BAD;
|
|
|
|
|
|
|
|
case GPGME_No_Public_Key:
|
|
|
|
return GPGME_SIG_STAT_NOKEY;
|
|
|
|
|
|
|
|
case GPGME_No_Data:
|
|
|
|
return GPGME_SIG_STAT_NOSIG;
|
|
|
|
|
|
|
|
case GPGME_Sig_Expired:
|
|
|
|
return GPGME_SIG_STAT_GOOD_EXP;
|
|
|
|
|
|
|
|
case GPGME_Key_Expired:
|
|
|
|
return GPGME_SIG_STAT_GOOD_EXPKEY;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return GPGME_SIG_STAT_ERROR;
|
|
|
|
@}
|
|
|
|
|
|
|
|
case GPGME_ATTR_SIG_SUMMARY:
|
|
|
|
return sig->summary;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
@}
|
|
|
|
return 0;
|
|
|
|
@end example
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_get_sig_key (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_key_t *@var{r_key}})
|
2003-04-28 23:59:03 +00:00
|
|
|
The function @code{gpgme_get_sig_key} is equivalent to:
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_verify_result_t result;
|
|
|
|
gpgme_signature_t sig;
|
2003-04-28 23:59:03 +00:00
|
|
|
|
|
|
|
result = gpgme_op_verify_result (ctx);
|
|
|
|
sig = result->signatures;
|
|
|
|
|
|
|
|
while (sig && idx)
|
|
|
|
@{
|
|
|
|
sig = sig->next;
|
|
|
|
idx--;
|
|
|
|
@}
|
|
|
|
if (!sig || idx)
|
|
|
|
return GPGME_EOF;
|
|
|
|
|
|
|
|
return gpgme_get_key (ctx, sig->fpr, r_key, 0, 0);
|
|
|
|
@end example
|
2002-01-29 22:58:25 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Decrypt and Verify
|
|
|
|
@subsection Decrypt and Verify
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex decryption and verification
|
|
|
|
@cindex verification and decryption
|
|
|
|
@cindex signature check
|
|
|
|
@cindex cryptographic operation, decryption and verification
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_decrypt_verify (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_decrypt_verify} decrypts the ciphertext in
|
|
|
|
the data object @var{cipher} and stores it into the data object
|
|
|
|
@var{plain}. If @var{cipher} contains signatures, they will be
|
2002-12-24 13:08:56 +00:00
|
|
|
verified.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
After the operation completed, @code{gpgme_op_get_sig_status} and
|
|
|
|
@code{gpgme_op_get_sig_key} can be used to retrieve more information
|
|
|
|
about the signatures.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the ciphertext could be
|
|
|
|
decrypted successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{cipher}, @var{plain} or @var{r_stat} is not a valid pointer,
|
|
|
|
@code{GPGME_No_Data} if @var{cipher} does not contain any data to
|
|
|
|
decrypt, @code{GPGME_Decryption_Failed} if @var{cipher} is not a valid
|
2003-04-24 14:33:13 +00:00
|
|
|
cipher text, @code{GPGME_Bad_Passphrase} if the passphrase for the
|
2002-01-16 00:41:10 +00:00
|
|
|
secret key could not be retrieved, and passes through any errors that
|
|
|
|
are reported by the crypto engine support routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_decrypt_verify (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_decrypt_verify_start} initiates a
|
|
|
|
@code{gpgme_op_decrypt_verify} operation. It can be completed by
|
|
|
|
calling @code{gpgme_wait} on the context. @xref{Waiting For
|
|
|
|
Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{cipher}, @var{plain} or @var{r_stat} is not a valid pointer, and
|
|
|
|
@code{GPGME_No_Data} if @var{cipher} does not contain any data to
|
|
|
|
decrypt.
|
|
|
|
@end deftypefun
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
@node Sign
|
|
|
|
@subsection Sign
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex signature, creation
|
|
|
|
@cindex sign
|
|
|
|
@cindex cryptographic operation, signing
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
A signature can contain signatures by one or more keys. The set of
|
|
|
|
keys used to create a signatures is contained in a context, and is
|
|
|
|
applied to all following signing operations in this context (until the
|
|
|
|
set is changed).
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Selecting Signers:: How to choose the keys to sign with.
|
|
|
|
* Creating a Signature:: How to create a signature.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Selecting Signers
|
|
|
|
@subsubsection Selecting Signers
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex signature, selecting signers
|
|
|
|
@cindex signers, selecting
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_signers_clear (@w{gpgme_ctx_t @var{ctx}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_signers_clear} releases a reference for each
|
|
|
|
key on the signers list and removes the list of signers from the
|
|
|
|
context @var{ctx}.
|
|
|
|
|
|
|
|
Every context starts with an empty list.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_signers_add (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_signers_add} adds the key @var{key} to the
|
|
|
|
list of signers in the context @var{ctx}.
|
|
|
|
|
2002-08-30 11:37:59 +00:00
|
|
|
Calling this function acquires an additional reference for the key.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_key_t gpgme_signers_enum (@w{const gpgme_ctx_t @var{ctx}}, @w{int @var{seq}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_signers_enum} returns the @var{seq}th key in
|
|
|
|
the list of signers in the context @var{ctx}. An additional reference
|
|
|
|
is acquired for the user.
|
|
|
|
|
|
|
|
If @var{seq} is out of range, @code{NULL} is returned.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Creating a Signature
|
|
|
|
@subsubsection Creating a Signature
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_sig_mode_t}
|
|
|
|
@tindex gpgme_sig_mode_t
|
|
|
|
The @code{gpgme_sig_mode_t} type is used to specify the desired type of a
|
2002-01-16 00:41:10 +00:00
|
|
|
signature. The following modes are available:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item GPGME_SIG_MODE_NORMAL
|
|
|
|
A normal signature is made, the output includes the plaintext and the
|
|
|
|
signature.
|
|
|
|
|
|
|
|
@item GPGME_SIG_MODE_DETACH
|
|
|
|
A detached signature is made.
|
|
|
|
|
|
|
|
@item GPGME_SIG_MODE_CLEAR
|
|
|
|
A clear text signature is made. The @acronym{ASCII} armor and text
|
|
|
|
mode settings of the context are ignored.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_sign (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_sig_mode_t @var{mode}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_op_sign} creates a signature for the text in
|
|
|
|
the data object @var{plain} and returns it in the data object
|
|
|
|
@var{sig}. The type of the signature created is determined by the
|
2002-01-22 14:23:56 +00:00
|
|
|
@acronym{ASCII} armor and text mode attributes set for the context
|
|
|
|
@var{ctx} and the requested signature mode @var{mode}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
After the operation completed successfully, the result can be
|
|
|
|
retrieved with @code{gpgme_op_sign_result}.
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2002-02-25 18:31:07 +00:00
|
|
|
If an S/MIME signed message is created using the CMS crypto engine,
|
|
|
|
the number of certificates to include in the message can be specified
|
|
|
|
with @code{gpgme_set_include_certs}. @xref{Included Certificates}.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
The function returns @code{GPGME_No_Error} if the signature could be
|
|
|
|
created successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{plain} or @var{sig} is not a valid pointer, @code{GPGME_No_Data}
|
2003-04-24 14:33:13 +00:00
|
|
|
if the signature could not be created, @code{GPGME_Bad_Passphrase} if
|
2002-01-16 00:41:10 +00:00
|
|
|
the passphrase for the secret key could not be retrieved, and passes
|
|
|
|
through any errors that are reported by the crypto engine support
|
|
|
|
routines.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_sig_mode_t @var{mode}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_sign_start} initiates a
|
|
|
|
@code{gpgme_op_sign} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, and @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{plain} or @var{sig} is not a valid pointer.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_new_signature_t}
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
This is a pointer to a structure used to store a part of the result of
|
|
|
|
a @code{gpgme_op_sign} operation. The structure contains the
|
|
|
|
following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_new_signature_t next
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
This is a pointer to the next new signature structure in the linked
|
|
|
|
list, or @code{NULL} if this is the last element.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_sig_mode_t type
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The type of this signature.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_pubkey_algo_t
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The public key algorithm used to create this signature.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_hash_algo_t
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The hash algorithm used to create this signature.
|
|
|
|
|
|
|
|
@item unsigned long class
|
|
|
|
The signature class of this signature.
|
|
|
|
|
2003-04-28 23:59:03 +00:00
|
|
|
@item long int timestamp
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The creation timestamp of this signature.
|
|
|
|
|
|
|
|
@item char *fpr
|
|
|
|
The fingerprint of the key which was used to create this signature.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_sign_result_t}
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
|
|
|
@code{gpgme_op_sign} operation. After successfully generating a
|
|
|
|
signature, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_sign_result}. The structure contains the following
|
|
|
|
members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_invalid_user_id_t invalid_signers
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
A linked list with information about all invalid user IDs for which a
|
|
|
|
signature could not be created.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_new_signature_t signatures
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
A linked list with information about all signatures created.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_sign_result_t gpgme_op_sign_result (@w{gpgme_ctx_t @var{ctx}})
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
The function @code{gpgme_op_sign_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_sign_result_t} pointer to a structure holding the result of a
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
@code{gpgme_op_sign} operation. The pointer is only valid if the last
|
|
|
|
operation on the context was a @code{gpgme_op_sign} or
|
|
|
|
@code{gpgme_op_sign_start} operation, and if this operation finished
|
|
|
|
successfully. The returned pointer is only valid until the next
|
|
|
|
operation is started on the context.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
@node Encrypt
|
|
|
|
@subsection Encrypt
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex encryption
|
|
|
|
@cindex cryptographic operation, encryption
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
One plaintext can be encrypted for several recipients at the same
|
|
|
|
time. The list of recipients is created independently of any context,
|
|
|
|
and then passed to the encryption operation.
|
|
|
|
|
|
|
|
@menu
|
2002-01-29 22:58:25 +00:00
|
|
|
* Selecting Recipients:: How to choose the recipients.
|
|
|
|
* Encrypting a Plaintext:: How to encrypt a plaintext.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Selecting Recipients
|
|
|
|
@subsubsection Selecting Recipients
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex encryption, selecting recipients
|
|
|
|
@cindex recipients
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} gpgme_recipients_t
|
|
|
|
The @code{gpgme_recipients_t} type is a handle for a set of recipients
|
2002-01-16 00:41:10 +00:00
|
|
|
that can be used in an encryption process.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_recipients_new (@w{gpgme_recipients_t *@var{r_rset}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_new} creates a new, empty set of
|
|
|
|
recipients and returns a handle for it in @var{r_rset}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the recipient set could
|
|
|
|
be created successfully, and @code{GPGME_Out_Of_Core} if not enough
|
|
|
|
memory was available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_recipients_release (@w{gpgme_recipients_t @var{rset}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_release} destroys the set of
|
|
|
|
recipients @var{rset} and releases all associated resources.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_recipients_add_name (@w{gpgme_recipients_t @var{rset}}, @w{const char *@var{name}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_add_name} adds the recipient
|
|
|
|
@var{name} to the set of recipients @var{rset}. This is equivalent to
|
|
|
|
@code{gpgme_recipients_add_name_with_validity} with a validity of
|
|
|
|
@code{GPGME_VALIDITY_UNKNOWN}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the recipient was added
|
|
|
|
successfully, @code{GPGME_Invalid_Value} if @var{rset} or @var{name}
|
|
|
|
is not a valid pointer, and @code{GPGME_Out_Of_Core} if not enough
|
|
|
|
memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_recipients_add_name_with_validity (@w{gpgme_recipients_t @var{rset}}, @w{const char *@var{name}}, @w{gpgme_validity_t @var{val}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_add_name_with_validity} adds the
|
|
|
|
recipient @var{name} with the validity @var{val} to the set of
|
|
|
|
recipients @var{rset}. If the validity is not known, the function
|
|
|
|
@code{gpgme_recipients_add_name} can be used.
|
2002-01-29 22:58:25 +00:00
|
|
|
@xref{Information About Keys}, for the possible values for @var{val}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the recipient was added
|
|
|
|
successfully, @code{GPGME_Invalid_Value} if @var{rset} or @var{name}
|
|
|
|
is not a valid pointer, and @code{GPGME_Out_Of_Core} if not enough
|
|
|
|
memory is available.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {unsigned int} gpgme_recipients_count (@w{const @var{gpgme_recipients_t rset}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_count} returns the number of
|
|
|
|
recipients in the set @var{rset}.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_recipients_enum_open (@w{const gpgme_recipients_t @var{rset}}, @w{void **@var{iter}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_enum_open} creates a new iterator
|
|
|
|
@var{iter} that can be used to walk through the set of recipients in
|
|
|
|
@var{rset}, using @code{gpgme_recipients_enum_read}.
|
|
|
|
|
|
|
|
If the iterator is not needed anymore, it can be closed with
|
|
|
|
@code{gpgme_recipients_enum_close}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the enumerator was
|
|
|
|
successfully created and @code{GPGME_Invalid_Value} if @var{rset} or
|
|
|
|
@var{iter} is not a valid pointer.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun {const char *} gpgme_recipients_enum_read (@w{const gpgme_recipients_t @var{rset}}, @w{void **@var{iter}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_enum_read} returns a string
|
|
|
|
containing the name of the next recipient in the set @var{rset} for
|
|
|
|
the iterator @var{iter}. The string is valid as long as @var{rset} is
|
|
|
|
valid or the function is called the next time with the same recipient
|
|
|
|
set and iterator, whatever is earlier.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_recipients_enum_close (@w{const gpgme_recipients_t @var{rset}}, @w{void **@var{iter}})
|
2002-01-16 00:41:10 +00:00
|
|
|
The function @code{gpgme_recipients_enum_close} releases the iterator
|
|
|
|
@var{iter} for the recipient set @var{rset}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Encrypting a Plaintext
|
|
|
|
@subsubsection Encrypting a Plaintext
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_encrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_recipients_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
|
2002-02-26 00:08:09 +00:00
|
|
|
The function @code{gpgme_op_encrypt} encrypts the plaintext in the data
|
2002-01-16 00:41:10 +00:00
|
|
|
object @var{plain} for the recipients @var{rset} and stores the
|
|
|
|
ciphertext in the data object @var{cipher}. The type of the
|
2002-01-22 14:23:56 +00:00
|
|
|
ciphertext created is determined by the @acronym{ASCII} armor and text
|
|
|
|
mode attributes set for the context @var{ctx}.
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2003-04-24 14:33:13 +00:00
|
|
|
If @code{GPGME_Invalid_UserID} is returned, some recipients in
|
2002-02-26 23:39:58 +00:00
|
|
|
@var{rset} are invalid, but not all. In this case the plaintext is
|
|
|
|
encrypted for all valid recipients and returned in @var{cipher}. More
|
|
|
|
information about the invalid recipients is available with
|
doc/
2003-04-30 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Encrypting a Plaintext): Remove reference to
gpgme_get_op_info.
(Detailed Results): Subsection removed.
gpgme/
2003-04-30 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (gpgme_get_op_info): Remove prototype.
* ops.h (_gpgme_set_op_info,
_gpgme_data_release_and_return_string, _gpgme_data_get_as_string,
_gpgme_data_append, _gpgme_data_append_string,
_gpgme_data_append_string_for_xml, _gpgme_data_append_for_xml,
_gpgme_data_append_percentstring_for_xml): Likewise.
(_gpgme_progress_status_handler): Change first arg to void *.
* progress.c (_gpgme_progress_status_handler): Likewise.
* conversion.c: Do not include <string.h>, <errno.h>, <ctype.h>,
and <sys/types.h>, but <string.h>.
(_gpgme_data_append): Remove function.
(_gpgme_data_append_string): Likewise.
(_gpgme_data_append_for_xml): Likewise.
(_gpgme_data_append_string_for_xml): Likewise.
(_gpgme_data_append_percentstring_for_xml): Likewise.
* data-mem.c (_gpgme_data_get_as_string): Likewise.
(_gpgme_data_release_and_return_string): Likewise.
* gpgme.c (gpgme_get_op_info): Likewise.
(_gpgme_set_op_info): Likewise.
tests/
2003-04-30 Marcus Brinkmann <marcus@g10code.de>
* gpg/t-eventloop.c (main): Do not call print_op_info.
(print_op_info): Function removed.
2003-04-30 03:34:30 +00:00
|
|
|
@code{gpgme_op_encrypt_result}.
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2002-03-06 01:40:25 +00:00
|
|
|
If @var{recp} is @code{NULL}, symmetric rather than public key
|
|
|
|
encryption is performed. Symmetrically encrypted cipher text can be
|
|
|
|
deciphered with @code{gpgme_op_decrypt}. Note that in this case the
|
|
|
|
crypto backend needs to retrieve a passphrase from the user.
|
|
|
|
Symmetric encryption is currently only supported for the OpenPGP
|
|
|
|
crypto backend.
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
The function returns @code{GPGME_No_Error} if the ciphertext could be
|
|
|
|
created successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{rset}, @var{plain} or @var{cipher} is not a valid pointer,
|
2003-04-24 14:33:13 +00:00
|
|
|
@code{GPGME_No_UserID} if @var{rset} does not contain any valid
|
|
|
|
recipients, @code{GPGME_Invalid_UserID} if @var{rset} contains some
|
|
|
|
invalid recipients, @code{GPGME_Bad_Passphrase} if the passphrase for
|
|
|
|
the secret key could not be retrieved, and passes through any errors
|
|
|
|
that are reported by the crypto engine support routines.
|
2002-01-16 00:41:10 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_encrypt_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_recipients_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
|
2002-01-30 01:17:30 +00:00
|
|
|
The function @code{gpgme_op_encrypt_start} initiates a
|
|
|
|
@code{gpgme_op_encrypt} operation. It can be completed by calling
|
|
|
|
@code{gpgme_wait} on the context. @xref{Waiting For Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and
|
2003-04-24 14:33:13 +00:00
|
|
|
@code{GPGME_No_UserID} if @var{rset} does not contain any valid
|
2002-01-30 01:17:30 +00:00
|
|
|
recipients.
|
|
|
|
@end deftypefun
|
2002-02-26 00:08:09 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_encrypt_result_t}
|
2003-04-27 22:24:37 +00:00
|
|
|
This is a pointer to a structure used to store the result of a
|
|
|
|
@code{gpgme_op_encrypt} operation. After successfully encrypting
|
|
|
|
data, you can retrieve the pointer to the result with
|
|
|
|
@code{gpgme_op_encrypt_result}. The structure contains the following
|
|
|
|
members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_invalid_user_id_t invalid_recipients
|
2003-04-27 22:24:37 +00:00
|
|
|
A linked list with information about all invalid user IDs for which
|
|
|
|
the data could not be encrypted.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_encrypt_result_t gpgme_op_encrypt_result (@w{gpgme_ctx_t @var{ctx}})
|
2003-04-27 22:24:37 +00:00
|
|
|
The function @code{gpgme_op_encrypt_result} returns a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_encrypt_result_t} pointer to a structure holding the result of
|
2003-04-27 22:24:37 +00:00
|
|
|
a @code{gpgme_op_encrypt} operation. The pointer is only valid if the
|
|
|
|
last operation on the context was a @code{gpgme_op_encrypt} or
|
|
|
|
@code{gpgme_op_encrypt_start} operation, and if this operation
|
|
|
|
finished successfully. The returned pointer is only valid until the
|
|
|
|
next operation is started on the context.
|
|
|
|
@end deftypefun
|
|
|
|
|
2002-02-26 00:08:09 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_encrypt_sign (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_recipients_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
|
2002-02-26 00:08:09 +00:00
|
|
|
The function @code{gpgme_op_encrypt_sign} does a combined encrypt and
|
|
|
|
sign operation. It is used like @code{gpgme_op_encrypt}, but the
|
|
|
|
ciphertext also contains signatures for the signers listed in
|
|
|
|
@var{ctx}.
|
|
|
|
|
|
|
|
The combined encrypt and sign operation is currently only available
|
|
|
|
for the OpenPGP crypto engine.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_recipients_t @var{rset}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
|
2002-02-26 00:08:09 +00:00
|
|
|
The function @code{gpgme_op_encrypt_sign_start} initiates a
|
|
|
|
@code{gpgme_op_encrypt_sign} operation. It can be completed by
|
|
|
|
calling @code{gpgme_wait} on the context. @xref{Waiting For
|
|
|
|
Completion}.
|
|
|
|
|
|
|
|
The function returns @code{GPGME_No_Error} if the operation could be
|
|
|
|
started successfully, @code{GPGME_Invalid_Value} if @var{ctx},
|
|
|
|
@var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and
|
2003-04-24 14:33:13 +00:00
|
|
|
@code{GPGME_No_UserID} if @var{rset} does not contain any valid
|
2002-02-26 00:08:09 +00:00
|
|
|
recipients.
|
|
|
|
@end deftypefun
|
2002-01-30 01:17:30 +00:00
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
|
2002-01-29 22:58:25 +00:00
|
|
|
@node Run Control
|
|
|
|
@section Run Control
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex run control
|
|
|
|
@cindex cryptographic operation, running
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2002-07-03 02:22:38 +00:00
|
|
|
@acronym{GPGME} supports running operations synchronously and
|
|
|
|
asynchronously. You can use asynchronous operation to set up a
|
|
|
|
context up to initiating the desired operation, but delay performing
|
|
|
|
it to a later point.
|
|
|
|
|
|
|
|
Furthermore, you can use an external event loop to control exactly
|
|
|
|
when @acronym{GPGME} runs. This ensures that @acronym{GPGME} only
|
|
|
|
runs when necessary and also prevents it from blocking for a long
|
|
|
|
time.
|
2002-01-29 22:58:25 +00:00
|
|
|
|
|
|
|
@menu
|
|
|
|
* Waiting For Completion:: Waiting until an operation is completed.
|
2002-07-03 02:22:38 +00:00
|
|
|
* Using External Event Loops:: Advanced control over what happens when.
|
2002-01-29 22:58:25 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node Waiting For Completion
|
|
|
|
@subsection Waiting For Completion
|
2002-01-30 01:17:30 +00:00
|
|
|
@cindex cryptographic operation, wait for
|
|
|
|
@cindex wait for completion
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun gpgme_ctx_t gpgme_wait (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_error_t *@var{status}}, @w{int @var{hang}})
|
2002-07-03 02:22:38 +00:00
|
|
|
The function @code{gpgme_wait} continues the pending operation within
|
|
|
|
the context @var{ctx}. In particular, it ensures the data exchange
|
|
|
|
between @acronym{GPGME} and the crypto backend and watches over the
|
|
|
|
run time status of the backend process.
|
2002-01-29 22:58:25 +00:00
|
|
|
|
|
|
|
If @var{hang} is true, the function does not return until the
|
|
|
|
operation is completed or cancelled. Otherwise the function will not
|
|
|
|
block for a long time.
|
|
|
|
|
2002-07-03 02:22:38 +00:00
|
|
|
The error status of the finished operation is returned in @var{status}
|
|
|
|
if @code{gpgme_wait} does not return @code{NULL}.
|
2002-02-06 01:20:49 +00:00
|
|
|
|
|
|
|
The @var{ctx} argument can be @code{NULL}. In that case,
|
|
|
|
@code{gpgme_wait} waits for any context to complete its operation.
|
|
|
|
|
2002-07-03 02:22:38 +00:00
|
|
|
@code{gpgme_wait} can be used only in conjunction with any context
|
|
|
|
that has a pending operation initiated with one of the
|
|
|
|
@code{gpgme_op_*_start} functions except @code{gpgme_op_keylist_start}
|
|
|
|
and @code{gpgme_op_trustlist_start} (for which you should use the
|
|
|
|
corresponding @code{gpgme_op_*_next} functions). If @var{ctx} is
|
|
|
|
@code{NULL}, all of such contexts are waited upon and possibly
|
|
|
|
returned. Synchronous operations running in parallel, as well as key
|
|
|
|
and trust item list operations, do not affect @code{gpgme_wait}.
|
|
|
|
|
|
|
|
In a multi-threaded environment, only one thread should ever call
|
|
|
|
@code{gpgme_wait} at any time, irregardless if @var{ctx} is specified
|
|
|
|
or not. This means that all calls to this function should be fully
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
synchronized by locking primitives. It is safe to start asynchronous
|
|
|
|
operations while a thread is running in @code{gpgme_wait}.
|
2002-07-03 02:22:38 +00:00
|
|
|
|
2002-02-06 01:20:49 +00:00
|
|
|
The function returns the @var{ctx} of the context which has finished
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
the operation. If @var{hang} is false, and the timeout expires,
|
|
|
|
@code{NULL} is returned and @code{*status} will be set to 0. If an
|
|
|
|
error occurs, @code{NULL} is returned and the error is returned in
|
|
|
|
@code{*status}.
|
2002-01-29 22:58:25 +00:00
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
2002-07-03 02:22:38 +00:00
|
|
|
@node Using External Event Loops
|
|
|
|
@subsection Using External Event Loops
|
|
|
|
@cindex event loop, external
|
|
|
|
|
|
|
|
@acronym{GPGME} hides the complexity of the communication between the
|
|
|
|
library and the crypto engine. The price of this convenience is that
|
|
|
|
the calling thread can block arbitrary long waiting for the data
|
|
|
|
returned by the crypto engine. In single-threaded programs, in
|
|
|
|
particular if they are interactive, this is an unwanted side-effect.
|
|
|
|
OTOH, if @code{gpgme_wait} is used without the @var{hang} option being
|
|
|
|
enabled, it might be called unnecessarily often, wasting CPU time that
|
|
|
|
could be used otherwise.
|
|
|
|
|
|
|
|
The I/O callback interface described in this section lets the user
|
|
|
|
take control over what happens when. @acronym{GPGME} will provide the
|
|
|
|
user with the file descriptors that should be monitored, and the
|
|
|
|
callback functions that should be invoked when a file descriptor is
|
|
|
|
ready for reading or writing. It is then the user's responsibility to
|
|
|
|
decide when to check the file descriptors and when to invoke the
|
|
|
|
callback functions. Usually this is done in an event loop, that also
|
|
|
|
checks for events in other parts of the program. If the callback
|
|
|
|
functions are only called when the file descriptors are ready,
|
|
|
|
@acronym{GPGME} will never block. This gives the user mroe control
|
|
|
|
over the program flow, and allows to perform other tasks when
|
|
|
|
@acronym{GPGME} would block otherwise.
|
|
|
|
|
|
|
|
By using this advanced mechanism, @acronym{GPGME} can be integrated
|
|
|
|
smoothly into GUI toolkits like GTK+ even for single-threaded
|
|
|
|
programs.
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* I/O Callback Interface:: How I/O callbacks are registered.
|
|
|
|
* Registering I/O Callbacks:: How to use I/O callbacks for a context.
|
|
|
|
* I/O Callback Example:: An example how to use I/O callbacks.
|
|
|
|
* I/O Callback Example GTK+:: How to use @acronym{GPGME} with GTK+.
|
|
|
|
* I/O Callback Example GDK:: How to use @acronym{GPGME} with GDK.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
|
|
|
|
@node I/O Callback Interface
|
|
|
|
@subsubsection I/O Callback Interface
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_error_t (*gpgme_io_cb_t) (@w{void *@var{data}}, @w{int @var{fd}})}
|
|
|
|
@tindex gpgme_io_cb_t
|
|
|
|
The @code{gpgme_io_cb_t} type is the type of functions which
|
2002-07-03 02:22:38 +00:00
|
|
|
@acronym{GPGME} wants to register as I/O callback handlers using the
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_register_io_cb_t} functions provided by the user.
|
2002-07-03 02:22:38 +00:00
|
|
|
|
|
|
|
@var{data} and @var{fd} are provided by @acronym{GPGME} when the I/O
|
|
|
|
callback handler is registered, and should be passed through to the
|
|
|
|
handler when it is invoked by the user because it noticed activity on
|
|
|
|
the file descriptor @var{fd}.
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
|
|
|
|
The callback handler always returns @code{0}, but you should consider
|
|
|
|
the return value to be reserved for later use.
|
2002-07-03 02:22:38 +00:00
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {gpgme_error_t (*gpgme_register_io_cb_t) (@w{void *@var{data}}, @w{int @var{fd}}, @w{int @var{dir}}, @w{gpgme_io_cb_t @var{fnc}}, @w{void *@var{fnc_data}}, @w{void **@var{tag}})}
|
|
|
|
@tindex gpgme_register_io_cb_t
|
|
|
|
The @code{gpgme_register_io_cb_t} type is the type of functions which can
|
2002-07-03 02:22:38 +00:00
|
|
|
be called by @acronym{GPGME} to register an I/O callback funtion
|
|
|
|
@var{fnc} for the file descriptor @var{fd} with the user.
|
|
|
|
@var{fnc_data} should be passed as the first argument to @var{fnc}
|
|
|
|
when the handler is invoked (the second argument should be @var{fd}).
|
|
|
|
If @var{dir} is 0, @var{fnc} should be called by the user when
|
|
|
|
@var{fd} is ready for writing. If @var{dir} is 1, @var{fnc} should be
|
|
|
|
called when @var{fd} is ready for reading.
|
|
|
|
|
|
|
|
@var{data} was provided by the user when registering the
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_register_io_cb_t} function with @acronym{GPGME} and will always
|
2002-07-03 02:22:38 +00:00
|
|
|
be passed as the first argument when registering a callback function.
|
|
|
|
For example, the user can use this to determine the event loop to
|
|
|
|
which the file descriptor should be added.
|
|
|
|
|
|
|
|
@acronym{GPGME} will call this function when a crypto operation is
|
|
|
|
initiated in a context for which the user has registered I/O callback
|
|
|
|
handler functions with @code{gpgme_set_io_cbs}. It can also call this
|
|
|
|
function when it is in an I/O callback handler for a file descriptor
|
|
|
|
associated to this context.
|
|
|
|
|
|
|
|
The user should return a unique handle in @var{tag} identifying this
|
|
|
|
I/O callback registration, which will be passed to the
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_register_io_cb_t} function without interpretation when the file
|
2002-07-03 02:22:38 +00:00
|
|
|
descriptor should not be monitored anymore.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {void (*gpgme_remove_io_cb_t) (@w{void *@var{tag}})}
|
|
|
|
The @code{gpgme_remove_io_cb_t} type is the type of functions which can be
|
2002-07-03 02:22:38 +00:00
|
|
|
called by @acronym{GPGME} to remove an I/O callback handler that was
|
|
|
|
registered before. @var{tag} is the handle that was returned by the
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_register_io_cb_t} for this I/O callback.
|
2002-07-03 02:22:38 +00:00
|
|
|
|
|
|
|
@acronym{GPGME} can call this function when a crypto operation is in
|
|
|
|
an I/O callback. It will also call this function when the context is
|
|
|
|
destroyed while an operation is pending.
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {enum gpgme_event_io_t}
|
|
|
|
@tindex gpgme_event_io_t
|
|
|
|
The @code{gpgme_event_io_t} type specifies the type of an event that is
|
2002-07-03 02:22:38 +00:00
|
|
|
reported to the user by @acronym{GPGME} as a consequence of an I/O
|
|
|
|
operation. The following events are defined:
|
|
|
|
|
|
|
|
@table @code
|
doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
@item GPGME_EVENT_START
|
|
|
|
The operation is fully initialized now, and you can start to run the
|
|
|
|
registered I/O callback handlers now. Note that registered I/O
|
|
|
|
callback handlers must not be run before this event is signalled.
|
|
|
|
@var{type_data} is @code{NULL} and reserved for later use.
|
|
|
|
|
2002-07-03 02:22:38 +00:00
|
|
|
@item GPGME_EVENT_DONE
|
|
|
|
The operation is finished, the last I/O callback for this operation
|
|
|
|
was removed. The accompanying @var{type_data} points to a
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_error_t} variable that contains the status of the operation
|
2002-07-03 02:22:38 +00:00
|
|
|
that finished. This event is signalled after the last I/O callback
|
|
|
|
has been removed.
|
|
|
|
|
|
|
|
@item GPGME_EVENT_NEXT_KEY
|
|
|
|
In a @code{gpgme_op_keylist_start} operation, the next key was
|
|
|
|
received from the crypto engine. The accompanying @var{type_data} is
|
2003-05-18 20:45:24 +00:00
|
|
|
a @code{gpgme_key_t} variable that contains the key with one reference
|
2002-07-03 02:22:38 +00:00
|
|
|
for the user.
|
|
|
|
|
|
|
|
@item GPGME_EVENT_NEXT_TRUSTITEM
|
|
|
|
In a @code{gpgme_op_trustlist_start} operation, the next trust item
|
|
|
|
was received from the crypto engine. The accompanying @var{type_data}
|
2003-05-18 20:45:24 +00:00
|
|
|
is a @code{gpgme_trust_item_t} variable that contains the trust item with
|
2002-07-03 02:22:38 +00:00
|
|
|
one reference for the user.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {void (*gpgme_event_io_cb_t) (@w{void *@var{data}}, @w{gpgme_event_io_t @var{type}}, @w{void *@var{type_data}})}
|
|
|
|
The @code{gpgme_event_io_cb_t} type is the type of functions which can be
|
2002-07-03 02:22:38 +00:00
|
|
|
called by @acronym{GPGME} to signal an event for an operation running
|
|
|
|
in a context which has I/O callback functions registered by the user.
|
|
|
|
|
|
|
|
@var{data} was provided by the user when registering the
|
2003-05-18 20:45:24 +00:00
|
|
|
@code{gpgme_event_io_cb_t} function with @acronym{GPGME} and will always be
|
2002-07-03 02:22:38 +00:00
|
|
|
passed as the first argument when registering a callback function.
|
|
|
|
For example, the user can use this to determine the context in which
|
|
|
|
this event has occured.
|
|
|
|
|
|
|
|
@var{type} will specify the type of event that has occured.
|
|
|
|
@var{type_data} specifies the event further, as described in the above
|
2003-05-18 20:45:24 +00:00
|
|
|
list of possible @code{gpgme_event_io_t} types.
|
2002-07-03 02:22:38 +00:00
|
|
|
|
|
|
|
@acronym{GPGME} can call this function in an I/O callback handler.
|
|
|
|
@end deftp
|
|
|
|
|
|
|
|
|
|
|
|
@node Registering I/O Callbacks
|
|
|
|
@subsubsection Registering I/O Callbacks
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftp {Data type} {struct gpgme_io_cb_ts}
|
|
|
|
@tindex gpgme_event_io_t
|
2002-07-03 02:22:38 +00:00
|
|
|
This structure is used to store the I/O callback interface functions
|
|
|
|
described in the previous section. It has the following members:
|
|
|
|
|
|
|
|
@table @code
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_register_io_cb_t add
|
2002-07-03 02:22:38 +00:00
|
|
|
This is the function called by @acronym{GPGME} to register an I/O
|
|
|
|
callback handler. It must be specified.
|
|
|
|
|
|
|
|
@item void *add_data
|
|
|
|
This is passed as the first argument to the @code{add} function when
|
|
|
|
it is called by @acronym{GPGME}. For example, it can be used to
|
|
|
|
determine the event loop to which the file descriptor should be added.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_remove_io_cb_t remove
|
2002-07-03 02:22:38 +00:00
|
|
|
This is the function called by @acronym{GPGME} to remove an I/O
|
|
|
|
callback handler. It must be specified.
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@item gpgme_event_io_cb_t event
|
2002-07-03 02:22:38 +00:00
|
|
|
This is the function called by @acronym{GPGME} to signal an event for
|
|
|
|
an operation. It is optional, but if you don't specify it, you can
|
|
|
|
not retrieve the return value of the operation.
|
|
|
|
|
|
|
|
@item void *event_data
|
|
|
|
This is passed as the first argument to the @code{event} function when
|
|
|
|
it is called by @acronym{GPGME}. For example, it can be used to
|
|
|
|
determine the context in which the event has occured.
|
|
|
|
@end table
|
|
|
|
@end deftp
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_set_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cb_ts *@var{io_cbs}})
|
2002-07-03 02:22:38 +00:00
|
|
|
The function @code{gpgme_set_io_cbs} enables the I/O callback
|
|
|
|
interface for the context @var{ctx}. The I/O callback functions are
|
|
|
|
specified by @var{io_cbs}.
|
|
|
|
|
|
|
|
If @var{io_cbs}->@code{add} is @code{NULL}, the I/O callback interface
|
|
|
|
is disabled for the context, and normal operation is restored.
|
|
|
|
@end deftypefun
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
@deftypefun void gpgme_get_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cb_ts *@var{io_cbs}})
|
2002-07-03 02:22:38 +00:00
|
|
|
The function @code{gpgme_get_io_cbs} returns the I/O callback
|
|
|
|
functions set with @code{gpgme_set_io_cbs} in @var{io_cbs}.
|
|
|
|
@end deftypefun
|
|
|
|
|
|
|
|
|
|
|
|
@node I/O Callback Example
|
|
|
|
@subsubsection I/O Callback Example
|
|
|
|
|
|
|
|
To actually use an external event loop, you have to implement the I/O
|
|
|
|
callback functions that are used by @acronym{GPGME} to register and
|
|
|
|
unregister file descriptors. Furthermore, you have to actually
|
|
|
|
monitor these file descriptors for activity and call the appropriate
|
|
|
|
I/O callbacks.
|
|
|
|
|
|
|
|
The following example illustrates how to do that. The example uses
|
|
|
|
locking to show in which way the the callbacks and the event loop can
|
|
|
|
run concurrently. For the event loop, we use a fixed array. For a
|
|
|
|
real-world implementation, you should use a dynamically sized
|
|
|
|
structure because the number of file descriptors needed for a crypto
|
|
|
|
operation in @acronym{GPGME} is not predictable.
|
|
|
|
|
|
|
|
@example
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <gpgme.h>
|
|
|
|
|
|
|
|
/* The following structure holds the result of a crypto operation. */
|
|
|
|
struct op_result
|
|
|
|
@{
|
|
|
|
int done;
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_error_t err;
|
2002-07-03 02:22:38 +00:00
|
|
|
@};
|
|
|
|
|
|
|
|
/* The following structure holds the data associated with one I/O
|
|
|
|
callback. */
|
|
|
|
struct one_fd
|
|
|
|
@{
|
|
|
|
int fd;
|
|
|
|
int dir;
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_io_cb_t fnc;
|
2002-07-03 02:22:38 +00:00
|
|
|
void *fnc_data;
|
|
|
|
@};
|
|
|
|
|
|
|
|
struct event_loop
|
|
|
|
@{
|
|
|
|
pthread_mutex_t lock;
|
|
|
|
#define MAX_FDS 32
|
|
|
|
/* Unused slots are marked with FD being -1. */
|
|
|
|
struct one_fd fds[MAX_FDS];
|
|
|
|
@};
|
|
|
|
@end example
|
|
|
|
|
|
|
|
The following functions implement the I/O callback interface.
|
|
|
|
|
|
|
|
@example
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_error_t
|
|
|
|
add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data,
|
2002-07-03 02:22:38 +00:00
|
|
|
void **r_tag)
|
|
|
|
@{
|
|
|
|
struct event_loop *loop = data;
|
|
|
|
struct one_fd *fds = loop->fds;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
pthread_mutex_lock (&loop->lock);
|
|
|
|
for (i = 0; i < MAX_FDS; i++)
|
|
|
|
@{
|
|
|
|
if (fds[i].fd == -1)
|
|
|
|
@{
|
|
|
|
fds[i].fd = fd;
|
|
|
|
fds[i].dir = dir;
|
|
|
|
fds[i].fnc = fnc;
|
|
|
|
fds[i].fnc_data = fnc_data;
|
|
|
|
break;
|
|
|
|
@}
|
|
|
|
@}
|
|
|
|
pthread_mutex_unlock (&loop->lock);
|
|
|
|
if (i == MAX_FDS)
|
|
|
|
return GPGME_General_Error;
|
|
|
|
*r_tag = &fds[i];
|
|
|
|
return 0;
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
|
|
|
remove_io_cb (void *tag)
|
|
|
|
@{
|
|
|
|
struct one_fd *fd = tag;
|
|
|
|
|
|
|
|
pthread_mutex_lock (&loop->lock);
|
|
|
|
fd->fd = -1;
|
|
|
|
pthread_mutex_unlock (&loop->lock);
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
event_io_cb (void *data, gpgme_event_io_t type, void *type_data)
|
2002-07-03 02:22:38 +00:00
|
|
|
@{
|
|
|
|
struct op_result *result = data;
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_error_t *err = data;
|
2002-07-03 02:22:38 +00:00
|
|
|
|
|
|
|
/* We don't support list operations here. */
|
|
|
|
if (type == GPGME_EVENT_DONE)
|
|
|
|
@{
|
|
|
|
result->done = 1;
|
|
|
|
result->err = *data;
|
|
|
|
@}
|
|
|
|
@}
|
|
|
|
@end example
|
|
|
|
|
|
|
|
The final missing piece is the event loop, which will be presented
|
|
|
|
next. We only support waiting for the success of a single operation.
|
|
|
|
|
|
|
|
@example
|
|
|
|
int
|
|
|
|
do_select (struct event_loop *loop)
|
|
|
|
@{
|
|
|
|
fd_set rfds;
|
|
|
|
fd_set wfds;
|
|
|
|
int i, n;
|
|
|
|
int any = 0;
|
|
|
|
|
|
|
|
pthread_mutex_lock (&loop->lock);
|
|
|
|
FD_ZERO (&rfds);
|
|
|
|
FD_ZERO (&wfds);
|
|
|
|
for (i = 0; i < FDLIST_MAX; i++)
|
|
|
|
if (fdlist[i].fd != -1)
|
|
|
|
FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds);
|
|
|
|
pthread_mutex_unlock (&loop->unlock);
|
|
|
|
|
|
|
|
do
|
|
|
|
@{
|
|
|
|
n = select (FD_SETSIZE, &rfds, &wfds, NULL, 0);
|
|
|
|
@}
|
|
|
|
while (n < 0 && errno == EINTR);
|
|
|
|
|
|
|
|
if (n < 0)
|
|
|
|
return n; /* Error or timeout. */
|
|
|
|
|
|
|
|
pthread_mutex_lock (&loop->lock);
|
|
|
|
for (i = 0; i < FDLIST_MAX && n; i++)
|
|
|
|
@{
|
|
|
|
if (fdlist[i].fd != -1)
|
|
|
|
@{
|
|
|
|
if (FD_ISSET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds))
|
|
|
|
@{
|
|
|
|
assert (n);
|
|
|
|
n--;
|
|
|
|
any = 1;
|
|
|
|
/* The I/O callback handler can register/remove callbacks,
|
|
|
|
so we have to unlock the file descriptor list. */
|
|
|
|
pthread_mutex_unlock (&loop->lock);
|
|
|
|
(*fdlist[i].fnc) (fdlist[i].fnc_data, fdlist[i].fd);
|
|
|
|
pthread_mutex_lock (&loop->lock);
|
|
|
|
@}
|
|
|
|
@}
|
|
|
|
@}
|
|
|
|
pthread_mutex_unlock (&loop->lock);
|
|
|
|
return any;
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
|
|
|
wait_for_op (struct event_loop *loop, struct op_result *result)
|
|
|
|
@{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
do
|
|
|
|
@{
|
|
|
|
ret = do_select (loop);
|
|
|
|
@}
|
|
|
|
while (ret >= 0 && !result->done);
|
|
|
|
return ret;
|
|
|
|
@}
|
|
|
|
@end example
|
|
|
|
|
|
|
|
The main function shows how to put it all together.
|
|
|
|
|
|
|
|
@example
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
@{
|
|
|
|
struct event_loop loop;
|
|
|
|
struct op_result result;
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_ctx_t ctx;
|
|
|
|
gpgme_error_t err;
|
|
|
|
gpgme_data_t sig, text;
|
|
|
|
gpgme_sig_stat_t status;
|
2002-07-03 02:22:38 +00:00
|
|
|
int i;
|
2003-05-18 20:45:24 +00:00
|
|
|
struct gpgme_io_cb_ts io_cbs =
|
2002-07-03 02:22:38 +00:00
|
|
|
@{
|
|
|
|
add_io_cb,
|
|
|
|
&loop,
|
|
|
|
remove_io_cb,
|
|
|
|
event_io_cb,
|
|
|
|
&result
|
|
|
|
@};
|
|
|
|
|
|
|
|
/* Initialize the loop structure. */
|
|
|
|
loop.lock = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
for (i = 0; i < MAX_FDS; i++)
|
|
|
|
loop->fds[i].fd = -1;
|
|
|
|
|
|
|
|
/* Initialize the result structure. */
|
|
|
|
result.done = 0;
|
|
|
|
|
|
|
|
err = gpgme_data_new_from_file (&sig, "signature", 1);
|
|
|
|
if (!err)
|
|
|
|
err = gpgme_data_new_from_file (&text, "text", 1);
|
|
|
|
if (!err)
|
|
|
|
err = gpgme_new (&ctx);
|
|
|
|
if (!err)
|
|
|
|
@{
|
|
|
|
gpgme_set_io_cbs (ctx, &io_cbs);
|
|
|
|
err = gpgme_op_verify_start (ctx, sig, text, &status);
|
|
|
|
@}
|
|
|
|
if (err)
|
|
|
|
@{
|
|
|
|
fprintf (stderr, "gpgme error: %s\n", gpgme_strerror (err));
|
|
|
|
exit (1);
|
|
|
|
@}
|
|
|
|
|
|
|
|
wait_for_op (&loop, &result);
|
|
|
|
if (!result.done)
|
|
|
|
@{
|
|
|
|
fprintf (stderr, "select error\n");
|
|
|
|
exit (1);
|
|
|
|
@}
|
|
|
|
if (!result.err)
|
|
|
|
@{
|
|
|
|
fprintf (stderr, "verification failed: %s\n", gpgme_strerror (result.err));
|
|
|
|
exit (1);
|
|
|
|
@}
|
|
|
|
/* Evaluate STATUS. */
|
|
|
|
@dots{}
|
|
|
|
return 0;
|
|
|
|
@}
|
|
|
|
@end example
|
|
|
|
|
|
|
|
|
|
|
|
@node I/O Callback Example GTK+
|
|
|
|
@subsubsection I/O Callback Example GTK+
|
|
|
|
@cindex GTK+, using @acronym{GPGME} with
|
|
|
|
|
|
|
|
The I/O callback interface can be used to integrate @acronym{GPGME}
|
|
|
|
with the GTK+ event loop. The following code snippets shows how this
|
|
|
|
can be done using the appropriate register and remove I/O callback
|
|
|
|
functions. In this example, the private data of the register I/O
|
|
|
|
callback function is unused. The event notifications is missing
|
|
|
|
because it does not require any GTK+ specific setup.
|
|
|
|
|
|
|
|
@example
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
struct my_gpgme_io_cb
|
|
|
|
@{
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_io_cb_t fnc;
|
2002-07-03 02:22:38 +00:00
|
|
|
void *fnc_data;
|
|
|
|
guint input_handler_id
|
|
|
|
@};
|
|
|
|
|
|
|
|
void
|
|
|
|
my_gpgme_io_cb (gpointer data, gint source, GdkInputCondition condition)
|
|
|
|
@{
|
|
|
|
struct my_gpgme_io_cb *iocb = data;
|
|
|
|
(*(iocb->fnc)) (iocb->data, source);
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
|
|
|
my_gpgme_remove_io_cb (void *data)
|
|
|
|
@{
|
|
|
|
struct my_gpgme_io_cb *iocb = data;
|
|
|
|
gtk_input_remove (data->input_handler_id);
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
my_gpgme_register_io_callback (void *data, int fd, int dir, gpgme_io_cb_t fnc,
|
2002-07-03 02:22:38 +00:00
|
|
|
void *fnc_data, void **tag)
|
|
|
|
@{
|
|
|
|
struct my_gpgme_io_cb *iocb = g_malloc (sizeof (struct my_gpgme_io_cb));
|
|
|
|
iocb->fnc = fnc;
|
|
|
|
iocb->data = fnc_data;
|
|
|
|
iocb->input_handler_id = gtk_input_add_full (fd, dir
|
|
|
|
? GDK_INPUT_READ
|
|
|
|
: GDK_INPUT_WRITE,
|
|
|
|
my_gpgme_io_callback,
|
|
|
|
0, iocb, NULL);
|
|
|
|
*tag = iocb;
|
|
|
|
return 0;
|
|
|
|
@}
|
|
|
|
@end example
|
|
|
|
|
|
|
|
|
|
|
|
@node I/O Callback Example GDK
|
|
|
|
@subsubsection I/O Callback Example GDK
|
|
|
|
@cindex GDK, using @acronym{GPGME} with
|
|
|
|
|
|
|
|
The I/O callback interface can also be used to integrate
|
|
|
|
@acronym{GPGME} with the GDK event loop. The following code snippets
|
|
|
|
shows how this can be done using the appropriate register and remove
|
|
|
|
I/O callback functions. In this example, the private data of the
|
|
|
|
register I/O callback function is unused. The event notifications is
|
|
|
|
missing because it does not require any GDK specific setup.
|
|
|
|
|
|
|
|
It is very similar to the GTK+ example in the previous section.
|
|
|
|
|
|
|
|
@example
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
|
|
|
|
struct my_gpgme_io_cb
|
|
|
|
@{
|
2003-05-18 20:45:24 +00:00
|
|
|
gpgme_io_cb_t fnc;
|
2002-07-03 02:22:38 +00:00
|
|
|
void *fnc_data;
|
|
|
|
gint tag;
|
|
|
|
@};
|
|
|
|
|
|
|
|
void
|
|
|
|
my_gpgme_io_cb (gpointer data, gint source, GdkInputCondition condition)
|
|
|
|
@{
|
|
|
|
struct my_gpgme_io_cb *iocb = data;
|
|
|
|
(*(iocb->fnc)) (iocb->data, source);
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
|
|
|
my_gpgme_remove_io_cb (void *data)
|
|
|
|
@{
|
|
|
|
struct my_gpgme_io_cb *iocb = data;
|
|
|
|
gdk_input_remove (data->tag);
|
|
|
|
@}
|
|
|
|
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
my_gpgme_register_io_callback (void *data, int fd, int dir, gpgme_io_cb_t fnc,
|
2002-07-03 02:22:38 +00:00
|
|
|
void *fnc_data, void **tag)
|
|
|
|
@{
|
|
|
|
struct my_gpgme_io_cb *iocb = g_malloc (sizeof (struct my_gpgme_io_cb));
|
|
|
|
iocb->fnc = fnc;
|
|
|
|
iocb->data = fnc_data;
|
|
|
|
iocb->tag = gtk_input_add_full (fd, dir ? GDK_INPUT_READ : GDK_INPUT_WRITE,
|
|
|
|
my_gpgme_io_callback, iocb, NULL);
|
|
|
|
*tag = iocb;
|
|
|
|
return 0;
|
|
|
|
@}
|
|
|
|
@end example
|
|
|
|
|
|
|
|
|
2002-01-16 00:41:10 +00:00
|
|
|
@include gpl.texi
|
|
|
|
|
|
|
|
|
|
|
|
@include fdl.texi
|
|
|
|
|
|
|
|
|
|
|
|
@node Concept Index
|
|
|
|
@unnumbered Concept Index
|
|
|
|
|
|
|
|
@printindex cp
|
|
|
|
|
|
|
|
|
|
|
|
@node Function and Data Index
|
|
|
|
@unnumbered Function and Data Index
|
|
|
|
|
|
|
|
@printindex fn
|
|
|
|
|
|
|
|
|
|
|
|
@summarycontents
|
|
|
|
@contents
|
|
|
|
@bye
|