diff --git a/doc/ChangeLog b/doc/ChangeLog index f711a126..7328f381 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,777 +1,781 @@ +2007-09-11 Werner Koch + + * gpgme.texi (I/O Callback Example): Typo fix. + 2007-08-07 Werner Koch * gpgme.texi (Verify): Describe chain_model. 2007-07-12 Werner Koch * gpgme.texi (Library Version Check): Add remark that the socket layer will get initialized. 2007-06-05 Marcus Brinkmann * gpgme.texi (Advanced Key Editing): New section. 2007-05-21 Werner Koch * Makefile.am (online): New target. 2007-05-18 Marcus Brinkmann * gpgme.texi (Error Strings): Fix documentation of gpgme_strerror_r. 2006-11-01 Moritz Schulte * gpgme.texi (Data Buffer I/O Operations): Fixed entry for gpgme_data_seek: OFFSET is not a pointer; some s/whence/offset/. 2006-09-25 Marcus Brinkmann * gpgme.texi (Destroying Data Buffers): Clarify that gpgme_data_release_and_get_mem destroys DH unconditionally. 2005-03-24 Marcus Brinkmann * gpgme.texi (Library Version Check): Make example code compatible to W32 systems. 2006-06-21 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Fix inverted condition in description. 2005-12-20 Werner Koch * gpgme.texi (Verify): Document pka_trust. 2005-12-06 Werner Koch * gpgme.texi (Key Management): Updated to match the fixes for subkey fingerprints and theg secret flag. 2005-10-06 Marcus Brinkmann * gpgme.texi (Destroying Data Buffers): Document gpgme_free. 2005-10-02 Marcus Brinkmann * gpgme.texi (Key Management): Add the new member notations of gpgme_sig_key_t. (Key Listing Mode): Document GPGME_KEYLIST_MODE_SIG_NOTATIONS. 2005-10-01 Marcus Brinkmann * gpgme.texi: Enclose all return parameters of deftypefuns in curly brackets. * gpgme.texi (Signature Notation Data): New section. (Verify): Added more about the notation data structure. 2005-09-30 Marcus Brinkmann * gpgme.texi (Data Buffer I/O Operations, Data Buffer Meta-Data): New subsections. * gpgme.texi: Replace plaintext_filename with file_name. * gpgme.texi (Key Management): Document is_qualified. 2005-07-27 Marcus Brinkmann * gpgme.texi (Decrypt): Add plaintext_filename to gpgme_decrypt_result_t. (Verify): Likewise for gpgme_verify_result_t. 2005-06-03 Marcus Brinkmann * gpgme.texi (Verify): Add information about new fields in gpgme_signature_t. * gpgme.texi (Decrypt): Add gpgme_recipient_t. 2005-05-28 Marcus Brinkmann * gpgme.texi (Key Listing Mode): Fix return type of gpgme_set_keylist_mode. Reported by "Sergio" . 2005-04-28 Marcus Brinkmann * gpgme.texi (Included Certificates): Document GPGME_INCLUDE_CERTS_DEFAULT. 2005-01-12 Marcus Brinkmann * gpgme.texi (Engine Configuration): New section. (Crypto Engine): New subsection. 2004-12-07 Marcus Brinkmann * lesser.texi (Library Copying): Change from @appendixsec to @appendix. * gpgme.texi (Features): Change reference to GPL to one to LGPL. * Makefile.am: Change license to LGPL. (gpgme_TEXINFOS): Replace gpl.texi with lesser.texi. * gpgme.texi: Change license to LGPL (also for documentation of GPGME's license). * lesser.texi: New file. * gpl.texi: File removed. * gpgme.texi (Creating Contexts): Fix cut&paste error. Reported by Noel Torres . 2004-09-30 Marcus Brinkmann * Makefile.am (gpgme_TEXINFOS): Remove fdl.texi. * gpgme.texi: Do not include fdl.texi. Change license to GPL. * fdl.texi: File removed. 2004-09-29 Marcus Brinkmann * gpgme.texi (Key Management): Change type of keylist_mode in gpgme_key_t to gpgme_keylist_mode_t. 2004-09-28 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Fix last change. 2004-09-27 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Document GPG_ERR_NOT_IMPLEMENTED. * gpgme.texi: Update copyright year for tex version. 2004-07-29 Moritz Schulte * gpgme.texi (Verify): Fix gpgme_get_key example (ancient force_update argument was still there). 2004-06-08 Marcus Brinkmann * gpgme.texi (Listing Keys): Elaborate on the length restrictions on search patterns. * gpgme.texi (Decrypt and Verify): Document the NO_DATA error code. (Verify): Document the relationship between gpgme_op_verify_result and the decrypt and verify operations. 2004-05-21 Marcus Brinkmann * gpgme.text (Verify): Document GPG_ERR_CERT_REVOKED status. * gpgme.texi (Decrypt): Add note about new field wrong_key_usage of gpgme_decrypt_result_t. * gpgme.texi (Key Management): Add note about new field keylist_mode of gpgme_key_t. 2004-04-29 Marcus Brinkmann * gpgme.texi (Verify): Correct type of member wrong_key_usage. 2004-03-29 Moritz Schulte * gpgme.texi (Verify): Fix type of gpgme_op_verify_result. * gpgme.texi (Key Listing Mode): Typo fix. 2004-03-23 Marcus Brinkmann * gpgme.texi (Library Version Check): Fix the instruction when to set the locale. 2004-03-03 Marcus Brinkmann * gpgme.texi (I/O Callback Example Qt): New section by Marc Mutz. 2004-02-24 Marcus Brinkmann * gpgme.texi (cancellation): New section. 2004-02-17 Werner Koch * gpgme.texi (Key Listing Mode): Doc KEYLIST_MODE_VALIDATE. 2004-02-06 Moritz Schulte * gpgme.texi: A couple of small fixes regarding the Largfile Support section. 2004-02-01 Marcus Brinkmann * gpgme.texi (Largefile Support): New section. 2004-01-13 Marcus Brinkmann * gpgme.texi (Key Management): Fix exportable field. 2003-12-25 Marcus Brinkmann * gpgme.texi (Key Management): Rename member class in gpgme_key_sig_t to sig_class. (Creating a Signature): Likewise for gpgme_signature_t. 2003-12-23 Moritz Schulte * gpgme.texi (Listing Keys): Minor clarification for gpgme_get_key. 2003-10-06 Marcus Brinkmann * gpgme.texi (Signal Handling): New section. 2003-09-14 Marcus Brinkmann * gpgme.texi (Multi Threading): Correct documentation on memory synchronization requirement. * gpgme.texi (Locale): New section. (Multi Threading): Set locale in example. 2003-09-13 Marcus Brinkmann * gpgme.texi (Error Strings): Add gpgme_strerror_r. 2003-09-13 Marcus Brinkmann * gpgme.texi (Multi Threading): Update documentation. 2003-09-03 Marcus Brinkmann * gpgme.texi (Header): We don't use the assuan namespace anymore. Document new thread options. 2003-08-14 Marcus Brinkmann * gpgme.texi (Creating a Signature): Change type of member class to unsigned int. 2003-08-04 Marcus Brinkmann * gpgme.texi (Verify): Get error code from SIG->status in the code for gpgme_get_sig_status. 2003-07-31 Marcus Brinkmann * gpgme.texi (Key Management): Add can_authenticate flag. * gpgme.texi (Listing Keys): Document GPG_ERR_AMBIGUOUS_NAME for gpgme_get_key. 2003-07-29 Marcus Brinkmann * Makefile.am (EXTRA_DIST): Remove variable. * gpgme.texi (Encrypting a Plaintext): Bad passphrase is only possible with symmetric encryption, change the wording to reflect that. * gpgme.texi (Creating a Signature): Document GPG_ERR_UNUSABLE_SECKEY. * gpgme.texi (Encrypting a Plaintext): Mention encrypt and sign operations in result function. (Creating a Signature): Likewise. 2003-07-23 Marcus Brinkmann * gpgme.texi (Key Listing Mode): Remove word duplication. (Listing Keys): Remove mentioning of force argument. (Verify): Don't mention r_stat. Fix some typos. (Decrypt and Verify): Correct info how to get the result. Don't mention r_stat. (Manipulating Data Buffers): Fix documentation of return value. (Listing Keys): Update examples. (Decrypt): Result might also be available when operation failed. (Verify): Result might also be available when operation failed. All spotted by Stéphane Corthésy. 2003-07-22 Marcus Brinkmann * gpgme.texi (Error Sources): Fix cut and paste error. 2003-07-09 Marcus Brinkmann * gpgme.texi (Key Management): Clarify difference between can_sign and can_certify. (Information About Keys): Likewise for GPGME_ATTR_CAN_SIGN and GPGME_ATTR_CAN_CERTIFY. 2003-07-08 Marcus Brinkmann * gpgme.texi (Progress Meter Callback): Change return type of gpgme_progress_cb_t to void. 2003-06-22 Marcus Brinkmann * gpgme.texi: Add 2003 to copyright notice. * gpgme.texi (Header): Fix name space documentation on libgpg-error. 2003-06-22 Marcus Brinkmann * gpgme.texi (Multi Threading): Remove reference to gpgme_recipients_t. 2003-06-06 Marcus Brinkmann * gpgme.texi (Crypto Operations): Rename gpgme_invalid_user_id_t to gpgme_invalid_key_t. 2003-06-06 Marcus Brinkmann * gpgme.texi: Change error codes to GPG_ERR_* variants. (Error Handling): Rewritten. 2003-05-29 Marcus Brinkmann * gpgme.texi (Exporting Keys): Change and document prototypes. Add new gpgme_op_export_ext and gpgme_op_export_ext_start variants. (Selecting Recipients): Section removed. (Encrypting a Plaintext): Change prototypes and document the changes. 2003-05-28 Marcus Brinkmann * gpgme.texi (Exporting Keys): Change argument type from gpgme_recipient_t to gpgme_user_id_t. (Encrypting a Plaintext): Likewise. (Selecting Recipients): Rewritten. 2003-05-27 Marcus Brinkmann * gpgme.texi (Protocol Selection): Do not use @acronym in @node because that breaks texi2dvi. * gpgme.texi (Passphrase Callback): Document new prototype. 2003-05-18 Marcus Brinkmann * gpgme.texi (Header): Remove Gpgme as namespace prefix. Add _GPGME to namespace prefix. * gpgme.texi (Multi Threading): Add note about link order. 2003-05-04 Marcus Brinkmann * gpgme.texi (Listing Keys): Document what happens if key is not found. * gpgme.texi (Importing Keys): Fix cut and paste error. 2003-04-30 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Remove reference to gpgme_get_op_info. (Detailed Results): Subsection removed. * gpgme.texi (Key Listing Mode): Add GPGME_KEYLIST_MODE_SIGS. (Manipulating Keys): Add obsoleteness note. (Key Signatures): Likewise. (Information About Keys): Likewise. (Key Management): Add new data types GpgmeSubkey, GpgmeKeySig, GpgmeUserID, and all the information about GpgmeKey. 2003-04-29 Marcus Brinkmann * gpgme.texi (Listing Keys): Remove force_update argument from gpgme_get_key. * gpgme.texi (Trust Item Management): Add data members of GpgmeTrustItem type. (Information About Trust Items): Add note about obsoleteness. (Manipulating Trust Items): Add gpgme_trust_item_ref and gpgme_trust_item_unref. 2003-04-28 Marcus Brinkmann * gpgme.texi (Verify): Rewritten to take into account new and deprecated functions and data types. * gpgme.texi (Decrypt): Descript gpgme_op_decrypt_result and GpgmeDecryptResult. 2003-04-27 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Add info about GpgmeEncryptResult and gpgme_op_encrypt_result. * gpgme.texi (Creating a Signature): Add info about GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result. (Crypto Operations): Add GpgmeInvalidUserID. (Algorithms): New chapter. * 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. 2003-04-25 Marcus Brinkmann * gpgme.texi (Importing Keys): Change GPGME_IMPORT_PRIVATE to GPGME_IMPORT_SECRET. * gpgme.texi (Importing Keys): Remove note about gpgme_get_op_info. (Detailed Results): Remove note about import. * gpgme.texi (Importing Keys): Add documentation for GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result. * gpgme.texi (Generating Keys): Fix documentation of public and secret arguments. 2003-04-24 Marcus Brinkmann * gpgme.texi (Generating Keys): Document changed gpgme_op_genkey and new gpgme_op_genkey_result function. Document GpgmeGenKeyResult data type. * gpgme.texi (Error Values): Rename GPGME_No_Passphrase to GPGME_Bad_Passphrase. * gpgme.texi (Decrypt): Likewise. (Decrypt and Verify): Likewise. (Creating a Signature): Likewise. (Encrypting a Plaintext): Likewise. * gpgme.texi (Error Values): Rename GPGME_No_Recipients to GPGME_No_UserID and GPGME_Invalid_Recipient to GPGME_Invalid_UserID. (Encrypting a Plaintext): Likewise. * gpgme.texi (Error Values): Remove GPGME_Busy and GPGME_No_Request. (Listing Keys): Likewise. (Listing Trust Items): Likewise. 2003-02-06 Marcus Brinkmann * gpgme.texi (Cancelling an Operation): Removed. (Passphrase Callback): Document new type for GpgmePassphraseCb. 2003-01-30 Marcus Brinkmann * gpgme.texi (Engine Information): Rename member part to file_name. * gpgme.texi (Protocols and Engines): Document gpgme_get_protocol_name. * gpgme.texi (Engine Information): Rewritten. 2003-01-29 Marcus Brinkmann * 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. 2003-01-29 Marcus Brinkmann * gpgme.texi (Hooking Up Into Idle Time): Section removed. 2002-12-24 Marcus Brinkmann * gpgme.texi (Verify): Drop R_STAT argument in gpgme_op_verify. * gpgme.texi (Decrypt and Verify): Likewise for gpgme_op_decrypt_verify. 2002-12-23 Marcus Brinkmann * gpgme.texi (Information About Keys): Document that GPGME_ATTR_IS_SECRET is not representable as a string anymore. 2002-12-22 Marcus Brinkmann * gpgme.texi (Key Signatures): New section. (Listing Keys): Add gpgme_get_key. 2002-12-06 Marcus Brinkmann * gpgme.texi (Memory Based Data Buffers): New subsection. (File Based Data Buffers): Likewise. (Callback Based Data Buffers): Likewise. (Manipulating Data Buffers): Update interfaces. Add gpgme_data_seek. * gpgme.texi (Engine Version Check): Remove gpgme_check_engine. 2002-11-21 Marcus Brinkmann * gpgme.texi (Verify): Document the new interface. 2002-11-19 Marcus Brinkmann * gpgme.texi (Generating Keys): Document new argument to gpgme_op_genkey. 2002-11-05 Marcus Brinkmann * gpgme.texi (Verify): Fix prototype of gpgme_get_sig_key. Reported by Miguel Coca . 2002-08-30 Marcus Brinkmann * gpgme.texi (Selecting Signers): Fix reference count. 2002-08-21 Marcus Brinkmann * gpgme.texi (Header): Document name space. 2002-08-20 Marcus Brinkmann * gpgme.texi (Importing Keys): Document gpgme_op_import_ext. * gpgme.texi (Importing Keys): Undocument EOF. 2002-08-14 Werner Koch * gpgme.texi (Information About Keys): Changed GPGME_ATTR_TYPE. 2002-07-25 Marcus Brinkmann * gpgme.texi (Deleting Keys): Say that secret keys might not be deleted. 2002-07-25 Marcus Brinkmann * gpgme.texi (Information About Keys): Document (badly) the new key attributes. * gpgme.texi (Manipulating Data Buffers): Mention that backend tries to detect encoding automatically. 2002-07-03 Marcus Brinkmann * gpgme.texi (Run Control): Update this section. (Waiting For Completion): Likewise for this subsection. (Cancelling an Operation): Likewise for this subsection. (Using External Event Loops): New subsection with several subsubsections. 2002-06-28 Marcus Brinkmann * gpgme.texi (Multi Threading): Remove item about the need to synchronize anything against gpgme_wait (except gpgme_wait itself). 2002-06-27 Marcus Brinkmann * gpgme.texi (Information About Keys): Fix documentation for IDX. (Information About Trust Items): Likewise. 2002-06-26 Werner Koch * gpgme.texi (Importing Keys): Document the return value -1 of gpgme_op_import. 2002-06-20 Werner Koch * gpgme.texi (Verify): Explain the new whatidx variable. 2002-06-10 Werner Koch * gpgme.texi (Verify): Document attribute GPGME_ATTR_ERRTOK. 2002-06-04 Marcus Brinkmann * gpgme.texi (Multi Threading): Document new autodetection. 2002-06-04 Marcus Brinkmann * Makefile.am (DISTCLEANFILES): New variable. 2002-05-26 Marcus Brinkmann * gpgme.texi: Some typographical correctons throughout. 2002-05-09 Marcus Brinkmann * gpgme.texi (Using Automake): New section. 2002-05-09 Marcus Brinkmann * gpgme.texi (Multi Threading): Escape { and }. 2002-05-09 Marcus Brinkmann * gpgme.texi (Overview): Replace note about thread-safeness. (Multi Threading): New section. 2002-05-03 Werner Koch * gpgme.texi (Manipulating Data Buffers): Changed some data types to void*. (Protocol Selection): Added gpgme_get_protocol. (Verify): Updated to include the new attribute fucntions and status codes. 2002-04-27 Werner Koch * gpgme.texi (Manipulating Data Buffers): New type GpgmeDataEncoding. 2002-04-23 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Document that either return argument can be NULL. (Progress Meter Callback): Likewise. 2002-04-22 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Fix small typo. Document the new function gpgme_get_passphrase_cb. (Progress Meter Callback): Document the new function gpgme_get_progress_cb. 2002-04-16 Marcus Brinkmann * gpgme.texi (Creating a Signature): Fix function name. Reported by Wichert Ackerman . 2002-03-29 Marcus Brinkmann * gpgme.texi (direntry): End index entry with a full stop. Patch submitted by Jose Carlos Garcia Sogo . 2002-03-17 Marcus Brinkmann * gpgme.texi (Detailed Results): Fix syntax error in last change. 2002-03-08 Werner Koch * gpgme.texi (Detailed Results): Import does also return info. 2002-03-06 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document symmetric encryption. 2002-03-06 Marcus Brinkmann * gpgme.texi (Error Strings): Add example. * gpgme.texi (Listing Keys): Likewise. 2002-03-03 Marcus Brinkmann * gpgme.texi (Information About Keys): Document GPGME_ATTR_EXPIRE. 2002-03-03 Marcus Brinkmann * gpgme.texi (Verify): Document verification of normal and cleartext signatures. 2002-02-27 Marcus Brinkmann * gpgme.texi (Listing Keys): Document gpgme_op_keylist_ext_start. 2002-02-27 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document GPGME_Invalid_Recipients. (Error Values): Likewise. 2002-02-26 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document gpgme_op_encrypt_sign and gpgme_op_encrypt_sign_start. 2002-02-25 Marcus Brinkmann * gpgme.texi (Creating a Signature): Add a note about certificates to include. (Included Certificates): New section. 2002-02-09 Marcus Brinkmann * gpgme.texi (Detailed Results): Remove literal tags. (Generating Keys): Update documentation. * gpgme.texi (Generating Keys): Fix syntax error. 2002-02-06 Marcus Brinkmann * gpgme.texi (Waiting For Completion): Adjust doc to changes in the code. 2002-02-06 Marcus Brinkmann * gpgme.texi (Key Listing Mode): Update documentation. 2002-01-31 Marcus Brinkmann * gpgme.texi (Generating Keys): Document error at creation failure. 2002-01-30 Marcus Brinkmann * gpgme.texi (Deleting Keys): Document new error values. 2002-01-30 Marcus Brinkmann * gpgme.texi (Importing Keys): Add reference to gpgme_get_op_info. 2002-01-30 Marcus Brinkmann * gpgme.texi: Some spell checking. 2002-01-30 Marcus Brinkmann * gpgme.texi: Add all the gpgme_op_*_start functions. Fill the concept index with many, many entries. 2002-01-29 Marcus Brinkmann * gpgme.texi (Run Control): New section. (Verify): Docuent gpgme_get_notation. (More Information): New section describing gpgme_get_op_info. 2002-01-22 Marcus Brinkmann * gpgme.texi (Passphrase callback): Change GpgmePassphraseCb's R_HD type from void* to void**. 2002-01-22 Marcus Brinkmann * gpgme.texi (Creating data buffers): Change gpgme_data_new_from_filepart's LENGTH type from off_t to size_t. 2002-01-22 Marcus Brinkmann * gpgme.texi (Generating keys): New subsection. (Exporting keys): Likewise. (Importing keys): Likewise. (Deleting keys): Likewise. 2002-01-16 Marcus Brinkmann * gpgme.texi: g10Code -> g10 Code * gpgme.texi (Top): Complete detailmenu. * gpgme.texi: Convert embarassing cruft to the real thing. 2002-01-16 Marcus Brinkmann * ChangeLog: New file. * gpgme.texi: Likewise. * gpl.texi: Likewise. * fdl.texi: Likewise. * Makefile.am (info_TEXINFOS): New variable. (gpgme_TEXINFOS): Likewise. Copyright 2002, 2003, 2004 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index f480715e..4692d263 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -1,5483 +1,5483 @@ ()\input texinfo @c -*- Texinfo -*- @setfilename gpgme.info @settitle The `GnuPG Made Easy' Reference Manual @dircategory GNU Libraries @direntry * @acronym{GPGME}: (gpgme). Adding support for cryptography to your program. @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}. @c NOTE: Don't forget to update the year for the TeX version, too. Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH. The GPGME reference manual is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GPGME reference manual is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @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 Copyright @copyright{} 2002, 2003, 2004, 2005, 2006, 2007 g10 Code GmbH. The GPGME reference manual is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GPGME reference manual is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA @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 @value{VERSION} of the @acronym{GPGME} library. @end ifnottex @menu * Introduction:: How to use this manual. * Preparation:: What you should do before using the library. * Protocols and Engines:: Supported crypto protocols. * Algorithms:: Supported algorithms. * Error Handling:: Error numbers and their meanings. * Exchanging Data:: Passing data to and from @acronym{GPGME}. * Contexts:: Handling @acronym{GPGME} contexts. Appendices * Library Copying:: The GNU Lesser General Public License says how you can copy and share `GnuPG Made Easy'. 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. Preparation * Header:: What header file you need to include. * Building the Source:: Compiler options to be used. * Largefile Support (LFS):: How to use @acronym{GPGME} with LFS. * Using Automake:: Compiler options to be used the easy way. * Using Libtool:: Avoiding compiler options entirely. * Library Version Check:: Getting and verifying the library version. * Signal Handling:: How @acronym{GPGME} affects signal handling. * Multi Threading:: How @acronym{GPGME} can be used in an MT environment. Protocols and Engines * Engine Version Check:: Verifying the engine version. * Engine Information:: Obtaining more information about the engines. * Engine Configuration:: Changing the engine configuration. * OpenPGP:: Support for the OpenPGP protocol. * Cryptographic Message Syntax:: Support for the CMS. Algorithms * Public Key Algorithms:: A list of all public key algorithms. * Hash Algorithms:: A list of all hash algorithms. Error Handling * Error Values:: The error value and what it means. * Error Codes:: A list of important error codes. * Error Sources:: A list of important error sources. * Error Strings:: How to get a descriptive string from a value. Exchanging Data * Creating Data Buffers:: Creating new data buffers. * Destroying Data Buffers:: Releasing data buffers. * Manipulating Data Buffers:: Operations on data buffers. 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. Manipulating Data Buffers * Data Buffer I/O Operations:: I/O operations on data buffers. * Data Buffer Meta-Data:: Meta-data manipulation of data buffers. Contexts * Creating Contexts:: Creating new @acronym{GPGME} contexts. * Destroying Contexts:: Releasing @acronym{GPGME} contexts. * Context Attributes:: Setting properties of a context. * Key Management:: Managing keys with @acronym{GPGME}. * Trust Item Management:: Managing trust items with @acronym{GPGME}. * Crypto Operations:: Using a context for cryptography. * Run Control:: Controlling how operations are run. Context Attributes * Protocol Selection:: Selecting the protocol used by a context. * Crypto Engine:: Configuring the crypto engine. * ASCII Armor:: Requesting @acronym{ASCII} armored output. * Text Mode:: Choosing canonical text mode. * Included Certificates:: Including a number of certificates. * Key Listing Mode:: Selecting key listing mode. * Passphrase Callback:: Getting the passphrase from the user. * Progress Meter Callback:: Being informed about the progress. * Locale:: Setting the locale of a context. Key Management * Listing Keys:: Browsing the list of available keys. * Information About Keys:: Requesting detailed information about keys. * Key Signatures:: Listing the signatures on a key. * Manipulating Keys:: Operations on keys. * Generating Keys:: Creating new key pairs. * Exporting Keys:: Retrieving key data from the key ring. * Importing Keys:: Adding keys to the key ring. * Deleting Keys:: Removing keys from the key ring. * Advanced Key Editing:: Advanced key edit operation. Trust Item Management * Listing Trust Items:: Browsing the list of available trust items. * Information About Trust Items:: Requesting information about trust items. * Manipulating Trust Items:: Operations on trust items. Crypto Operations * Decrypt:: Decrypting a ciphertext. * Verify:: Verifying a signature. * Decrypt and Verify:: Decrypting a signed ciphertext. * Sign:: Creating a signature. * Encrypt:: Encrypting a plaintext. Sign * Selecting Signers:: How to choose the keys to sign with. * Creating a Signature:: How to create a signature. * Signature Notation Data:: How to add notation data to a signature. Encrypt * Encrypting a Plaintext:: How to encrypt a plaintext. Run Control * Waiting For Completion:: Waiting until an operation is completed. * Using External Event Loops:: Advanced control over what happens when. * Cancellation:: How to end pending operations prematurely. 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. * I/O Callback Example Qt:: How to integrate @acronym{GPGME} in Qt. @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 public key 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 OpenPGP and the Cryptographic Message Syntax (CMS). @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 This manual documents the @acronym{GPGME} library programming interface. All functions and data types provided by the library are explained. The reader is assumed to possess basic knowledge about cryptography in 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 Lesser General Public License (@pxref{Library 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. 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. @node Preparation @chapter Preparation 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. * Building the Source:: Compiler options to be used. * Largefile Support (LFS):: How to use @acronym{GPGME} with LFS. * Using Automake:: Compiler options to be used the easy way. * Using Libtool:: Avoiding compiler options entirely. * Library Version Check:: Getting and verifying the library version. * Signal Handling:: How @acronym{GPGME} affects signal handling. * Multi Threading:: How @acronym{GPGME} can be used in an MT environment. @end menu @node Header @section Header @cindex header file @cindex include file 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 @end example 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_*}. Because @acronym{GPGME} makes use of the GPG Error library, using @acronym{GPGME} will also use the @code{GPG_ERR_*} name space directly, and the @code{gpg_err*} and @code{gpg_str*} name space indirectly. @node Building the Source @section Building the Source @cindex compiler options @cindex compiler flags 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 compiler 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 If you want to link to one of the thread-safe versions of @acronym{GPGME}, you must specify the @option{--thread} option before any other option to select the thread package you want to link with. Supported thread packages are @option{--thread=pth} and @option{--thread=pthread}. @node Largefile Support (LFS) @section Largefile Support (LFS) @cindex largefile support @cindex LFS @acronym{GPGME} is compiled with largefile support by default, if it is available on the system. This means that GPGME supports files larger than two gigabyte in size, if the underlying operating system can. On some systems, largefile support is already the default. On such systems, nothing special is required. However, some systems provide only support for files up to two gigabyte in size by default. Support for larger file sizes has to be specifically enabled. To make a difficult situation even more complex, such systems provide two different types of largefile support. You can either get all relevant functions replaced with alternatives that are largefile capable, or you can get new functions and data types for largefile support added. Those new functions have the same name as their smallfile counterparts, but with a suffix of 64. An example: The data type @code{off_t} is 32 bit wide on GNU/Linux PC systems. To address offsets in large files, you can either enable largefile support add-on. Then a new data type @code{off64_t} is provided, which is 64 bit wide. Or you can replace the existing @code{off_t} data type with its 64 bit wide counterpart. All occurences of @code{off_t} are then automagically replaced. As if matters were not complex enough, there are also two different types of file descriptors in such systems. This is important because if file descriptors are exchanged between programs that use a different maximum file size, certain errors must be produced on some file descriptors to prevent subtle overflow bugs from occuring. As you can see, supporting two different maximum file sizes at the same time is not at all an easy task. However, the maximum file size does matter for @acronym{GPGME}, because some data types it uses in its interfaces are affected by that. For example, the @code{off_t} data type is used in the @code{gpgme_data_seek} function, to match its @acronym{POSIX} counterpart. This affects the call-frame of the function, and thus the ABI of the library. Furthermore, file descriptors can be exchanged between GPGME and the application. For you as the user of the library, this means that your program must be compiled in the same file size mode as the library. Luckily, there is absolutely no valid reason for new programs to not enable largefile support by default and just use that. The compatibility modes (small file sizes or dual mode) can be considered an historic artefact, only useful to allow for a transitional period. @acronym{GPGME} is compiled using largefile support by default. This means that your application must do the same, at least as far as it is relevant for using the @file{gpgme.h} header file. All types in this header files refer to their largefile counterparts, if they are different from any default types on the system. You can enable largefile support, if it is different from the default on the system the application is compiled on, by using the Autoconf macro @code{AC_SYS_LARGEFILE}. If you do this, then you don't need to worry about anything else: It will just work. In this case you might also want to use @code{AC_FUNC_FSEEKO} to take advantage of some new interfaces, and @code{AC_TYPE_OFF_T} (just in case). If you do not use Autoconf, you can define the preprocessor symbol @code{_FILE_OFFSET_BITS} to 64 @emph{before} including any header files, for example by specifying the option @code{-D_FILE_OFFSET_BITS=64} on the compiler command line. You will also want to define the preprocessor symbol @code{LARGEFILE_SOURCE} to 1 in this case, to take advantage of some new interfaces. If you do not want to do either of the above, you probably know enough about the issue to invent your own solution. Just keep in mind that the @acronym{GPGME} header file expects that largefile support is enabled, if it is available. In particular, we do not support dual mode (@code{_LARGEFILE64_SOURCE}). @node Using Automake @section Using Automake @cindex automake @cindex autoconf It is much easier if you use GNU Automake instead of writing your own Makefiles. If you do that you do not 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}) @defmacx AM_PATH_GPGME_PTH (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) @defmacx AM_PATH_GPGME_PTHREAD (@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. @code{AM_PATH_GPGME_PTH} checks for the version of @acronym{GPGME} that can be used with GNU Pth, and defines @code{GPGME_PTH_CFLAGS} and @code{GPGME_PTH_LIBS}. @code{AM_PATH_GPGME_PTHREAD} checks for the version of @acronym{GPGME} that can be used with the native pthread implementation, and defines @code{GPGME_PTHREAD_CFLAGS} and @code{GPGME_PTHREAD_LIBS}. @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 @node Using Libtool @section Using Libtool @cindex libtool The easiest way is to just use GNU Libtool. If you use libtool, and link to @code{libgpgme.la}, @code{libgpgme-pth.la} or @code{libgpgme-pthread.la} respectively, everything will be done automatically by Libtool. @node Library Version Check @section Library Version Check @cindex version check, of the library @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}. As a side effect for W32 based systems, the socket layer will get initialized. 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 After initializing @acronym{GPGME}, you should set the locale information to the locale required for your output terminal. This locale information is needed for example for the curses and Gtk pinentry. Here is an example of a complete initialization: @example #include #include void init_program (void) @{ /* Initialize the locale environment. */ setlocale (LC_ALL, ""); gpgme_check_version (NULL); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); #ifdef LC_MESSAGES gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); #endif @} @end example Note that you are highly recommended to initialize the locale settings like this. @acronym{GPGME} can not do this for you because it would not be thread safe. The conditional on LC_MESSAGES is only necessary for portability to W32 systems. @node Signal Handling @section Signal Handling @cindex signals @cindex signal handling The @acronym{GPGME} library communicates with child processes (the crypto engines). If a child process dies unexpectedly, for example due to a bug, or system problem, a @code{SIGPIPE} signal will be delivered to the application. The default action is to abort the program. To protect against this, @code{gpgme_check_version} sets the @code{SIGPIPE} signal action to @code{SIG_IGN}, which means that the signal will be ignored. @acronym{GPGME} will only do that if the signal action for @code{SIGPIPE} is @code{SIG_DEF} at the time @code{gpgme_check_version} is called. If it is something different, @code{GPGME} will take no action. This means that if your application does not install any signal handler for @code{SIGPIPE}, you don't need to take any precautions. If you do install a signal handler for @code{SIGPIPE}, you must be prepared to handle any @code{SIGPIPE} events that occur due to @acronym{GPGME} writing to a defunct pipe. Furthermore, if your application is multi-threaded, and you install a signal action for @code{SIGPIPE}, you must make sure you do this either before @code{gpgme_check_version} is called or afterwards. @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 @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 at build time. Support for other thread libraries is very easy to add. Please contact us if you have the need. @item If you want to use @acronym{GPGME} with threads, you must link to the right version of the library. The name of the right library is @code{libgpgme-} followed by the name of the thread package you use. For example, if you use GNU Pth, the right name is @code{libgpgme-pth}. Use the Automake macros or @command{gpgme-config} program for simplicity. @item The function @code{gpgme_check_version} must be called before any other function in the library, because it initializes the thread support subsystem in @acronym{GPGME}. To achieve this in multi-threaded programs, you must synchronize the memory with respect to other threads that also want to use @acronym{GPGME}. For this, it is sufficient to call @code{gpgme_check_version} before creating the other threads using @acronym{GPGME}@footnote{At least this is true for POSIX threads, as @code{pthread_create} is a function that synchronizes memory with respects to other threads. There are many functions which have this property, a complete list can be found in POSIX, IEEE Std 1003.1-2003, Base Definitions, Issue 6, in the definition of the term ``Memory Synchronization''. For other thread packages other, more relaxed or more strict rules may apply.}. @item Any @code{gpgme_data_t} and @code{gpgme_ctx_t} 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 that operations on that object are fully synchronized. @item Only one thread at any time is allowed to call @code{gpgme_wait}. If multiple threads call this function, the caller must make sure that all invocations are fully synchronized. It is safe to start asynchronous operations while a thread is running in gpgme_wait. @item The function @code{gpgme_strerror} is not thread safe. You have to use @code{gpgme_strerror_r} instead. @end itemize @node Protocols and Engines @chapter Protocols and Engines @cindex protocol @cindex engine @cindex crypto engine @cindex backend @cindex crypto backend @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 backend 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. @deftp {Data type} {enum gpgme_protocol_t} @tindex gpgme_protocol_t The @code{gpgme_protocol_t} type specifies the set of possible protocol 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 @deftypefun {const char *} gpgme_get_protocol_name (@w{gpgme_protocol_t @var{protocol}}) 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 @menu * Engine Version Check:: Verifying the engine version. * Engine Information:: Obtaining more information about the engines. * Engine Configuration:: Changing the engine configuration. * OpenPGP:: Support for the OpenPGP protocol. * Cryptographic Message Syntax:: Support for the CMS. @end menu @node Engine Version Check @section Engine Version Check @cindex version check, of the engines @deftypefun gpgme_error_t gpgme_engine_check_version (@w{gpgme_protocol_t @var{protocol}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the engine is available and @code{GPG_ERR_INV_ENGINE} if it is not. @end deftypefun @node Engine Information @section Engine Information @cindex engine, information about @deftp {Data type} {gpgme_engine_info_t} @tindex gpgme_protocol_t The @code{gpgme_engine_info_t} type specifies a pointer to a structure describing a crypto engine. The structure contains the following elements: @table @code @item gpgme_engine_info_t next This is a pointer to the next engine info structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_protocol_t protocol This is the protocol for which the crypto engine is used. You can convert this to a string with @code{gpgme_get_protocol_name} for printing. @item const char *file_name This is a string holding the file name of the executable of the crypto 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 *home_dir This is a string holding the directory name of the crypto engine's configuration directory. If it is @code{NULL}, then the default directory is used. @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. @end table @end deftp @deftypefun gpgme_error_t gpgme_get_engine_info (@w{gpgme_engine_info_t *@var{info}}) The function @code{gpgme_get_engine_info} returns a linked list of engine info structures in @var{info}. Each info structure describes the defaults of one configured backend. The memory for the info structures is allocated the first time this function is invoked, and must not be freed by the caller. This function returns the error code @code{GPG_ERR_NO_ERROR} if successful, and a system error if the memory could not be allocated. @end deftypefun Here is an example how you can provide more diagnostics if you receive an error message which indicates that the crypto engine is invalid. @example gpgme_ctx_t ctx; gpgme_error_t err; [...] if (gpgme_err_code (err) == GPG_ERR_INV_ENGINE) @{ gpgme_engine_info_t info; 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)); @} @} @end example @node Engine Configuration @section Engine Configuration @cindex engine, configuration of @cindex configuration of crypto backend You can change the configuration of a backend engine, and thus change the executable program and configuration directory to be used. You can make these changes the default or set them for some contexts individually. @deftypefun gpgme_error_t gpgme_set_engine_info (@w{gpgme_protocol_t @var{proto}}, @w{const char *@var{file_name}}, @w{const char *@var{home_dir}}) The function @code{gpgme_set_engine_info} changes the default configuration of the crypto engine implementing the protocol @var{proto}. @var{file_name} is the file name of the executable program implementing this protocol, and @var{home_dir} is the directory name of the configuration directory for this crypto engine. If @var{home_dir} is @code{NULL}, the engine's default will be used. The new defaults are not applied to already created GPGME contexts. This function returns the error code @code{GPG_ERR_NO_ERROR} if successful, or an eror code on failure. @end deftypefun The functions @code{gpgme_ctx_get_engine_info} and @code{gpgme_ctx_set_engine_info} can be used to change the engine configuration per context. @xref{Crypto Engine}. @node OpenPGP @section OpenPGP @cindex OpenPGP @cindex GnuPG @cindex protocol, GnuPG @cindex engine, GnuPG 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 @cindex CMS @cindex cryptographic message syntax @cindex GpgSM @cindex protocol, CMS @cindex engine, GpgSM @cindex S/MIME @cindex protocol, S/MIME @acronym{CMS} is implemented by GpgSM, the S/MIME implementation for GnuPG. The @acronym{CMS} protocol is specified by @code{GPGME_PROTOCOL_CMS}. @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. @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 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 @deftypefun {const char *} gpgme_pubkey_algo_name (@w{gpgme_pubkey_algo_t @var{algo}}) 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. @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 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 @deftypefun {const char *} gpgme_hash_algo_name (@w{gpgme_hash_algo_t @var{algo}}) 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 @node Error Handling @chapter Error Handling @cindex error handling 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 for many error codes what they mean usually. Some error values have specific meanings if returned by a certain functions. Such cases are described in the documentation of those functions. @acronym{GPGME} uses the @code{libgpg-error} library. This allows to share the error codes with other components of the GnuPG system, and thus pass error values transparently from the crypto engine, or some helper application of the crypto engine, to the user. This way no information is lost. As a consequence, @acronym{GPGME} does not use its own identifiers for error codes, but uses those provided by @code{libgpg-error}. They usually start with @code{GPG_ERR_}. However, @acronym{GPGME} does provide aliases for the functions defined in libgpg-error, which might be preferred for name space consistency. @menu * Error Values:: The error value and what it means. * Error Sources:: A list of important error sources. * Error Codes:: A list of important error codes. * Error Strings:: How to get a descriptive string from a value. @end menu @node Error Values @section Error Values @cindex error values @cindex error codes @cindex error sources @deftp {Data type} {gpgme_err_code_t} The @code{gpgme_err_code_t} type is an alias for the @code{libgpg-error} type @code{gpg_err_code_t}. The error code indicates the type of an error, or the reason why an operation failed. A list of important error codes can be found in the next section. @end deftp @deftp {Data type} {gpgme_err_source_t} The @code{gpgme_err_source_t} type is an alias for the @code{libgpg-error} type @code{gpg_err_source_t}. The error source has not a precisely defined meaning. Sometimes it is the place where the error happened, sometimes it is the place where an error was encoded into an error value. Usually the error source will give an indication to where to look for the problem. This is not always true, but it is attempted to achieve this goal. A list of important error sources can be found in the next section. @end deftp @deftp {Data type} {gpgme_error_t} The @code{gpgme_error_t} type is an alias for the @code{libgpg-error} type @code{gpg_error_t}. An error value like this has always two components, an error code and an error source. Both together form the error value. Thus, the error value can not be directly compared against an error code, but the accessor functions described below must be used. However, it is guaranteed that only 0 is used to indicate success (@code{GPG_ERR_NO_ERROR}), and that in this case all other parts of the error value are set to 0, too. Note that in @acronym{GPGME}, the error source is used purely for diagnostical purposes. Only the error code should be checked to test for a certain outcome of a function. The manual only documents the error code part of an error value. The error source is left unspecified and might be anything. @end deftp @deftypefun {static inline gpgme_err_code_t} gpgme_err_code (@w{gpgme_error_t @var{err}}) The static inline function @code{gpgme_err_code} returns the @code{gpgme_err_code_t} component of the error value @var{err}. This function must be used to extract the error code from an error value in order to compare it with the @code{GPG_ERR_*} error code macros. @end deftypefun @deftypefun {static inline gpgme_err_source_t} gpgme_err_source (@w{gpgme_error_t @var{err}}) The static inline function @code{gpgme_err_source} returns the @code{gpgme_err_source_t} component of the error value @var{err}. This function must be used to extract the error source from an error value in order to compare it with the @code{GPG_ERR_SOURCE_*} error source macros. @end deftypefun @deftypefun {static inline gpgme_error_t} gpgme_err_make (@w{gpgme_err_source_t @var{source}}, @w{gpgme_err_code_t @var{code}}) The static inline function @code{gpgme_err_make} returns the error value consisting of the error source @var{source} and the error code @var{code}. This function can be used in callback functions to construct an error value to return it to the library. @end deftypefun @deftypefun {static inline gpgme_error_t} gpgme_error (@w{gpgme_err_code_t @var{code}}) The static inline function @code{gpgme_error} returns the error value consisting of the default error source and the error code @var{code}. For @acronym{GPGME} applications, the default error source is @code{GPG_ERR_SOURCE_USER_1}. You can define @code{GPGME_ERR_SOURCE_DEFAULT} before including @file{gpgme.h} to change this default. This function can be used in callback functions to construct an error value to return it to the library. @end deftypefun The @code{libgpg-error} library provides error codes for all system error numbers it knows about. If @var{err} is an unknown error number, the error code @code{GPG_ERR_UNKNOWN_ERRNO} is used. The following functions can be used to construct error values from system errnor numbers. @deftypefun {gpgme_error_t} gpgme_err_make_from_errno (@w{gpgme_err_source_t @var{source}}, @w{int @var{err}}) The function @code{gpgme_err_make_from_errno} is like @code{gpgme_err_make}, but it takes a system error like @code{errno} instead of a @code{gpgme_err_code_t} error code. @end deftypefun @deftypefun {gpgme_error_t} gpgme_error_from_errno (@w{int @var{err}}) The function @code{gpgme_error_from_errno} is like @code{gpgme_error}, but it takes a system error like @code{errno} instead of a @code{gpgme_err_code_t} error code. @end deftypefun Sometimes you might want to map system error numbers to error codes directly, or map an error code representing a system error back to the system error number. The following functions can be used to do that. @deftypefun {gpgme_err_code_t} gpgme_err_code_from_errno (@w{int @var{err}}) The function @code{gpgme_err_code_from_errno} returns the error code for the system error @var{err}. If @var{err} is not a known system error, the function returns @code{GPG_ERR_UNKNOWN_ERRNO}. @end deftypefun @deftypefun {int} gpgme_err_code_to_errno (@w{gpgme_err_code_t @var{err}}) The function @code{gpgme_err_code_to_errno} returns the system error for the error code @var{err}. If @var{err} is not an error code representing a system error, or if this system error is not defined on this system, the function returns @code{0}. @end deftypefun @node Error Sources @section Error Sources @cindex error codes, list of The library @code{libgpg-error} defines an error source for every component of the GnuPG system. The error source part of an error value is not well defined. As such it is mainly useful to improve the diagnostic error message for the user. If the error code part of an error value is @code{0}, the whole error value will be @code{0}. In this case the error source part is of course @code{GPG_ERR_SOURCE_UNKNOWN}. The list of error sources that might occur in applications using @acronym{GPGME} is: @table @code @item GPG_ERR_SOURCE_UNKNOWN The error source is not known. The value of this error source is @code{0}. @item GPG_ERR_SOURCE_GPGME The error source is @acronym{GPGME} itself. This is the default for errors that occur in the @acronym{GPGME} library. @item GPG_ERR_SOURCE_GPG The error source is GnuPG, which is the crypto engine used for the OpenPGP protocol. @item GPG_ERR_SOURCE_GPGSM The error source is GPGSM, which is the crypto engine used for the CMS protocol. @item GPG_ERR_SOURCE_GCRYPT The error source is @code{libgcrypt}, which is used by crypto engines to perform cryptographic operations. @item GPG_ERR_SOURCE_GPGAGENT The error source is @command{gpg-agent}, which is used by crypto engines to perform operations with the secret key. @item GPG_ERR_SOURCE_PINENTRY The error source is @command{pinentry}, which is used by @command{gpg-agent} to query the passphrase to unlock a secret key. @item GPG_ERR_SOURCE_SCD The error source is the SmartCard Daemon, which is used by @command{gpg-agent} to delegate operations with the secret key to a SmartCard. @item GPG_ERR_SOURCE_KEYBOX The error source is @code{libkbx}, a library used by the crypto engines to manage local keyrings. @item GPG_ERR_SOURCE_USER_1 @item GPG_ERR_SOURCE_USER_2 @item GPG_ERR_SOURCE_USER_3 @item GPG_ERR_SOURCE_USER_4 These error sources are not used by any GnuPG component and can be used by other software. For example, applications using @acronym{GPGME} can use them to mark error values coming from callback handlers. Thus @code{GPG_ERR_SOURCE_USER_1} is the default for errors created with @code{gpgme_error} and @code{gpgme_error_from_errno}, unless you define @code{GPGME_ERR_SOURCE_DEFAULT} before including @file{gpgme.h}. @end table @node Error Codes @section Error Codes @cindex error codes, list of The library @code{libgpg-error} defines many error values. Most of them are not used by @code{GPGME} directly, but might be returned by @acronym{GPGME} because it received them from the crypto engine. The below list only includes such error codes that have a specific meaning in @code{GPGME}, or which are so common that you should know about them. @table @code @item GPG_ERR_EOF This value indicates the end of a list, buffer or file. @item GPG_ERR_NO_ERROR This value indicates success. The value of this error code is @code{0}. Also, it is guaranteed that an error value made from the error code @code{0} will be @code{0} itself (as a whole). This means that the error source information is lost for this error code, however, as this error code indicates that no error occured, this is generally not a problem. @item GPG_ERR_GENERAL This value means that something went wrong, but either there is not enough information about the problem to return a more useful error value, or there is no separate error value for this type of problem. @item GPG_ERR_ENOMEM This value means that an out-of-memory condition occurred. @item GPG_ERR_E... System errors are mapped to GPG_ERR_FOO where FOO is the symbol for the system error. @item GPG_ERR_INV_VALUE This value means that some user provided data was out of range. This can also refer to objects. For example, if an empty @code{gpgme_data_t} object was expected, but one containing data was provided, this error value is returned. @item GPG_ERR_UNUSABLE_PUBKEY This value means that some recipients for a message were invalid. @item GPG_ERR_UNUSABLE_SECKEY This value means that some signers were invalid. @item GPG_ERR_NO_DATA This value means that a @code{gpgme_data_t} object which was expected to have content was found empty. @item GPG_ERR_CONFLICT This value means that a conflict of some sort occurred. @item GPG_ERR_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 GPG_ERR_DECRYPT_FAILED This value indicates that a decryption operation was unsuccessful. @item GPG_ERR_BAD_PASSPHRASE This value means that the user did not provide a correct passphrase when requested. @item GPG_ERR_CANCELED This value means that the operation was canceled. @item GPG_ERR_INV_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. @item GPG_ERR_AMBIGUOUS_NAME This value indicates that a user ID or other specifier did not specify a unique key. @item GPG_ERR_WRONG_KEY_USAGE This value indicates that a key is not used appropriately. @item GPG_ERR_CERT_REVOKED This value indicates that a key signature was revoced. @item GPG_ERR_CERT_EXPIRED This value indicates that a key signature expired. @item GPG_ERR_NO_CRL_KNOWN This value indicates that no certificate revocation list is known for the certificate. @item GPG_ERR_NO_POLICY_MATCH This value indicates that a policy issue occured. @item GPG_ERR_NO_SECKEY This value indicates that no secret key for the user ID is available. @item GPG_ERR_MISSING_CERT This value indicates that a key could not be imported because the issuer certificate is missing. @item GPG_ERR_BAD_CERT_CHAIN This value indicates that a key could not be imported because its certificate chain is not good, for example it could be too long. @item GPG_ERR_UNSUPPORTED_ALGORITHM This value means a verification failed because the cryptographic algorithm is not supported by the crypto backend. @item GPG_ERR_BAD_SIGNATURE This value means a verification failed because the signature is bad. @item GPG_ERR_NO_PUBKEY This value means a verification failed because the public key is not available. @item GPG_ERR_USER_1 @item GPG_ERR_USER_2 @item ... @item GPG_ERR_USER_16 These error codes are not used by any GnuPG component and can be freely used by other software. Applications using @acronym{GPGME} might use them to mark specific errors returned by callback handlers if no suitable error codes (including the system errors) for these errors exist already. @end table @node Error Strings @section Error Strings @cindex error values, printing of @cindex error codes, printing of @cindex error sources, printing of @cindex error strings @deftypefun {const char *} gpgme_strerror (@w{gpgme_error_t @var{err}}) The function @code{gpgme_strerror} returns a pointer to a statically allocated string containing a description of the error code contained in the error value @var{err}. This string can be used to output a diagnostic message to the user. This function is not thread safe. Use @code{gpgme_strerror_r} in multi-threaded programs. @end deftypefun @deftypefun {int} gpgme_strerror_r (@w{gpgme_error_t @var{err}}, @w{char *@var{buf}}, @w{size_t @var{buflen}}) The function @code{gpgme_strerror_r} returns the error string for @var{err} in the user-supplied buffer @var{buf} of size @var{buflen}. This function is, in contrast to @code{gpgme_strerror}, thread-safe if a thread-safe @code{strerror_r} function is provided by the system. If the function succeeds, 0 is returned and @var{buf} contains the string describing the error. If the buffer was not large enough, ERANGE is returned and @var{buf} contains as much of the beginning of the error string as fits into the buffer. @end deftypefun @deftypefun {const char *} gpgme_strsource (@w{gpgme_error_t @var{err}}) The function @code{gpgme_strerror} returns a pointer to a statically allocated string containing a description of the error source contained in the error value @var{err}. This string can be used to output a diagnostic message to the user. @end deftypefun The following example illustrates the use of @code{gpgme_strerror}: @example gpgme_ctx_t ctx; gpgme_error_t err = gpgme_new (&ctx); if (err) @{ fprintf (stderr, "%s: creating GpgME context failed: %s: %s\n", argv[0], gpgme_strsource (err), gpgme_strerror (err)); exit (1); @} @end example @node Exchanging Data @chapter Exchanging Data @cindex data, exchanging 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}. The user provides and receives the data via @code{gpgme_data_t} objects, regardless of the communication protocol between @acronym{GPGME} and the crypto engine in use. @deftp {Data type} {gpgme_data_t} The @code{gpgme_data_t} type is a handle for a container for generic data, which is used by @acronym{GPGME} to exchange data with the user. @end deftp @menu * Creating Data Buffers:: Creating new data buffers. * Destroying Data Buffers:: Releasing data buffers. * Manipulating Data Buffers:: Operations on data buffers. @end menu @node Creating Data Buffers @section Creating Data Buffers @cindex data buffer, creation 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 @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} object and returns a handle for it in @var{dh}. The data object is memory based and initially empty. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @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}}) The function @code{gpgme_data_new_from_mem} creates a new @code{gpgme_data_t} object and fills it with @var{size} bytes starting 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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} or @var{buffer} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_file (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{filename}}, @w{int @var{copy}}) The function @code{gpgme_data_new_from_file} creates a new @code{gpgme_data_t} object and fills it with the content of the file @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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} or @var{filename} is not a valid pointer, @code{GPG_ERR_NOT_IMPLEMENTED} if @var{code} is zero, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @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}}) The function @code{gpgme_data_new_from_filepart} creates a new @code{gpgme_data_t} object and fills it with a part of the file specified 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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} and exactly one of @var{filename} and @var{fp} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @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}. @deftypefun gpgme_error_t gpgme_data_new_from_fd (@w{gpgme_data_t *@var{dh}}, @w{int @var{fd}}) The function @code{gpgme_data_new_from_fd} creates a new @code{gpgme_data_t} object and uses the file descriptor @var{fd} to read 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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_stream (@w{gpgme_data_t *@var{dh}}, @w{FILE *@var{stream}}) The function @code{gpgme_data_new_from_stream} creates a new @code{gpgme_data_t} object and uses the I/O stream @var{stream} to read 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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} 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. @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 @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 @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 @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 @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 @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 @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 @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 @deftp {Data type} {struct gpgme_data_cbs} This structure is used to store the data callback interface functions described above. It has the following members: @table @code @item gpgme_data_read_cb_t read This is the function called by @acronym{GPGME} to read data from the data object. It is only required for input data object. @item gpgme_data_write_cb_t write This is the function called by @acronym{GPGME} to write data to the data object. It is only required for output data object. @item gpgme_data_seek_cb_t seek This is the function called by @acronym{GPGME} to change the current read/write pointer in the data object (if available). It is optional. @item gpgme_data_release_cb_t release This is the function called by @acronym{GPGME} to release a data object. It is optional. @end table @end deftp @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}}) The function @code{gpgme_data_new_from_cbs} creates a new @code{gpgme_data_t} object and uses the user-provided callback functions 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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} 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}. @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}}) The function @code{gpgme_data_new_with_read_cb} creates a new @code{gpgme_data_t} object and uses the callback function @var{readfunc} 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 the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} or @var{readfunc} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @node Destroying Data Buffers @section Destroying Data Buffers @cindex data buffer, destruction @deftypefun void gpgme_data_release (@w{gpgme_data_t @var{dh}}) 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 @deftypefun {char *} gpgme_data_release_and_get_mem (@w{gpgme_data_t @var{dh}}, @w{size_t *@var{length}}) 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{gpgme_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}. In any case, the data object @var{dh} is destroyed. @end deftypefun @deftypefun void gpgme_free (@w{void *@var{buffer}}) The function @code{gpgme_free} releases the memory returned by @code{gpgme_data_release_and_get_mem}. It should be used instead of the system libraries @code{free} function in case different allocators are used in a single program. @end deftypefun @node Manipulating Data Buffers @section Manipulating Data Buffers @cindex data buffer, manipulation Data buffers contain data and meta-data. The following operations can be used to manipulate both. @menu * Data Buffer I/O Operations:: I/O operations on data buffers. * Data Buffer Meta-Data:: Meta-data manipulation of data buffers. @end menu @node Data Buffer I/O Operations @subsection Data Buffer I/O Operations @cindex data buffer, I/O operations @cindex data buffer, read @cindex data buffer, write @cindex data buffer, seek @deftypefun ssize_t gpgme_data_read (@w{gpgme_data_t @var{dh}}, @w{void *@var{buffer}}, @w{size_t @var{length}}) 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 at @var{buffer}. If no error occurs, the actual amount read is returned. If the end of the data object is reached, the function returns 0. In all other cases, the function returns -1 and sets @var{errno}. @end deftypefun @deftypefun ssize_t gpgme_data_write (@w{gpgme_data_t @var{dh}}, @w{const void *@var{buffer}}, @w{size_t @var{size}}) The function @code{gpgme_data_write} writes up to @var{size} bytes starting from @var{buffer} into the data object with the handle @var{dh} at the current write position. The function returns the number of bytes actually written, or -1 if an error occurs. If an error occurs, @var{errno} is set. @end deftypefun @deftypefun off_t gpgme_data_seek (@w{gpgme_data_t @var{dh}}, @w{off_t @var{offset}}, @w{int @var{whence}}) 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: @table @code @item SEEK_SET Specifies that @var{offset} is a count of characters from the beginning of the data object. @item SEEK_CUR Specifies that @var{offset} is a count of characters from the current file position. This count may be positive or negative. @item SEEK_END Specifies that @var{offset} 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 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. If the function fails, -1 is returned and @var{errno} is set. @end deftypefun The following function is deprecated and should not be used. It will be removed in a future version of @acronym{GPGME}. @deftypefun gpgme_error_t gpgme_data_rewind (@w{gpgme_data_t @var{dh}}) The function @code{gpgme_data_rewind} is equivalent to: @example return (gpgme_data_seek (dh, 0, SEEK_SET) == -1) ? gpgme_error_from_errno (errno) : 0; @end example @end deftypefun @node Data Buffer Meta-Data @subsection Data Buffer Meta-Data @cindex data buffer, meta-data @cindex data buffer, file name @cindex data buffer, encoding @deftypefun {char *} gpgme_data_get_file_name (@w{gpgme_data_t @var{dh}}) The function @code{gpgme_data_get_file_name} returns a pointer to a string containing the file name associated with the data object. The file name will be stored in the output when encrypting or signing the data and will be returned to the user when decrypting or verifying the output data. If no error occurs, the string containing the file name is returned. Otherwise, @code{NULL} will be returned. @end deftypefun @deftypefun gpgme_error_t gpgme_data_set_file_name (@w{gpgme_data_t @var{dh}}, @w{const char *@var{file_name}}) The function @code{gpgme_data_set_file_name} sets the file name associated with the data object. The file name will be stored in the output when encrypting or signing the data and will be returned to the user when decrypting or verifying the output data. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{dh} is not a valid pointer and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @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 a hint on the type of data. The following data types are available: @table @code @item GPGME_DATA_ENCODING_NONE This specifies that the encoding is not known. This is the default for a new data object. The backend will try its best to detect the encoding automatically. @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 @deftypefun gpgme_data_encoding_t gpgme_data_get_encoding (@w{gpgme_data_t @var{dh}}) 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. @end deftypefun @deftypefun gpgme_error_t gpgme_data_set_encoding (@w{gpgme_data_t @var{dh}, gpgme_data_encoding_t @var{enc}}) The function @code{gpgme_data_set_encoding} changes the encoding of the data object with the handle @var{dh} to @var{enc}. @end deftypefun @c @c Chapter Contexts @c @node Contexts @chapter Contexts @cindex context All cryptographic operations in @acronym{GPGME} are performed within a 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. @deftp {Data type} {gpgme_ctx_t} The @code{gpgme_ctx_t} type is a handle for a @acronym{GPGME} context, which is used to hold the configuration, status and result of cryptographic operations. @end deftp @menu * Creating Contexts:: Creating new @acronym{GPGME} contexts. * Destroying Contexts:: Releasing @acronym{GPGME} contexts. * Context Attributes:: Setting properties of a context. * Key Management:: Managing keys with @acronym{GPGME}. * Trust Item Management:: Managing trust items with @acronym{GPGME}. * Crypto Operations:: Using a context for cryptography. * Run Control:: Controlling how operations are run. @end menu @node Creating Contexts @section Creating Contexts @cindex context, creation @deftypefun gpgme_error_t gpgme_new (@w{gpgme_ctx_t *@var{ctx}}) The function @code{gpgme_new} creates a new @code{gpgme_ctx_t} object and returns a handle for it in @var{ctx}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the context was successfully created, @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @node Destroying Contexts @section Destroying Contexts @cindex context, destruction @deftypefun void gpgme_release (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_release} destroys the context with the handle @var{ctx} and releases all associated resources. @end deftypefun @node Context Attributes @section Context Attributes @cindex context, attributes @menu * Protocol Selection:: Selecting the protocol used by a context. * Crypto Engine:: Configuring the crypto engine. * ASCII Armor:: Requesting @acronym{ASCII} armored output. * Text Mode:: Choosing canonical text mode. * Included Certificates:: Including a number of certificates. * Key Listing Mode:: Selecting key listing mode. * Passphrase Callback:: Getting the passphrase from the user. * Progress Meter Callback:: Being informed about the progress. * Locale:: Setting the locale of a context. @end menu @node Protocol Selection @subsection Protocol Selection @cindex context, selecting protocol @cindex protocol, selecting @deftypefun gpgme_error_t gpgme_set_protocol (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_protocol_t @var{proto}}) 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 correctly. @xref{Engine Version Check}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the protocol could be set successfully, and @code{GPG_ERR_INV_VALUE} if @var{protocol} is not a valid protocol. @end deftypefun @deftypefun gpgme_protocol_t gpgme_get_protocol (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_protocol} retrieves the protocol currently use with the context @var{ctx}. @end deftypefun @node Crypto Engine @subsection Crypto Engine @cindex context, configuring engine @cindex engine, configuration per context The following functions can be used to set and retrieve the configuration of the crypto engines of a specific context. The default can also be retrieved without any particular context. @xref{Engine Information}. The default can also be changed globally. @xref{Engine Configuration}. @deftypefun gpgme_engine_info_t gpgme_ctx_get_engine_info (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_ctx_get_engine_info} returns a linked list of engine info structures. Each info structure describes the configuration of one configured backend, as used by the context @var{ctx}. The result is valid until the next invocation of @code{gpgme_ctx_set_engine_info} for this particular context. This function can not fail. @end deftypefun @deftypefun gpgme_error_t gpgme_ctx_set_engine_info (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_protocol_t @var{proto}}, @w{const char *@var{file_name}}, @w{const char *@var{home_dir}}) The function @code{gpgme_ctx_set_engine_info} changes the configuration of the crypto engine implementing the protocol @var{proto} for the context @var{ctx}. @var{file_name} is the file name of the executable program implementing this protocol, and @var{home_dir} is the directory name of the configuration directory for this crypto engine. If @var{home_dir} is @code{NULL}, the engine's default will be used. Currently this function must be used before starting the first crypto operation. It is unspecified if and when the changes will take effect if the function is called after starting the first operation on the context @var{ctx}. This function returns the error code @code{GPG_ERR_NO_ERROR} if successful, or an eror code on failure. @end deftypefun @c FIXME: Unfortunately, using @acronym here breaks texi2dvi. @node ASCII Armor @subsection @acronym{ASCII} Armor @cindex context, armor mode @cindex @acronym{ASCII} armor @cindex armor mode @deftypefun void gpgme_set_armor (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}}) The function @code{gpgme_set_armor} specifies if the output should be @acronym{ASCII} armored. By default, output is not @acronym{ASCII} armored. @acronym{ASCII} armored output is disabled if @var{yes} is zero, and enabled otherwise. @end deftypefun @deftypefun int gpgme_get_armor (@w{gpgme_ctx_t @var{ctx}}) 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 @node Text Mode @subsection Text Mode @cindex context, text mode @cindex text mode @cindex canonical text mode @deftypefun void gpgme_set_textmode (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}}) 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. This option is only relevant to the OpenPGP crypto engine, and ignored by all other engines. Canonical text mode is disabled if @var{yes} is zero, and enabled otherwise. @end deftypefun @deftypefun int gpgme_get_textmode (@w{gpgme_ctx_t @var{ctx}}) 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 @node Included Certificates @subsection Included Certificates @cindex certificates, included @deftypefun void gpgme_set_include_certs (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{nr_of_certs}}) 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 GPGME_INCLUDE_CERTS_DEFAULT Fall back to the default of the crypto backend. This is the default for GPGME. @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 @deftypefun int gpgme_get_include_certs (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_include_certs} returns the number of certificates to include into an S/MIME signed message. @end deftypefun @node Key Listing Mode @subsection Key Listing Mode @cindex key listing mode @cindex key listing, mode of @deftypefun gpgme_error_t gpgme_set_keylist_mode (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_keylist_mode_t @var{mode}}) The function @code{gpgme_set_keylist_mode} changes the default 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: @table @code @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 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. @item GPGME_KEYLIST_MODE_SIGS The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key signatures should be included in the listed keys. @item GPGME_KEYLIST_MODE_SIG_NOTATIONS The @code{GPGME_KEYLIST_MODE_SIG_NOTATIONS} symbol specifies that the signature notations on key signatures should be included in the listed keys. This only works if @code{GPGME_KEYLIST_MODE_SIGS} is also enabled. @item GPGME_KEYLIST_MODE_VALIDATE The @code{GPGME_KEYLIST_MODE_VALIDATE} symbol specifies that the backend should do key or certificate validation and not just get the validity information from an internal cache. This might be an expensive operation and is in general not useful. Currently only implemented for the S/MIME backend and ignored for other backends. @end table 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 the error code @code{GPG_ERR_NO_ERROR} if the mode could be set correctly, and @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer or @var{mode} is not a valid mode. @end deftypefun @deftypefun gpgme_keylist_mode_t gpgme_get_keylist_mode (@w{gpgme_ctx_t @var{ctx}}) 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. @end deftypefun @node Passphrase Callback @subsection Passphrase Callback @cindex callback, passphrase @cindex passphrase callback @deftp {Data type} {gpgme_error_t (*gpgme_passphrase_cb_t)(void *@var{hook}, const char *@var{uid_hint}, const char *@var{passphrase_info}, @w{int @var{prev_was_bad}}, @w{int @var{fd}})} @tindex gpgme_passphrase_cb_t The @code{gpgme_passphrase_cb_t} type is the type of functions usable as passphrase callback function. The argument @var{uid_hint} might contain a string that gives an indication for which user ID the passphrase is required. If this is not available, or not applicable (in the case of symmetric encryption, for example), @var{uid_hint} will be @code{NULL}. The argument @var{passphrase_info}, if not @code{NULL}, will give further information about the context in which the passphrase is required. This information is engine and operation specific. If this is the repeated attempt to get the passphrase, because previous attempts failed, then @var{prev_was_bad} is 1, otherwise it will be 0. The user must write the passphrase, followed by a newline character, to the file descriptor @var{fd}. If the user returns 0 indicating success, the user must at least write a newline character before returning from the callback. If an error occurs, return the corresponding @code{gpgme_error_t} value. You can use the error code @code{GPG_ERR_CANCELED} to abort the operation. Otherwise, return @code{0}. @end deftp @deftypefun void gpgme_set_passphrase_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_passphrase_cb_t @var{passfunc}}, @w{void *@var{hook_value}}) 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. Some engines do not even support an external passphrase callback at all, in this case the error code @code{GPG_ERR_NOT_SUPPORTED} is returned. 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 @deftypefun void gpgme_get_passphrase_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_passphrase_cb_t *@var{passfunc}}, @w{void **@var{hook_value}}) 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. @var{passfunc} or @var{hook_value} can be @code{NULL}. In this case, the corresponding value will not be returned. @end deftypefun @node Progress Meter Callback @subsection Progress Meter Callback @cindex callback, progress meter @cindex progress meter callback @deftp {Data type} {void (*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 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 @deftypefun void gpgme_set_progress_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_progress_cb_t @var{progfunc}}, @w{void *@var{hook_value}}) 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 @deftypefun void gpgme_get_progress_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_progress_cb_t *@var{progfunc}}, @w{void **@var{hook_value}}) 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. @var{progfunc} or @var{hook_value} can be @code{NULL}. In this case, the corresponding value will not be returned. @end deftypefun @node Locale @subsection Locale @cindex locale, default @cindex locale, of a context A locale setting can be associated with a context. This locale is passed to the crypto engine, and used for applications like the PIN entry, which is displayed to the user when entering a passphrase is required. The default locale is used to initialize the locale setting of all contexts created afterwards. @deftypefun gpgme_error_t gpgme_set_locale (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{category}}, @w{const char *@var{value}}) The function @code{gpgme_set_locale} sets the locale of the context @var{ctx}, or the default locale if @var{ctx} is a null pointer. The locale settings that should be changed are specified by @var{category}. Supported categories are @code{LC_CTYPE}, @code{LC_MESSAGES}, and @code{LC_ALL}, which is a wildcard you can use if you want to change all the categories at once. The value to be used for the locale setting is @var{value}, which will be copied to @acronym{GPGME}'s internal data structures. @var{value} can be a null pointer, which disables setting the locale, and will make PIN entry and other applications use their default setting, which is usually not what you want. Note that the settings are only used if the application runs on a text terminal, and that the settings should fit the configuration of the output terminal. Normally, it is sufficient to initialize the default value at startup. The function returns an error if not enough memory is available. @end deftypefun @node Key Management @section Key Management @cindex key management 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. @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 are those parts that contains the real information about the individual cryptographic keys that belong to the same key object. One @code{gpgme_key_t} can contain several subkeys. The first subkey in the linked list is also called the primary key. The subkey structure has the following members: @table @code @item gpgme_sub_key_t next 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 to create data signatures. @item unsigned int can_certify : 1 This is true if the subkey can be used to create key certificates. @item unsigned int can_authenticate : 1 This is true if the subkey can be used for authentication. @item unsigned int is_qualified : 1 This is true if the subkey can be used for qualified signatures according to local government regulations. @item unsigned int secret : 1 This is true if the subkey is a secret key. Note that it will be false if the key is actually a stub key; i.e. a secret key operation is currently not possible (offline-key). @item gpgme_pubkey_algo_t pubkey_algo 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. @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 @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 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 can be expensive to retrieve all signatures of a key. The signature notations on a key signature are only available if the key was retrieved via a listing operation with the @code{GPGME_KEYLIST_MODE_SIG_NOTATIONS} mode enabled, because it can be expensive to retrieve all signature notations. The key signature structure has the following members: @table @code @item gpgme_key_sig_t next 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 exportable : 1 This is true if the key signature is exportable. @item gpgme_pubkey_algo_t pubkey_algo 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. @item gpgme_error_t status This is the status of the signature and has the same meaning as the member of the same name in a @code{gpgme_signature_t} object. @item unsigned int sig_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. @item gpgme_sig_notation_t notations This is a linked list with the notation data and policy URLs. @end table @end deftp @deftp {Data type} gpgme_user_id_t A user ID is a component of a @code{gpgme_key_t} object. One key can 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 @item gpgme_user_id_t next 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. @item gpgme_validity_t validity 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. @item gpgme_key_sig_t signatures This is a linked list with the signatures on this user ID. @end table @end deftp @deftp {Data type} gpgme_key_t The @code{gpgme_key_t} type is a pointer to a key object. It has the following members: @table @code @item gpgme_keylist_mode_t keylist_mode The keylist mode that was active when the key was retrieved. @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. @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. This might have several reasons, for a example for the S/MIME backend, it will be set in during key listsing if the key could not be validated due to a missing certificates or unmatched policies. @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 to create data signatures. @item unsigned int can_certify : 1 This is true if the key (ie one of its subkeys) can be used to create key certificates. @item unsigned int can_authenticate : 1 This is true if the key (ie one of its subkeys) can be used for authentication. @item unsigned int is_qualified : 1 This is true if the key can be used for qualified signatures according to local government regulations. @item unsigned int secret : 1 This is true if the key is a secret key. Note, that this will always be true even if the corresponding subkey flag may be false (offline/stub keys). @item gpgme_protocol_t protocol 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. @item gpgme_validity_t owner_trust If @code{protocol} is @code{GPGME_PROTOCOL_OpenPGP}, then this is the owner trust. @item gpgme_sub_key_t subkeys This is a linked list with the subkeys of the key. The first subkey in the list is the primary key and usually available. @item gpgme_user_id_t uids 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 @end deftp @menu * Listing Keys:: Browsing the list of available keys. * Information About Keys:: Requesting detailed information about keys. * Key Signatures:: Listing the signatures on a key. * Manipulating Keys:: Operations on keys. * Generating Keys:: Creating new key pairs. * Exporting Keys:: Retrieving key data from the key ring. * Importing Keys:: Adding keys to the key ring. * Deleting Keys:: Removing keys from the key ring. * Advanced Key Editing:: Advanced key edit operation. @end menu @node Listing Keys @subsection Listing Keys @cindex listing keys @cindex key listing @cindex key listing, start @cindex key ring, list @cindex key ring, search @deftypefun gpgme_error_t gpgme_op_keylist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{secret_only}}) 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. Note that the total length of the pattern is restricted to an engine-specific maximum (a couple of hundred characters are usually accepted). The pattern should be used to restrict the search to a certain common name or user, not to list many specific keys at once by listing their fingerprints or key IDs. 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{GPG_ERR_EOF}), or @code{gpgme_op_keylist_end} is called to finish the operation. The function returns the error code @code{GPG_ERR_INV_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 @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}}) 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. Note that the total length of all patterns is restricted to an engine-specific maximum (the exact limit also depends on the number of patterns and amount of quoting required, but a couple of hundred characters are usually accepted). Patterns should be used to restrict the search to a certain common name or user, not to list many specific keys at once by listing their fingerprints or key IDs. 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{GPG_ERR_EOF}), or @code{gpgme_op_keylist_end} is called to finish the operation. The function returns the error code @code{GPG_ERR_INV_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 @deftypefun gpgme_error_t gpgme_op_keylist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t *@var{r_key}}) 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. @xref{Manipulating Keys}. This is the only way to get at @code{gpgme_key_t} objects in @acronym{GPGME}. If the last key in the list has already been returned, @code{gpgme_op_keylist_next} returns @code{GPG_ERR_EOF}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{r_key} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if there is not enough memory for the operation. @end deftypefun @deftypefun gpgme_error_t gpgme_op_keylist_end (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_keylist_next} ends a pending key list operation in the context @var{ctx}. After the operation completed successfully, the result of the key listing operation can be retrieved with @code{gpgme_op_keylist_result}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if at some time during the operation there was not enough memory available. @end deftypefun 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 gpgme_ctx_t ctx; gpgme_error_t err = gpgme_new (&ctx); if (!err) @{ err = gpgme_op_keylist_start (ctx, "g10code", 0); while (!err) @{ err = gpgme_op_keylist_next (ctx, &key); if (err) break; printf ("%s: %s <%s>\n", key->keyid, key->name, key->email); gpgme_key_release (key); @} gpgme_release (ctx); @} if (gpg_err_code (err) != GPG_ERR_EOF) @{ fprintf (stderr, "%s: can not list keys: %s\n", argv[0], gpgme_strerror (err)); exit (1); @} @end example @deftp {Data type} {gpgme_keylist_result_t} 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 @deftypefun gpgme_keylist_result_t gpgme_op_keylist_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_keylist_result} returns a @code{gpgme_keylist_result_t} pointer to a structure holding the result of 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 In a simple program, for which a blocking operation is acceptable, the following function can be used to retrieve a single key. @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}}) The function @code{gpgme_get_key} gets the key with the fingerprint (or key ID) @var{fpr} from the crypto backend and return it in @var{r_key}. If @var{secret} is true, get the secret key. The currently active keylist mode is used to retrieve the key. The key will have one reference for the user. If the key is not found in the keyring, @code{gpgme_get_key} returns the error code @code{GPG_ERR_NO_ERROR} and *@var{r_key} will be set to @code{NULL}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{r_key} is not a valid pointer or @var{fpr} is not a fingerprint or key ID, @code{GPG_ERR_AMBIGUOUS_NAME} if the key ID was not a unique specifier for a key, and @code{GPG_ERR_ENOMEM} if at some time during the operation there was not enough memory available. @end deftypefun @node Information About Keys @subsection Information About Keys @cindex key, information about @cindex key, attributes @cindex attributes, of a key Please see the beginning of this section for more information about @code{gpgme_key_t} objects. @deftp {Data type} gpgme_validity_t The @code{gpgme_validity_t} type is used to specify the validity of a user ID 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 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}. @deftp {Data type} gpgme_attr_t The @code{gpgme_attr_t} type is used to specify a key or trust item 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 This is the expiration time of a sub key. It is representable as a number. @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 @var{gpgme_key_t} object. The first one (with index 0) is the primary 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 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. @item GPGME_ATTR_IS_SECRET This specifies if the key is a secret key. It is representable as a number, and is @code{1} if the key is revoked, and @code{0} otherwise. @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 to create data 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 to create key certificates. It is representable as a number, and is @code{1} if the sub key can be used for certifications, and @code{0} otherwise. @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. @end table @end deftp @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}}) The function @code{gpgme_key_get_string_attr} returns the value of the string-representable attribute @var{what} of key @var{key}. If the 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}. 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 @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}}) The function @code{gpgme_key_get_ulong_attr} returns the value of the number-representable attribute @var{what} of key @var{key}. If the 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}. 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 @node Key Signatures @subsection Key Signatures @cindex key, signatures @cindex signatures, on a key 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}. 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}. @deftp {Data type} gpgme_attr_t The @code{gpgme_attr_t} type is used to specify a key signature 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 @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}}) 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 @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}}) 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 @node Manipulating Keys @subsection Manipulating Keys @cindex key, manipulation @deftypefun void gpgme_key_ref (@w{gpgme_key_t @var{key}}) The function @code{gpgme_key_ref} acquires an additional reference for the key @var{key}. @end deftypefun @deftypefun void gpgme_key_unref (@w{gpgme_key_t @var{key}}) The function @code{gpgme_key_unref} releases a reference for the key @var{key}. If this was the last reference, the key 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}. @deftypefun void gpgme_key_release (@w{gpgme_key_t @var{key}}) The function @code{gpgme_key_release} is equivalent to @code{gpgme_key_unref}. @end deftypefun @node Generating Keys @subsection Generating Keys @cindex key, creation @cindex key ring, add @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}}) The function @code{gpgme_op_genkey} generates a new key pair in the 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. The argument @var{parms} specifies parameters for the key in an XML string. The details about the format of @var{parms} are specific to the crypto engine used by @var{ctx}. Here is an example for GnuPG as the crypto engine: @example 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 @end example Here is an example for GpgSM as the crypto engine: @example Key-Type: RSA Key-Length: 1024 Name-DN: C=de,O=g10 code,OU=Testlab,CN=Joe 2 Tester Name-Email: joe@@foo.bar @end example Strings should be given in UTF-8 encoding. The only format supported for now is ``internal''. The content of the @code{GnupgKeyParms} container is passed verbatim to the crypto backend. Control statements are not allowed. After the operation completed successfully, the result can be retrieved with @code{gpgme_op_genkey_result}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{parms} is not a valid XML string, @code{GPG_ERR_NOT_SUPPORTED} if @var{public} or @var{secret} is not valid, and @code{GPG_ERR_GENERAL} if no key was created by the backend. @end deftypefun @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}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{parms} is not a valid XML string, and @code{GPG_ERR_NOT_SUPPORTED} if @var{public} or @var{secret} is not @code{NULL}. @end deftypefun @deftp {Data type} {gpgme_genkey_result_t} 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 @deftypefun gpgme_genkey_result_t gpgme_op_genkey_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_genkey_result} returns a @code{gpgme_genkey_result_t} pointer to a structure holding the result of 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 @node Exporting Keys @subsection Exporting Keys @cindex key, export @cindex key ring, export from @deftypefun gpgme_error_t gpgme_op_export (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export} extracts public keys and returns them in the data buffer @var{keydata}. The output format of the key data returned is determined by the @acronym{ASCII} armor attribute set for the context @var{ctx}. 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. @var{reserved} is reserved for future use and must be @code{0}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation completed successfully, @code{GPG_ERR_INV_VALUE} if @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 @deftypefun gpgme_error_t gpgme_op_export_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_export_ext (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export} extracts public keys and returns them in the data buffer @var{keydata}. The output format of the key data returned is determined by the @acronym{ASCII} armor attribute set for the context @var{ctx}. 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. @var{reserved} is reserved for future use and must be @code{0}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation completed successfully, @code{GPG_ERR_INV_VALUE} if @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 @deftypefun gpgme_error_t gpgme_op_export_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{unsigned int @var{reserved}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export_ext_start} initiates a @code{gpgme_op_export_ext} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer. @end deftypefun @node Importing Keys @subsection Importing Keys @cindex key, import @cindex key ring, import to @deftypefun gpgme_error_t gpgme_op_import (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}) 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 @acronym{ASCII} armored, for example, but the details are specific to the crypto engine. After the operation completed successfully, the result can be retrieved with @code{gpgme_op_import_result}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the import was completed successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} if @var{ctx} or @var{keydata} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{keydata} is an empty data buffer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_import_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the import could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} if @var{ctx} or @var{keydata} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{keydata} is an empty data buffer. @end deftypefun @deftp {Data type} {gpgme_import_status_t} This is a pointer to a structure used to store a part of the result of a @code{gpgme_op_import} operation. For each considered key one status is added that contains information about the result of the import. The structure contains the following members: @table @code @item gpgme_import_status_t next This is a pointer to the next status structure in the linked list, or @code{NULL} if this is the last element. @item char *fpr This is the fingerprint of the key that was considered. @item gpgme_error_t result If the import was not successful, this is the error value that caused the import to fail. Otherwise the error code is @code{GPG_ERR_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. @item GPGME_IMPORT_SECRET The key contained a secret key. @end table @end table @end deftp @deftp {Data type} {gpgme_import_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_import} operation. After a successful import 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. @item gpgme_import_status_t imports A list of gpgme_import_status_t objects which contain more information about the keys for which an import was attempted. @end table @end deftp @deftypefun gpgme_import_result_t gpgme_op_import_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_import_result} returns a @code{gpgme_import_result_t} pointer to a structure holding the result of 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}. @deftypefun gpgme_error_t gpgme_op_import_ext (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}, @w{int *@var{nr}}) The function @code{gpgme_op_import_ext} is equivalent to: @example gpgme_error_t err = gpgme_op_import (ctx, keydata); if (!err) @{ gpgme_import_result_t result = gpgme_op_import_result (ctx); *nr = result->considered; @} @end example @end deftypefun @node Deleting Keys @subsection Deleting Keys @cindex key, delete @cindex key ring, delete from @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}}) 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, otherwise secret keys are deleted as well, if that is supported. The function returns the error code @code{GPG_ERR_NO_ERROR} if the key was deleted successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer, @code{GPG_ERR_NO_PUBKEY} if @var{key} could not be found in the keyring, @code{GPG_ERR_AMBIGUOUS_NAME} if the key was not specified unambiguously, and @code{GPG_ERR_CONFLICT} if the secret key for @var{key} is available, but @var{allow_secret} is zero. @end deftypefun @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}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation was started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer. @end deftypefun @node Advanced Key Editing @subsection Advanced Key Editing @cindex key, edit @deftp {Data type} {gpgme_error_t (*gpgme_edit_cb_t) (@w{void *@var{handle}}, @w{gpgme_status_code_t @var{status}}, @w{const char *@var{args}}, @w{int @var{fd}})} @tindex gpgme_edit_cb_t The @code{gpgme_edit_cb_t} type is the type of functions which @acronym{GPGME} calls if it a key edit operation is on-going. The status code @var{status} and the argument line @var{args} are passed through by @acronym{GPGME} from the crypto engine. The file descriptor @var{fd} is -1 for normal status messages. If @var{status} indicates a command rather than a status message, the response to the command should be written to @var{fd}. The @var{handle} is provided by the user at start of operation. The function should return @code{GPG_ERR_NO_ERROR} or an error value. @end deftp @deftypefun gpgme_error_t gpgme_op_edit (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) The function @code{gpgme_op_edit} processes the key @var{KEY} interactively, using the edit callback function @var{FNC} with the handle @var{HANDLE}. The callback is invoked for every status and command request from the crypto engine. The output of the crypto engine is written to the data object @var{out}. Note that the protocol between the callback function and the crypto engine is specific to the crypto engine and no further support in implementing this protocol correctly is provided by @acronym{GPGME}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the edit operation completes successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer, and any error returned by the crypto engine or the edit callback handler. @end deftypefun @deftypefun gpgme_error_t gpgme_op_edit_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) The function @code{gpgme_op_edit_start} initiates a @code{gpgme_op_edit} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation was started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_card_edit (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) The function @code{gpgme_op_card_edit} is analogous to @code{gpgme_op_edit}, but should be used to process the smart card corresponding to the key @var{key}. @end deftypefun @deftypefun gpgme_error_t gpgme_op_card_edit_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) The function @code{gpgme_op_card_edit_start} initiates a @code{gpgme_op_card_edit} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation was started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer. @end deftypefun @node Trust Item Management @section Trust Item Management @cindex trust item @strong{Caution:} The trust items interface is experimental. @deftp {Data type} gpgme_trust_item_t The @code{gpgme_trust_item_t} type is a pointer to a trust item object. 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. @item char *owner_trust The owner trust if @code{type} is 1. @item char *validity The calculated validity. @item char *name The user name if @code{type} is 2. @end table @end deftp @menu * Listing Trust Items:: Browsing the list of available trust items. * Information About Trust Items:: Requesting information about trust items. * Manipulating Trust Items:: Operations on trust items. @end menu @node Listing Trust Items @subsection Listing Trust Items @cindex trust item list @deftypefun gpgme_error_t gpgme_op_trustlist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{max_level}}) 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 the trust items in the list. 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{GPG_ERR_EOF}), or @code{gpgme_op_trustlist_end} is called to finish the operation. The function returns the error code @code{GPG_ERR_INV_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 @deftypefun gpgme_error_t gpgme_op_trustlist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_trust_item_t *@var{r_item}}) 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 with @code{gpgme_trust_item_release}. @xref{Manipulating Trust Items}. This is the only way to get at @code{gpgme_trust_item_t} objects in @acronym{GPGME}. If the last trust item in the list has already been returned, @code{gpgme_op_trustlist_next} returns @code{GPG_ERR_EOF}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{r_item} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if there is not enough memory for the operation. @end deftypefun @deftypefun gpgme_error_t gpgme_op_trustlist_end (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_trustlist_next} ends a pending key list operation in the context @var{ctx}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if at some time during the operation there was not enough memory available. @end deftypefun @node Information About Trust Items @subsection Information About Trust Items @cindex trust item, information about @cindex trust item, attributes @cindex attributes, of a trust item 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}. Trust items have attributes which can be queried using the interfaces below. The attribute identifiers are shared with those for key attributes. @xref{Information About Keys}. @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}}) The function @code{gpgme_trust_item_get_string_attr} returns the value of the string-representable attribute @var{what} of trust item @var{item}. The arguments @var{idx} and @var{reserved} are reserved for later use and should be @code{0} and @code{NULL} respectively. 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 @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}}) 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 @node Manipulating Trust Items @subsection Manipulating Trust Items @cindex trust item, manipulation @deftypefun void gpgme_trust_item_ref (@w{gpgme_trust_item_t @var{item}}) The function @code{gpgme_trust_item_ref} acquires an additional reference for the trust item @var{item}. @end deftypefun @deftypefun void gpgme_trust_item_unref (@w{gpgme_trust_item_t @var{item}}) 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}. @deftypefun void gpgme_trust_item_release (@w{gpgme_trust_item_t @var{item}}) The function @code{gpgme_trust_item_release} is an alias for @code{gpgme_trust_item_unref}. @end deftypefun @node Crypto Operations @section Crypto Operations @cindex cryptographic operation Sometimes, the result of a crypto operation returns a list of invalid keys encountered in processing the request. The following structure is used to hold information about such a key. @deftp {Data type} {gpgme_invalid_key_t} 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 @item gpgme_invalid_key_t next This is a pointer to the next invalid key structure in the linked list, or @code{NULL} if this is the last element. @item char *fpr The fingerprint or key ID of the invalid key encountered. @item gpgme_error_t reason An error code describing the reason why the key was found invalid. @end table @end deftp @menu * Decrypt:: Decrypting a ciphertext. * Verify:: Verifying a signature. * Decrypt and Verify:: Decrypting a signed ciphertext. * Sign:: Creating a signature. * Encrypt:: Encrypting a plaintext. @end menu @node Decrypt @subsection Decrypt @cindex decryption @cindex cryptographic operation, decryption @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}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the ciphertext could be decrypted successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{cipher} or @var{plain} is not a valid pointer, @code{GPG_ERR_NO_DATA} if @var{cipher} does not contain any data to decrypt, @code{GPG_ERR_DECRYPT_FAILED} if @var{cipher} is not a valid cipher text, @code{GPG_ERR_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. @end deftypefun @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}}) 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}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{cipher} or @var{plain} is not a valid pointer. @end deftypefun @deftp {Data type} {gpgme_recipient_t} This is a pointer to a structure used to store information about the recipient of an encrypted text which is decrypted in a @code{gpgme_op_decrypt} operation. This information (except for the status field) is even available before the operation finished successfully, for example in a passphrase callback. The structure contains the following members: @table @code @item gpgme_recipient_t next This is a pointer to the next recipient structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_pubkey_algo_t The public key algorithm used in the encryption. @item unsigned int wrong_key_usage : 1 This is true if the key was not used according to its policy. @item char *keyid This is the key ID of the key (in hexadecimal digits) used as recipient. @item gpgme_error_t status This is an error number with the error code GPG_ERR_NO_SECKEY if the secret key for this recipient is not available, and 0 otherwise. @end table @end deftp @deftp {Data type} {gpgme_decrypt_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_decrypt} operation. After successfully decrypting 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. @item unsigned int wrong_key_usage : 1 This is true if the key was not used according to its policy. @item gpgme_recipient_t recipient This is a linked list of recipients to which this message was encrypted. @item char *file_name This is the filename of the original plaintext message file if it is known, otherwise this is a null pointer. @end table @end deftp @deftypefun gpgme_decrypt_result_t gpgme_op_decrypt_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_decrypt_result} returns a @code{gpgme_decrypt_result_t} pointer to a structure holding the result of 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. If the operation failed this might be a @code{NULL} pointer. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @node Verify @subsection Verify @cindex verification @cindex signature, verification @cindex cryptographic operation, verification @cindex cryptographic operation, signature check @cindex signature notation data @cindex notation data @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}}) The function @code{gpgme_op_verify} verifies that the signature in the 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. The results of the individual signature verifications can be retrieved with @code{gpgme_op_verify_result}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be completed successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{sig} or @var{plain} is not a valid pointer, @code{GPG_ERR_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. @end deftypefun @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}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{sig} or @var{plain} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{sig} or @var{plain} does not contain any data to verify. @end deftypefun @deftp {Data type} {gpgme_sig_notation_t} 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: @table @code @item gpgme_sig_notation_t next This is a pointer to the next new signature notation structure in the linked list, or @code{NULL} if this is the last element. @item char *name The name of the notation field. If this is @code{NULL}, then the member @code{value} will contain a policy URL. @item int name_len The length of the @code{name} field. For strings the length is counted without the trailing binary zero. @item char *value The value of the notation field. If @code{name} is @code{NULL}, then this is a policy URL. @item int value_len The length of the @code{value} field. For strings the length is counted without the trailing binary zero. @item gpgme_sig_notation_flags_t flags The accumulated flags field. This field contains the flags associated with the notation data in an accumulated form which can be used as an argument to the function @code{gpgme_sig_notation_add}. The value @code{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_SIG_NOTATION_HUMAN_READABLE The @code{GPGME_SIG_NOTATION_HUMAN_READABLE} symbol specifies that the notation data is in human readable form @item GPGME_SIG_NOTATION_CRITICAL The @code{GPGME_SIG_NOTATION_CRITICAL} symbol specifies that the notation data is critical. @end table @item unsigned int human_readable : 1 This is true if the @code{GPGME_SIG_NOTATION_HUMAN_READABLE} flag is set and false otherwise. This flag is only valid for notation data, not for policy URLs. @item unsigned int critical : 1 This is true if the @code{GPGME_SIG_NOTATION_CRITICAL} flag is set and false otherwise. This flag is valid for notation data and policy URLs. @end table @end deftp @deftp {Data type} {gpgme_signature_t} 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: @table @code @item gpgme_signature_t next This is a pointer to the next new signature structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_sigsum_t 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. 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 check other bits and display more 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 verify due to a missing key or 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. @end table @item char *fpr This is the fingerprint or key ID of the signature. @item gpgme_error_t status This is the status of the signature. In particular, the following status codes are of interest: @table @code @item GPG_ERR_NO_ERROR This status indicates that the signature is valid. For the combined result this status means that all signatures are valid. @item GPG_ERR_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 GPG_ERR_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 GPG_ERR_CERT_REVOKED This status indicates that the signature is valid but the key used to verify the signature has been revoked. For the combined result this status means that all signatures are valid and all keys are revoked. @item GPG_ERR_BAD_SIGNATURE This status indicates that the signature is invalid. For the combined result this status means that all signatures are invalid. @item GPG_ERR_NO_PUBKEY 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 GPG_ERR_GENERAL This status indicates that there was some other error which prevented the signature verification. @end table @item gpgme_sig_notation_t notations 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 unsigned int wrong_key_usage : 1 This is true if the key was not used according to its policy. @item unsigned int pka_trust : 2 This is set to the trust information gained by means of the PKA system. Values are: @table @code @item 0 No PKA information available or verification not possible. @item 1 PKA verification failed. @item 2 PKA verification succeeded. @item 3 Reserved for future use. @end table Depending on the configuration of the engine, this metric may also be reflected by the validity of the signature. @item unsigned int chain_model : 1 This is true if the validity of the signature has been checked using the chain model. In the chain model the time the signature has been created must be within the validity period of the certificate and the time the certificate itself has been created must be within the validity period of the issuing certificate. In contrast the default validation model checks the validity of signature as well at the entire certificate chain at the current time. @item gpgme_validity_t validity The validity of the signature. @item gpgme_error_t validity_reason If a signature is not valid, this provides a reason why. @item gpgme_pubkey_algo_t The public key algorithm used to create this signature. @item gpgme_hash_algo_t The hash algorithm used to create this signature. @end table @end deftp @deftp {Data type} {gpgme_verify_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_verify} operation. After verifying a signature, you can retrieve the pointer to the result with @code{gpgme_op_verify_result}. If the operation failed this might be a @code{NULL} pointer. The structure contains the following member: @table @code @item gpgme_signature_t signatures A linked list with information about all signatures for which a verification was attempted. @item char *file_name This is the filename of the original plaintext message file if it is known, otherwise this is a null pointer. @end table @end deftp @deftypefun gpgme_verify_result_t gpgme_op_verify_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_verify_result} returns a @code{gpgme_verify_result_t} pointer to a structure holding the result of a @code{gpgme_op_verify} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_verify}, @code{gpgme_op_verify_start}, @code{gpgme_op_decrypt_verify} or @code{gpgme_op_decrypt_verify_start} operation, and if this operation finished successfully (for @code{gpgme_op_decrypt_verify} and @code{gpgme_op_decrypt_verify_start}, the error code @code{GPG_ERR_NO_DATA} counts as successful in this context). 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}. @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 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}. @end table @end deftp @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}}) The function @code{gpgme_get_sig_status} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; 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 (gpg_err_code (sig->status)) @{ case GPG_ERR_NO_ERROR: *r_stat = GPGME_SIG_STAT_GOOD; break; case GPG_ERR_BAD_SIGNATURE: *r_stat = GPGME_SIG_STAT_BAD; break; case GPG_ERR_NO_PUBKEY: *r_stat = GPGME_SIG_STAT_NOKEY; break; case GPG_ERR_NO_DATA: *r_stat = GPGME_SIG_STAT_NOSIG; break; case GPG_ERR_SIG_EXPIRED: *r_stat = GPGME_SIG_STAT_GOOD_EXP; break; case GPG_ERR_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 @end deftypefun @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}}) The function @code{gpgme_get_sig_string_attr} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return NULL; 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; @} return NULL; @end example @end deftypefun @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}}) The function @code{gpgme_get_sig_ulong_attr} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return 0; 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 GPG_ERR_NO_ERROR: return GPGME_SIG_STAT_GOOD; case GPG_ERR_BAD_SIGNATURE: return GPGME_SIG_STAT_BAD; case GPG_ERR_NO_PUBKEY: return GPGME_SIG_STAT_NOKEY; case GPG_ERR_NO_DATA: return GPGME_SIG_STAT_NOSIG; case GPG_ERR_SIG_EXPIRED: return GPGME_SIG_STAT_GOOD_EXP; case GPG_ERR_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 @deftypefun {const char *} gpgme_get_sig_key (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_key_t *@var{r_key}}) The function @code{gpgme_get_sig_key} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return gpg_error (GPG_ERR_EOF); return gpgme_get_key (ctx, sig->fpr, r_key, 0); @end example @end deftypefun @node Decrypt and Verify @subsection Decrypt and Verify @cindex decryption and verification @cindex verification and decryption @cindex signature check @cindex cryptographic operation, decryption and verification @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}}) 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 verified. After the operation completed, @code{gpgme_op_decrypt_result} and @code{gpgme_op_verify_result} can be used to retrieve more information about the signatures. If the error code @code{GPG_ERR_NO_DATA} is returned, @var{cipher} does not contain any data to decrypt. However, it might still be signed. The information about detected signatures is available with @code{gpgme_op_verify_result} in this case. The function returns the error code @code{GPG_ERR_NO_ERROR} if the ciphertext could be decrypted successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{cipher} or @var{plain} is not a valid pointer, @code{GPG_ERR_NO_DATA} if @var{cipher} does not contain any data to decrypt, @code{GPG_ERR_DECRYPT_FAILED} if @var{cipher} is not a valid cipher text, @code{GPG_ERR_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. @end deftypefun @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}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{cipher}, @var{plain} or @var{r_stat} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{cipher} does not contain any data to decrypt. @end deftypefun @node Sign @subsection Sign @cindex signature, creation @cindex sign @cindex cryptographic operation, signing 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 * Selecting Signers:: How to choose the keys to sign with. * Creating a Signature:: How to create a signature. * Signature Notation Data:: How to add notation data to a signature. @end menu @node Selecting Signers @subsubsection Selecting Signers @cindex signature, selecting signers @cindex signers, selecting @deftypefun void gpgme_signers_clear (@w{gpgme_ctx_t @var{ctx}}) 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 @deftypefun gpgme_error_t gpgme_signers_add (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}) The function @code{gpgme_signers_add} adds the key @var{key} to the list of signers in the context @var{ctx}. Calling this function acquires an additional reference for the key. @end deftypefun @deftypefun gpgme_key_t gpgme_signers_enum (@w{const gpgme_ctx_t @var{ctx}}, @w{int @var{seq}}) 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 @node Creating a Signature @subsubsection Creating a Signature @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 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 @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}}) 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 @acronym{ASCII} armor and text mode attributes set for the context @var{ctx} and the requested signature mode @var{mode}. After the operation completed successfully, the result can be retrieved with @code{gpgme_op_sign_result}. 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}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the signature could be created successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{plain} or @var{sig} is not a valid pointer, @code{GPG_ERR_NO_DATA} if the signature could not be created, @code{GPG_ERR_BAD_PASSPHRASE} if the passphrase for the secret key could not be retrieved, @code{GPG_ERR_UNUSABLE_SECKEY} if there are invalid signers, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @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}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{plain} or @var{sig} is not a valid pointer. @end deftypefun @deftp {Data type} {gpgme_new_signature_t} 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 @item gpgme_new_signature_t next This is a pointer to the next new signature structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_sig_mode_t type The type of this signature. @item gpgme_pubkey_algo_t The public key algorithm used to create this signature. @item gpgme_hash_algo_t The hash algorithm used to create this signature. @item unsigned int sig_class The signature class of this signature. @item long int timestamp 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 @deftp {Data type} {gpgme_sign_result_t} 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 @item gpgme_invalid_key_t invalid_signers A linked list with information about all invalid keys for which a signature could not be created. @item gpgme_new_signature_t signatures A linked list with information about all signatures created. @end table @end deftp @deftypefun gpgme_sign_result_t gpgme_op_sign_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_sign_result} returns a @code{gpgme_sign_result_t} pointer to a structure holding the result of a @code{gpgme_op_sign} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_sign}, @code{gpgme_op_sign_start}, @code{gpgme_op_encrypt_sign} or @code{gpgme_op_encrypt_sign_start} operation. If that operation failed, the function might return a @code{NULL} pointer, The returned pointer is only valid until the next operation is started on the context. @end deftypefun @node Signature Notation Data @subsubsection Signature Notation Data @cindex notation data @cindex signature notation data @cindex policy URL Using the following functions, you can attach arbitrary notation data to a signature. This information is then available to the user when the signature is verified. @deftypefun void gpgme_sig_notation_clear (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_sig_notation_clear} removes the notation data from the context @var{ctx}. Subsequent signing operations from this context will not include any notation data. Every context starts with an empty notation data list. @end deftypefun @deftypefun gpgme_error_t gpgme_sig_notation_add (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{name}}, @w{const char *@var{value}}, @w{gpgme_sig_notation_flags_t @var{flags}}) The function @code{gpgme_sig_notation_add} adds the notation data with the name @var{name} and the value @var{value} to the context @var{ctx}. Subsequent signing operations will include this notation data, as well as any other notation data that was added since the creation of the context or the last @code{gpgme_sig_notation_clear} operation. The arguments @var{name} and @var{value} must be @code{NUL}-terminated strings in human-readable form. The flag @code{GPGME_SIG_NOTATION_HUMAN_READABLE} is implied (non-human-readable notation data is currently not supported). The strings must be in UTF-8 encoding. If @var{name} is @code{NULL}, then @var{value} should be a policy URL. The function @code{gpgme_sig_notation_add} returns the error code @code{GPG_ERR_NO_ERROR} if the notation data could be added successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, or if @var{name}, @var{value} and @var{flags} are an invalid combination. The function also passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_sig_notation_t gpgme_sig_notation_get (@w{const gpgme_ctx_t @var{ctx}}) The function @code{gpgme_sig_notation_get} returns the linked list of notation data structures that are contained in the context @var{ctx}. If @var{ctx} is not a valid pointer, or there is no notation data added for this context, @code{NULL} is returned. @end deftypefun @node Encrypt @subsection Encrypt @cindex encryption @cindex cryptographic operation, encryption 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 * Encrypting a Plaintext:: How to encrypt a plaintext. @end menu @node Encrypting a Plaintext @subsubsection Encrypting a Plaintext @deftypefun gpgme_error_t gpgme_op_encrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) The function @code{gpgme_op_encrypt} encrypts the plaintext in the data object @var{plain} for the recipients @var{recp} and stores the ciphertext in the data object @var{cipher}. The type of the ciphertext created is determined by the @acronym{ASCII} armor and text mode attributes set for the context @var{ctx}. @var{key} must be a @code{NULL}-terminated array of keys. The user must keep references for all keys during the whole duration of the call (but see @code{gpgme_op_encrypt_start} for the requirements with the asynchronous variant). The value in @var{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_ENCRYPT_ALWAYS_TRUST The @code{GPGME_ENCRYPT_ALWAYS_TRUST} symbol specifies that all the recipients in @var{recp} should be trusted, even if the keys do not have a high enough validity in the keyring. This flag should be used with care; in general it is not a good idea to use any untrusted keys. @end table If @code{GPG_ERR_UNUSABLE_PUBKEY} is returned, some recipients in @var{recp} are invalid, but not all. In this case the plaintext might be encrypted for all valid recipients and returned in @var{cipher} (if this happens depends on the crypto engine). More information about the invalid recipients is available with @code{gpgme_op_encrypt_result}. 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. The function returns the error code @code{GPG_ERR_NO_ERROR} if the ciphertext could be created successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{recp}, @var{plain} or @var{cipher} is not a valid pointer, @code{GPG_ERR_UNUSABLE_PUBKEY} if @var{recp} contains some invalid recipients, @code{GPG_ERR_BAD_PASSPHRASE} if the passphrase for the symmetric key could not be retrieved, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) 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}. References to the keys only need to be held for the duration of this call. The user can release its references to the keys after this function returns, even if the operation is not yet finished. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and @code{GPG_ERR_UNUSABLE_PUBKEY} if @var{rset} does not contain any valid recipients. @end deftypefun @deftp {Data type} {gpgme_encrypt_result_t} 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 @item gpgme_invalid_key_t invalid_recipients A linked list with information about all invalid keys for which the data could not be encrypted. @end table @end deftp @deftypefun gpgme_encrypt_result_t gpgme_op_encrypt_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_encrypt_result} returns a @code{gpgme_encrypt_result_t} pointer to a structure holding the result of a @code{gpgme_op_encrypt} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_encrypt}, @code{gpgme_op_encrypt_start}, @code{gpgme_op_sign} or @code{gpgme_op_sign_start} operation. If this operation failed, this might be a @code{NULL} pointer. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_sign (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) 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 @deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) 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 the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer. @end deftypefun @node Run Control @section Run Control @cindex run control @cindex cryptographic operation, running @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. @menu * Waiting For Completion:: Waiting until an operation is completed. * Using External Event Loops:: Advanced control over what happens when. * Cancellation:: How to end pending operations prematurely. @end menu @node Waiting For Completion @subsection Waiting For Completion @cindex cryptographic operation, wait for @cindex wait for completion @deftypefun gpgme_ctx_t gpgme_wait (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_error_t *@var{status}}, @w{int @var{hang}}) 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. 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. The error status of the finished operation is returned in @var{status} if @code{gpgme_wait} does not return @code{NULL}. The @var{ctx} argument can be @code{NULL}. In that case, @code{gpgme_wait} waits for any context to complete its operation. @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 synchronized by locking primitives. It is safe to start asynchronous operations while a thread is running in @code{gpgme_wait}. The function returns the @var{ctx} of the context which has finished 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}. @end deftypefun @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 more 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. * I/O Callback Example Qt:: How to use @acronym{GPGME} with Qt. @end menu @node I/O Callback Interface @subsubsection I/O Callback Interface @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 @acronym{GPGME} wants to register as I/O callback handlers using the @code{gpgme_register_io_cb_t} functions provided by the user. @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}. The callback handler always returns @code{0}, but you should consider the return value to be reserved for later use. @end deftp @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 be called by @acronym{GPGME} to register an I/O callback function @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 @code{gpgme_register_io_cb_t} function with @acronym{GPGME} and will always 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 @code{gpgme_register_io_cb_t} function without interpretation when the file descriptor should not be monitored anymore. @end deftp @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 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 @code{gpgme_register_io_cb_t} for this I/O callback. @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 @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 reported to the user by @acronym{GPGME} as a consequence of an I/O operation. The following events are defined: @table @code @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. @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 @code{gpgme_error_t} variable that contains the status of the operation 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 a @code{gpgme_key_t} variable that contains the key with one reference 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} is a @code{gpgme_trust_item_t} variable that contains the trust item with one reference for the user. @end table @end deftp @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 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 @code{gpgme_event_io_cb_t} function with @acronym{GPGME} and will always be 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 list of possible @code{gpgme_event_io_t} types. @acronym{GPGME} can call this function in an I/O callback handler. @end deftp @node Registering I/O Callbacks @subsubsection Registering I/O Callbacks @deftp {Data type} {struct gpgme_io_cb_ts} @tindex gpgme_event_io_t This structure is used to store the I/O callback interface functions described in the previous section. It has the following members: @table @code @item gpgme_register_io_cb_t add 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. @item gpgme_remove_io_cb_t remove This is the function called by @acronym{GPGME} to remove an I/O callback handler. It must be specified. @item gpgme_event_io_cb_t event This is the function called by @acronym{GPGME} to signal an event for an operation. It must be specified, because at least the start event must be processed. @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 @deftypefun void gpgme_set_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cb_ts *@var{io_cbs}}) 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 @deftypefun void gpgme_get_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cb_ts *@var{io_cbs}}) 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 +locking to show in which way 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 #include #include /* The following structure holds the result of a crypto operation. */ struct op_result @{ int done; gpgme_error_t err; @}; /* The following structure holds the data associated with one I/O callback. */ struct one_fd @{ int fd; int dir; gpgme_io_cb_t fnc; 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 gpgme_error_t add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, 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 gpg_error (GPG_ERR_GENERAL); *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 event_io_cb (void *data, gpgme_event_io_t type, void *type_data) @{ struct op_result *result = data; /* We don't support list operations here. */ if (type == GPGME_EVENT_DONE) @{ result->done = 1; result->err = *type_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; gpgme_ctx_t ctx; gpgme_error_t err; gpgme_data_t sig, text; gpgme_sig_stat_t status; int i; struct gpgme_io_cb_ts io_cbs = @{ 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: %s\n", gpgme_strsource (err), 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: %s\n", gpgme_strsource (result.err), 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 struct my_gpgme_io_cb @{ gpgme_io_cb_t fnc; 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 my_gpgme_register_io_callback (void *data, int fd, int dir, gpgme_io_cb_t fnc, 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 struct my_gpgme_io_cb @{ gpgme_io_cb_t fnc; 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 my_gpgme_register_io_callback (void *data, int fd, int dir, gpgme_io_cb_t fnc, 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 @node I/O Callback Example Qt @subsubsection I/O Callback Example Qt @cindex Qt, using @acronym{GPGME} with The I/O callback interface can also be used to integrate @acronym{GPGME} with the Qt event loop. The following code snippets show 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 Qt specific setup. @example #include #include struct IOCB @{ IOCB( GpgmeIOCb f, void * d, QSocketNotifier * n ) : func( f ), data( d ), notifier( n ) @{@} GpgmeIOCb func; void * data; QSocketNotifier * notifier; @} class MyApp : public QApplication @{ // ... static void registerGpgmeIOCallback( void * data, int fd, int dir, GpgmeIOCb func, void * func_data, void ** tag ) @{ QSocketNotifier * n = new QSocketNotifier( fd, dir ? QSocketNotifier::Read : QSocketNotifier::Write ); connect( n, SIGNAL(activated(int)), qApp, SLOT(slotGpgmeIOCallback(int)) ); qApp->mIOCBs.push_back( IOCB( func, func_data, n ) ); *tag = (void*)n; @} static void removeGpgmeIOCallback( void * tag ) @{ if ( !tag ) return; QSocketNotifier * n = static_cast( tag ); for ( QValueList::iterator it = qApp->mIOCBs.begin() ; it != qApp->mIOCBs.end() ; ++it ) if ( it->notifier == n ) @{ delete it->notifier; qApp->mIOCBs.erase( it ); return; @} @} public slots: void slotGpgmeIOCallback( int fd ) @{ for ( QValueList::const_iterator it = mIOCBs.begin() ; it != mIOCBs.end() ; ++it ) if ( it->notifier && it->notifier->socket() == fd ) (*(it->func)) ( it->func_data, fd ); @} // ... private: QValueList mIOCBs; // ... @}; @end example @node Cancellation @subsection Cancellation @cindex cryptographic operation, aborting @cindex cryptographic operation, cancelling @cindex aborting operations @cindex cancelling operations Sometimes you do not want to wait for an operation to finish. If you use external I/O callbacks, you can cancel a pending operation. However, you must ensure that no other thread is currently using the context in which the operation you want to cancel runs. This includes callback handlers. So your external event loop must either be halted or otherwise it must be guaranteed that no installed I/O callbacks are run for this context. @deftypefun gpgme_ctx_t gpgme_cancel (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_cancel} attempts to cancel a pending operation in the context @var{ctx}. This only works if you use the global event loop or your own event loop. If you use the global event loop, you must not call @code{gpgme_wait} or @code{gpgme_wait} during cancellation. After successful cancellation, you can call @code{gpgme_wait} (optionally waiting on @var{ctx}), and the context @var{ctx} will appear as if it had finished with the error code @code{GPG_ERR_CANCEL}. If you use your an external event loop, you must ensure that no I/O callbacks are invoked for this context (for example by halting the event loop). On successful cancellation, all registered I/O callbacks for this context will be unregistered, and a @code{GPGME_EVENT_DONE} event with the error code @code{GPG_ERR_CANCEL} will be signaled. The function returns an error code if the cancellation failed (in this case the state of @var{ctx} is not modified). @end deftypefun @include lesser.texi @node Concept Index @unnumbered Concept Index @printindex cp @node Function and Data Index @unnumbered Function and Data Index @printindex fn @summarycontents @contents @bye diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index d115dc61..53a1d0b8 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,5474 +1,5478 @@ +2007-09-14 Werner Koch + + * data-mem.c (gpgme_data_release_and_get_mem): Fix tracing bug. + 2007-09-14 Marcus Brinkmann * gpgme.c (gpgme_release): Call gpgme_sig_notation_clear. 2007-09-13 Marcus Brinkmann * rungpg.c (gpg_new): Handle return value of _gpgme_getenv (fixes small memory leak). 2007-09-07 Marcus Brinkmann * Makefile.am (libgpgme_qt_la_SOURCES): Move moc_kdpipeiodevice.cpp to EXTRA_DIST, as this is only included by another file (it's more like a header file than a cpp file, but automake doesn't know that). * w32-qt-io.cpp (_gpgme_io_spawn): Fix several cast errors and typos. * w32-io.c (_gpgme_io_write): Use TRACE_SYSRES instead of TRACE_SYS. (libgpgme_qt_la_LIBADD): Add QT4_CORE_LIBS, not QT4_CORE_LIB. * kdpipeiodevice.h, kdpipeiodevice.cpp, moc_kdpipeiodevice.cpp, kdpipeiodevice.moc, w32-qt-io.c: New files. * Makefile.am (ltlib_gpgme_extra): Rename to ltlib_gpgme_glib. (ltlib_gpgme_qt): New variable. (lib_LTLIBRARIES): Add $(ltlib_gpgme_qt). (libgpgme_qt_la_SOURCES): New variable. (AM_CPPFLAGS): Add @QT4_CORE_INCLUDES@ (AM_CFLAGS): Add @QT4_CORE_CFLAGS@. (libgpgme_qt_la_LDFLAGS, libgpgme_qt_la_DEPENDENCIES) (libgpgme_qt_la_LIBADD): New variables. * sema.h (struct critsect_s): Rename "private" to "priv" to make C++ users happy. Change users. * posix-sema.c (_gpgme_sema_cs_enter, _gpgme_sema_cs_leave) (_gpgme_sema_cs_destroy): Likewise. * w32-sema.c (critsect_init, _gpgme_sema_cs_enter) (_gpgme_sema_cs_leave, _gpgme_sema_cs_destroy): Likewise. * w32-glib-io.c (gpgme_get_giochannel): Change return type to void*. (gpgme_get_fdptr): New function. * w32-io.c (gpgme_get_fdptr): New function * gpgme.def: Add gpgme_get_fdptr. 2007-08-22 Marcus Brinkmann * w32-io.c (_gpgme_io_write): Return early if COUNT is zero. (writer): Remove superfluous check. 2007-08-20 Marcus Brinkmann * gpgme.h: Move include of gpg-error.h out of extern "C". 2007-08-07 Werner Koch * gpgme.h (struct _gpgme_signature): Add member CHAIN_MODEL. * verify.c (parse_trust): Set Chain_MODEL. 2007-08-02 Werner Koch * w32-glib-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS flag. * w32-io.c (_gpgme_io_spawn): Ditto. (_gpgme_io_write): Map ERROR_NO_DATA to EPIPE. * debug.c (_gpgme_debug): Enable assuan logging. (_gpgme_debug_subsystem_init): New. * version.c (do_subsystem_inits): Disable assuan logging and initialize de debug system. (gpgme_check_version): Do not trace before the subsystems are initialized. 2007-07-17 Marcus Brinkmann * debug.c: Include and "debug.h". (_gpgme_debug): Save and restore ERRNO. (TOHEX): New macro. (_gpgme_debug_buffer): New function. * conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c, gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c, w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In most of these files, add many more tracepoints. 2007-07-16 Marcus Brinkmann * engine-gpgsm.c (status_handler): Do not send BYE here. * w32-io.c (struct reader_context_s, struct writer_context_s): New members REFCOUNT. (create_reader, create_writer): Initialize C->refcount to 1. (destroy_reader, destroy_writer): Only destroy if C->refcount drops to 0. (find_reader, find_writer, kill_reader, kill_writer): Beautify. * priv-io.h (_gpgme_io_dup): New prototype. * posix-io.c (_gpgme_io_dup): New function. * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Reverting to version 2007-07-10. 2007-07-13 Marcus Brinkmann * data-user.c (user_read, user_write, user_seek): Set errno and return -1 instead returning the error code directly. * data-compat.c (old_user_seek): Likewise. * gpgme.c (gpgme_sig_notation_add): Return error properly. * Revert the "close_notify_handler" returns int stuff. Always close in the _gpgme_io_close implementations. * engine-gpgsm.c (status_handler): Try to terminate the connection in case of error. * w32-io.c (_gpgme_io_read): Return C->error_code in ERRNO. (_gpgme_io_write): Likewise. * priv-io.h (_gpgme_io_set_close_notify): Change type of HANDLER to _gpgme_close_notify_handler. (_gpgme_close_notify_handler): New type. (_gpgme_io_dup): Remove prototype. * posix-io.c (notify_table, _gpgme_io_set_close_notify): Change type of HANDLER to _gpgme_close_notify_handler_t. (_gpgme_io_close): Do not close the FD if handler returns 0. (_gpgme_io_dup): Remove function. * w32-io.c (notify_table, _gpgme_io_set_close_notify, _gpgme_io_close): Change type of HANDLER to _gpgme_close_notify_handler_t. (_gpgme_io_close): Do not close the FD if handler returns 0. (_gpgme_io_dup): Remove function. * w32-glib-io.c (_gpgme_io_dup): Remove function. (_gpgme_io_set_close_notify, notify_table): Change type of HANDLER to _gpgme_close_notify_handler_t. (_gpgme_io_close): Do not close the FD if handler returns 0. * rungpg.c (close_notify_handler): Change return type to int, return 1. * engine-gpgsm.c (close_notify_handler): Change return type to int, return 0 for status FD and 1 for all other FDs. (start): Do not duplicate the status FD. 2007-07-12 Marcus Brinkmann * Makefile.am: Replace implicite rule by suffix rule. Add SUFFIXES for that. 2007-07-12 Werner Koch * version.c (do_subsystem_inits) [W32]: Make sure that the socket system has been started. 2007-07-10 Marcus Brinkmann * priv-io.h (_gpgme_io_dup): New prototype. * posix-io.c (_gpgme_io_dup): New function. * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup(). 2007-07-08 Marcus Brinkmann * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. * funopen.c (funopen): Rename to _gpgme_funopen. 2007-04-30 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Fix error handling for ttyname_r. * rungpg.c (gpg_new): Likewise. Submitted by Stephen Tether. 2007-02-26 Werner Koch * verify.c (op_data_t): New element PLAINTEXT_SEEN. (_gpgme_verify_status_handler): Return an error if more than one plaintext has been seen. (parse_error): New arg SET_STATUS. Also detect it based on an ERROR status (gpg > 1.4.6). 2007-01-26 Werner Koch * w32-io.c (build_commandline): Fixed stupid quoting bug. * w32-glib-io.c (build_commandline): Ditto. * rungpg.c (gpg_set_locale): Avoid dangling pointer after free. * gpgme-config.in: New options --get-gpg and --get-gpgsm. 2007-01-18 Marcus Brinkmann * data.h (_gpgme_data_get_fd): Add prototype. (gpgme_data_get_fd_cb): New type. (struct _gpgme_data_cbs): New member get_fd. * data.c (_gpgme_data_get_fd): New function. * data-fd.c (fd_get_fd): New function. (fd_cbs): Add fd_get_fd. * data-stream.c (stream_get_fd): New function. (stream_cbs): Add stream_get_fd. * data-mem.c (mem_cbs): Add NULL for get_fd callback. * data-user.c (user_cbs): Likewise. * engine-gpgsm.c (gpgsm_set_fd) [USE_DESCRIPTOR_PASSING]: Try to short-cut by passing the data descriptor directly. 2007-01-17 Marcus Brinkmann * w32-io.c (build_commandline): Quote all command line arguments. * w32-glib-io.c (build_commandline): Likewise. 2007-01-10 Werner Koch * ttyname_r.c (ttyname_r) [W32]: Return a dummy name. 2007-01-08 Werner Koch * version.c (do_subsystem_inits): Do assuan init only if building with Assuan. * setenv.c: Include assuan-def.h only if building with Assuan support. * op-support.c (_gpgme_op_reset): Set LC_MESSAGES only if if defined. * engine-gpgsm.c (gpgsm_set_locale): Ditto. * rungpg.c (gpg_set_locale): Ditto. 2006-12-17 Marcus Brinkmann * gpgme.c (gpgme_set_protocol): Shut down the engine when switching protocols. (gpgme_ctx_set_engine_info): Likewise for engine info. * engine.h (_gpgme_engine_reset): New function prototype. * engine.c (_gpgme_engine_reset): New function. * engine-backend.h (struct engine_ops): New member RESET. * rungpg.c (_gpgme_engine_ops_gpg): Add NULL for reset function. * engine-gpgsm.c (_gpgme_engine_ops_gpgsm) [USE_DESCRIPTOR_PASSING]: Add gpgsm_reset for reset. (_gpgme_engine_ops_gpgsm) [!USE_DESCRIPTOR_PASSING]: Add NULL for reset function. (gpgsm_reset) [USE_DESCRIPTOR_PASSING]: New function. * op-support.c (_gpgme_op_reset): Try to use the engine's reset function if available. * engine-gpgsm.c (gpgsm_new): Move code to dup status_fd to ... (start): ... here. * posix-io.c (_gpgme_io_recvmsg, _gpgme_io_sendmsg): New functions. * engine.h (_gpgme_engine_new): Remove arguments lc_ctype and lc_messages from prototype. (_gpgme_engine_set_locale): New prototype. * engine.c (_gpgme_engine_set_locale): New function. * op-support.c (_gpgme_op_reset): Call _gpgme_engine_set_locale. * engine-backend.h (struct engine_ops): Add new member SET_LOCALE. Remove arguments lc_messages and lc_ctype from member NEW. * engine-gpgsm.c (struct engine_gpgsm): New members lc_ctype_set and lc_messages_set. (gpgsm_new): Remove lc_messages and lc_ctype arguments. (gpgsm_set_locale): New function. (_gpgme_engine_ops_gpgsm): Add gpgsm_set_locale. * rungpg.c (struct engine_gpg): Add new members lc_messages and lc_ctype. (gpg_release): Release lc_messages and lc_ctype if set. (gpg_new): Remove lc_messages and lc_ctype arguments. (gpg_set_locale): New function. (_gpgme_engine_ops_gpg): Add gpg_set_locale. (add_arg): Implement in terms of: (add_arg_ext): New function. (start): Set lc-messages and lc-ctype arguments here. 2006-12-03 Marcus Brinkmann * engine-gpgsm.c (struct engine_gpgsm): Move members input_fd_server, output_fd_server, message_fd_server to ... (iocb_data): ... here (as server_fd). (close_notify_handler): Reset tags as well. (gpgsm_new): Implement support for descriptor passing. (fd_type_t): New type. (gpgsm_clear_fd): New function. Use it instead of _gpgsm_io_close for unused communication channels. (gpgsm_set_fd): Rewritten to support descriptor passing. All relevant callers adjusted as well (previously of _gpgme_io_close). 2006-12-02 Marcus Brinkmann * version.c: Include "assuan.h". (do_subsystem_inits): Call assuan_set_assuan_err_source. 2006-12-01 Marcus Brinkmann * Makefile.am (libgpgme_real_la_SOURCES): Rename to main_sources. (libgpgme_la_SOURCES, libgpgme_pthread_la_SOURCES, libgpgme_glib_la_SOURCES, libgpgme_pth_la_SOURCES): Add $(main_sources). (libgpgme_la_DEPENDENCIES, libgpgme_la_LIBADD, libgpgme_pthread_la_DEPENDENCIES, libgpgme_pthread_la_LIBADD, libgpgme_pth_la_DEPENDENCIES, libgpgme_pth_la_LIBADD, libgpgme_glib_la_DEPENDENCIES, libgpgme_glib_la_LIBADD): Remove libgpgme-real.la. (noinst_LTLIBRARIES): Removed. (libgpgme_glib_la_CFLAGS, libgpgme_pth_la_CFLAGS): Removed. (AM_CFLAGS): New variable. 2006-11-30 Marcus Brinkmann * engine-gpgsm.c: Replace AssuanError with gpg_error_t and ASSUAN_CONTEXT with assuan_context_t. 2006-11-29 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Check return value of assuan_pipe_connect. * rungpg.c: Include . (gpg_new): Support --display, --ttyname, --ttytype, --lc-ctype and --lc-messages. Fixes issue 734. 2006-10-24 Marcus Brinkmann * trustlist.c (gpgme_op_trustlist_next): Return error if OPD is NULL. 2006-10-23 Marcus Brinkmann * wait-global.c (gpgme_wait): Unlock CTX_LIST_LOCK while calling _gpgme_engine_io_event(). * keylist.c (gpgme_op_keylist_next): Return error if OPD is NULL. 2006-09-25 Marcus Brinkmann * data-mem.c (gpgme_data_release_and_get_mem): Release the data object properly. 2006-09-22 Marcus Brinkmann * keylist.c (keylist_colon_handler): Move debug output after initialising KEY. 2006-07-29 Marcus Brinkmann * gpgme-config.in (Options): Add NETLIBS. * Makefile.am (libgpgme_la_LIBADD, libgpgme_pthread_la_LIBADD, libgpgme_pth_la_LIBADD, libgpgme_glib_la_LIBADD): Add NETLIBS. * rungpg.c (read_status): Fix comparison disguising as an assignment. 2005-03-24 Marcus Brinkmann * gpgme.c (gpgme_set_locale): Remove conditional on HAVE_W32_SYSTEM, and just check for LC_MESSAGES. 2006-07-16 Marcus Brinkmann * rungpg.c (read_status): Strip potential carriage return. * genkey.c (get_key_parameter): Skip potential carriage return. * version.c (_gpgme_get_program_version): Strip potential carriage return. * data.c (gpgme_data_set_file_name): Allow to clear the file name by passing NULL. 2006-06-22 Marcus Brinkmann * keylist.c (gpgme_get_key): Also clone the engine info. 2006-03-06 Marcus Brinkmann * gpgme-config.in (cflags_pth): Revert accidential removal of pthread support with last change. 2006-02-28 Marcus Brinkmann * w32-glib-io.c (O_BINARY) [!O_BINARY]: New macro. (_gpgme_io_pipe): Open pipes in binary mode. 2006-02-22 Marcus Brinkmann * engine.c (gpgme_engine_check_version): Reimplemented to allow checking the version correctly even after changing the engine information. Bug reported by Stéphane Corthésy. * rungpg.c (read_colon_line): Invoke colon preprocess handler if it is set. (colon_preprocessor_t): New type. (struct engine_gpg): New member colon.preprocess_fnc. (gpg_keylist_preprocess): New function. * keylist.c (keylist_colon_handler): Allow short key IDs. 2006-02-15 Marcus Brinkmann * w32-io.c (create_writer): Make C->have_data a manually resetted event. (writer): Move code from end of if block to beginning, so it is also run the first time. (_gpgme_io_write): Move assert check after error check. Reset the is_empty event, and also do it eagerly. (_gpgme_io_select): Unconditionally wait for the is_empty event. 2006-01-26 Werner Koch * w32-util.c (_gpgme_get_conf_int): New. * posix-util.c (_gpgme_get_conf_int): New. * w32-io.c (get_desired_thread_priority): New. (create_reader, create_writer): Use it here. 2006-01-04 Werner Koch * debug.h (_gpgme_debug_srcname): New. Use it with the debug macros. * w32-glib-io.c (_gpgme_io_set_nonblocking): Add debug statements. Disable error return for failed nonblocking call. 2006-01-03 Marcus Brinkmann * w32-glib-io.c (_gpgme_io_close): Only close fd if there is no channel for it. 2005-12-31 Marcus Brinkmann * w32-glib-io.c (find_channel): Set channel to unbuffered. (_gpgme_io_select): Fix debug output. 2005-12-23 Werner Koch * gpgme.h (struct _gpgme_signature): Append field PKA_ADDRESS. * verify.c (release_op_data, _gpgme_verify_status_handler): Set this field. 2005-12-20 Werner Koch * gpgme.h (gpgme_status_code_t): Added GPGME_STATUS_PKA_TRUST_BAD and GPGME_STATUS_PKA_TRUST_GOOD. (struct _gpgme_signature): New field pka_trust. * verify.c (_gpgme_verify_status_handler): Set pka_trust. 2005-12-06 Werner Koch * keylist.c (keylist_colon_handler): Store fingerprints of the subkeys. Reset the secret flag of subkeys for stub secret keys. (NR_FIELDS): Bumped up to 16 2005-11-27 Marcus Brinkmann * engine.c (_gpgme_set_engine_info): Use new_file_name in engine_get_version invocation. Reported by Stéphane Corthésy. 2005-11-24 Marcus Brinkmann * w32-glib-io.c (_gpgme_io_fd2str): Remove debug printf. 2005-11-18 Werner Koch * w32-glib-io.c: Include glib.h before windows to avoid a symbol shadowing warning. (find_channel): Better use g_io_channel_win32_new_fd instead of the autodetection function g_io_channel_unix_new. (_gpgme_io_select): Rewritten. It is now a fully working select implementation. 2005-11-18 Marcus Brinkmann * priv-io.h (_gpgme_io_fd2str): New prototype. * posix-io.c (_gpgme_io_fd2str): New function. * w32-io.c (_gpgme_io_fd2str): New function. * rungpg.c: Use this new function. * w32-glib-io.c (_gpgme_io_fd2str): Rewrote the file handle code again. Two's company, three's the musketeers. * w32-glib-io.c: Rewrote the file handle code. We don't create system fds for every handle (doesn't work for inherited handles), but we create pseudo fds in a private namespace that designate a handle and potentially a giochannel. 2005-11-18 Werner Koch * versioninfo.rc.in: Set file version to LT-version + Svn-revision. 2005-11-17 Marcus Brinkmann * w32-glib-io.c: New file. * gpgme.def (gpgme_get_giochannel): Add symbol. * Makefile.am (system_components) [HAVE_DOSISH_SYSTEM]: Remove w32-io.c. (ltlib_gpgme_extra): New variable. (lib_LTLIBRARIES): Add $(ltlib_gpgme_extra). (system_components_not_extra): New variable. (libgpgme_la_SOURCES, libgpgme_pthread_la_SOURCES, (libgpgme_pth_la_SOURCES): Add $(system_components_not_extra). (libgpgme_glib_la_LDFLAGS, libgpgme_glib_la_DEPENDENCIES, (libgpgme_glib_la_LIBADD, libgpgme_glib_la_CFLAGS) [BUILD_W32_GLIB]: New variables. * gpgme-config.in (glib): New option. * gpgme.m4 (AM_PATH_GPGME_GLIB): New macro. 2005-11-17 Marcus Brinkmann * priv-io.h (_gpgme_io_waitpid, _gpgme_io_kill): Removed. * w32-io.c (_gpgme_io_waitpid, _gpgme_io_kill): Removed. * posix-io.c (_gpgme_io_kill): Removed. (_gpgme_io_waitpid): Declare static. 2005-10-24 Marcus Brinkmann * w32-io.c (_gpgme_io_spawn): Don't minimize window, hide it. 2005-10-21 Werner Koch * Makefile.am: Fixed cut+paste problem 2005-10-20 Marcus Brinkmann * Makefile.am: Build versioninfo.lo, not versioninfo.o. Also, fix the whole mess. 2005-10-16 Marcus Brinkmann * rungpg.c (gpg_edit): Don't add a key argument if in card edit mode. 2005-10-06 Marcus Brinkmann * Makefile.am (gpgme.dll gpgme.dll.a): Use $(srcdir) for gpgme.def. * gpgme.h (gpgme_free): New prototype. * data-mem.c (gpgme_free): New function. * libgpgme.vers (GPGME_1.1): Add gpgme_free. * gpgme.def: Add gpgme_free. 2005-10-02 Marcus Brinkmann * util.h (_gpgme_decode_percent_string): Add new argument BINARY to prototype. * verify.c (parse_notation): Likewise for invocation. * conversion.c (_gpgme_decode_percent_string): Likewise to declaration. If set, do not replace '\0' characters with a printable string. * gpgme.h (struct _gpgme_key_sig): New field notations. * ops.h (_gpgme_parse_notation): New prototype. * sig-notation.c (_gpgme_parse_notation): New function. * key.c (gpgme_key_unref): Free all signature notations. * keylist.c (op_data_t): New member tmp_keysig. (finish_key): Clear OPD->tmp_keysig. * gpgme.c (gpgme_set_keylist_mode): Remove check. * rungpg.c (gpg_keylist): Support listing signature notations. (gpg_keylist_ext): Likewise. 2005-10-01 Marcus Brinkmann * engine.h (_gpgme_set_engine_info): Add prototype. * engine-backend.h (struct engine_ops): Change return type of get_file_name() to const char * to silence gcc warning. * engine.c (engine_get_file_name): Change return type to const char * to silence gcc warning. (gpgme_get_engine_info): Use transitional variable to go from const char * to char * to silence gcc warning. (_gpgme_set_engine_info): Likewise. * engine-gpgsm.c (struct engine_gpgsm): Change type of LINE to char * to silence gcc warning. (gpgsm_new): Make ARGV a pointer to const char. (status_handler): Change type of SRC, END, DST, ALINE and NEWLINE to char * to silence gcc warning. * gpgme.def: Add gpgme_data_set_file_name, gpgme_data_get_file_name, gpgme_sig_notation_clear, gpgme_sig_notation_add and gpgme_sig_notation_get. * libgpgme.vers: Add gpgme_sig_notation_clear, gpgme_sig_notation_add and gpgme_sig_notation_get. * Makefile.am (libgpgme_real_la_SOURCES): Add sig-notation.c. * context.h (struct gpgme_context): New field sig_notations. * gpgme.h (struct _gpgme_sig_notation): New member value_len and critical. (GPGME_SIG_NOTATION_CRITICAL): New symbol. (gpgme_sig_notation_flags_t): New type. (gpgme_sig_notation_add, gpgme_sig_notation_clear, gpgme_sig_notation_get): New prototypes. * ops.h (_gpgme_sig_notation_create, _gpgme_sig_notation_free): New prototypes. * sig-notation.c (_gpgme_sig_notation_free): New file. * verify.c (parse_notation): Use support functions. (release_op_data): Likewise. * rungpg.c (append_args_from_sig_notations): New function. (gpg_encrypt_sign, gpg_sign): Call it. 2005-09-30 Marcus Brinkmann * data.h (struct gpgme_data): New member file_name. * data.c (gpgme_data_set_filename): New function. (_gpgme_data_release): Free DH->filename if necessary. (gpgme_data_get_filename): New function. * rungpg.c (gpg_encrypt): Set filename option. (gpg_encrypt_sign): Likewise. (gpg_sign): Likewise. * libgpgme.vers (GPGME_1.1): Add gpgme_data_set_file_name and gpgme_data_get_file_name. * decrpyt.c, verify.c, gpgme.h: Replace plaintext_filename with file_name. 2005-09-29 Marcus Brinkmann * gpgme.h (struct _gpgme_key): Add field is_qualified. (struct _gpgme_subkey): Likewise. * keylist.c (set_subkey_capability, set_mainkey_capability): Set field is_qualified. 2005-09-23 Werner Koch * w32-io.c (_gpgme_io_pipe): Removed use of environment variable again. (create_reader, create_writer): Set thread priority higher. 2005-09-19 Werner Koch * w32-io.c (_gpgme_io_pipe): New environment variable to change the size of the pipe buffer. 2005-09-13 Werner Koch * ath.c: Changes to make it work under W32. 2005-09-12 Marcus Brinkmann * Makefile.am (libgpgme_la_SOURCES): Set to ath.h and ath.c. (ath_pth_src, ath_pthread_src): Removed. (w32_o_files): Replace ath-compat.o with ath.o. (libgpgme_pth_la_CFLAGS): New variable. * ath-compat.c, ath-pthread-compat.c, ath-pth-compat.c: Removed. * ath.h (ath_pthread_available, ath_pth_available): Removed. (ath_init) [!_ATH_EXT_SYM_PREFIX]: Do not define macro. (struct ath_ops, ath_init) [_ATH_COMPAT]: Removed. (_ATH_COMPAT): Macro removed. * posix-sema.c (_gpgme_sema_subsystem_init): Do not call _gpgme_ath_init. 2005-09-12 Marcus Brinkmann * keylist.c (release_op_data): Do not free opd->tmp_uid. 2005-09-07 Werner Koch * w32-io.c (build_commandline): Quote argv[0]. 2005-08-26 Marcus Brinkmann * rungpg.c (command_handler): Use _gpgme_io_write instead of write. * edit.c (command_handler): Do not depend on PROCESSED being available. * engine.h (engine_command_handler_t): Add new argument processed. * ops.h (_gpgme_passphrase_command_handler_internal): Rename prototype to ... (_gpgme_passphrase_command_handler): ... this one. * passphrase.c (_gpgme_passphrase_command_handler_internal): Rename to ... (_gpgme_passphrase_command_handler): ... this one. * edit.c (command_handler): Add new argument processed. Remove local variable with the same name. Always return processed as true. * rungpg.c (command_handler): Send a newline character if the handler did not. 2005-08-26 Werner Koch * w32-util.c (read_w32_registry_string): Updated from code used by GnuPG. This allows for expanding strings and features the implicit fallback key. (w32_shgetfolderpath, find_program_at_standard_place): New. (_gpgme_get_gpg_path, _gpgme_get_gpgsm_path): With no registry entry, locate the programs at the standard place. (dlopen, dlsym, dlclose): New, so that we can keep on using what we are accustomed to. * debug.c (debug_init): Use PATHSEP_C so that under W32 a semicolon is used which allows us to create files with drive letters. * w32-io.c (_gpgme_io_read, _gpgme_io_write): Print content in debug mode too. 2005-08-19 Werner Koch * gpgme.def: New. * versioninfo.rc.in: New. * Makefile.am: Addes support for building a W32 DLL. * ttyname_r.c (ttyname_r) [W32]: Return error. * ath-compat.c [W32]: select and co are not yet supported; return error. * data-stream.c (stream_seek): Use ftell if ftello is not available. 2005-08-08 Werner Koch * util.h (stpcpy): Renamed to .. (_gpgme_stpcpy): .. this and made inline. This avoids duplicate definitions when linking statically. * stpcpy.c: Removed. 2005-07-27 Marcus Brinkmann * gpgme.h (gpgme_status_code_t): Add GPGME_STATUS_PLAINTEXT. (struct _gpgme_op_decrypt_result): New member plaintext_filename. (struct _gpgme_op_verify_result): Likewise. * ops.h (_gpgme_parse_plaintext): Add prototype. * op-support.c (_gpgme_parse_plaintext): New function. * decrypt.c (release_op_data): Release OPD->result.plaintext_filename. (_gpgme_decrypt_status_handler): Handle GPGME_STATUS_PLAINTEXT. * verify.c (release_op_data): Release OPD->result.plaintext_filename. (_gpgme_verify_status_handler): Handle GPGME_STATUS_PLAINTEXT. 2005-07-26 Marcus Brinkmann * keylist.c (gpgme_get_key): Allow key IDs. 2005-06-20 Marcus Brinkmann * gpgme.m4: Only call GPGME_CONFIG if found. 2005-06-03 Marcus Brinkmann * gpgme.h (struct _gpgme_signature): New members pubkey_algo and hash_algo. * verify.c (parse_valid_sig): Parse pubkey and hash algo numbers. (parse_new_sig): Parse pubkey, hash algo and timestamp for ERRSIG. (_gpgme_decrypt_status_handler): Fix last change. * gpgme.h (struct _gpgme_recipient): New structure. (gpgme_recipient_t): New type. (struct _gpgme_op_decrypt_result): Add member recipients. * decrypt.c (op_data_t): New member last_recipient_p. (_gpgme_op_decrypt_init_result): Initialize last_recipient_p. (parse_enc_to): New function. (_gpgme_decrypt_status_handler): Handle status ENC_TO and NO_SECKEY. * wait-global.c (gpgme_wait): Break out of the fd processing loop after an error. Reported by Igor Belyi . 2005-06-02 Marcus Brinkmann * wait.h (_gpgme_run_io_cb): New prototype. * wait.c (_gpgme_run_io_cb): New function. * wait-global.c (gpgme_wait): Call it. * wait-user.c (_gpgme_user_io_cb_handler): Likewise. * wait-private.c (_gpgme_wait_on_condition): Likewise. 2005-06-02 Werner Koch * passphrase.c (_gpgme_passphrase_status_handler): Take care of GPGME_STATUS_NEED_PASSPHRASE_PIN. (_gpgme_passphrase_command_handler_internal): Also act on the key "passphrase.pin.ask". * gpgme.h: Added status codes GPGME_STATUS_SIG_SUBPACKET, GPGME_STATUS_NEED_PASSPHRASE_PIN, GPGME_STATUS_SC_OP_FAILURE, GPGME_STATUS_SC_OP_SUCCESS, GPGME_STATUS_CARDCTRL, GPGME_STATUS_BACKUP_KEY_CREATED. 2005-05-28 Marcus Brinkmann * data-user.c: Include . 2005-05-17 Marcus Brinkmann * gpgme.c (gpgme_new): Set the CTX->include_certs default to the default. 2005-05-11 Marcus Brinkmann * w32-io.c (_gpgme_io_select): Fix loop increment. 2005-05-05 Marcus Brinkmann * data-user.c (user_release): Only call user hook if provided. (user_seek): Return EBADF if no user hook is provided. (user_read): Likewise. (user_write): Likewise. 2005-04-28 Marcus Brinkmann * gpgme.h (GPGME_INCLUDE_CERTS_DEFAULT): New macro. * engine-gpgsm.c (gpgsm_sign): Send the include-certs option after the reset, just for cleanliness, and do not sent it at all if the default is requested. * gpgme.c (gpgme_set_include_certs): Allow to use GPGME_INCLUDE_CERTS_DEFAULT. 2005-04-21 Werner Koch * verify.c (calc_sig_summary): Set the key revoked bit. 2005-04-14 Marcus Brinkmann * wait-global.c (gpgme_wait): Use LI->ctx when checking a context in the list, not the user-provided CTX. Reported by Igor Belyi . * wait-global.c (gpgme_wait): If no context is found, and we should not hang, set *status to 0 and return NULL. Reported by Igor Belyi . 2005-03-24 Marcus Brinkmann * data.h (EOPNOTSUPP) [_WIN32]: Remove definition. * data.c (EOPNOTSUPP) [HAVE_W32_SYSTEM]: Remove definition. (gpgme_data_read, gpgme_data_write, gpgme_data_seek): Return ENOSYS instead EOPNOTSUPP. * data-compat.c (EOPNOTSUPP) [HAVE_W32_SYSTEM]: Remove definition. (gpgme_error_to_errno): Map GPG_ERR_NOT_SUPPORTED to ENOSYS. 2005-03-24 Marcus Brinkmann * io.h: Rename to ... * priv-io.h: ... this. * Makefile.am (libgpgme_real_la_SOURCES): Change io.h to priv-io.h. * data.c, engine-gpgsm.c, posix-io.c, rungpg.c, version.c, w32-io.c, wait-private.c, wait-global.c, wait-user.c, wait.c: Change all includes of "io.h" to "priv-io.h" 2005-03-09 Werner Koch * w32-util.c (_gpgme_get_gpg_path, _gpgme_get_gpgsm_path): Do not cast away type checks. * io.h [W32]: Do not include stdio.h. If it is needed do it at the right place. * data.h [W32]: Removed kludge for EOPNOTSUP. * data.c, data-compat.c [W32]: Explicitly test for it here. Replaced use of _WIN32 by HAVE_W32_SYSTEM except for public header files. 2005-03-07 Timo Schulz * gpgme.h: [_WIN32] Removed ssize_t typedef. * ath.h: [_WIN32] Added some (dummy) types. * io.h: [_WIN32] include stdio.h. * data.h: [_WIN32] Define EOPNOTSUPP. * w32-io.c [_WIN32] (_gpgme_io_subsystem_init): New. * gpgme.c [_WIN32] (gpgme_set_locale): Disabled. 2004-12-12 Marcus Brinkmann * engine.c (_gpgme_set_engine_info): Fix assertion. 2004-12-11 Marcus Brinkmann * util.h [HAVE_CONFIG_H && HAVE_TTYNAME_R] (ttyname_r): Define prototype. * ttyname_r.c: New file. 2004-12-07 Marcus Brinkmann * putc_unlocked.c, funopen.c: I just claim copyright on these files and change their license to LGPL, because they are totally trivial wrapper functions. * isascii.c: Change copyright notice to the one from ctype/ctype.h in the GNU C Library (CVS Head 2004-10-10), where isascii is defined as a macro doing exactly the same as the function in this file. * memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06). * stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10). * ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c, ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c, data.c, data-compat.c, data-fd.c, data.h, data-mem.c, data-stream.c, data-user.c, debug.c, debug.h, decrypt.c, decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c, engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c, export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h, key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c, passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c, rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c, util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c, wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change license to LGPL. 2004-12-07 Marcus Brinkmann * libgpgme.vers (GPGME_1.1): New version. * engine-backend.h (struct engine_ops): Add argument FILE_NAME to member get_version(). Add arguments FILE_NAME and HOME_DIR to member new(). Change return type of get_file_name and get_version to char *. * engine-gpgsm.c (gpgsm_get_version): Change return type to char pointer. Do not cache result. (gpgsm_new): Add file_name and home_dir argument, and use them instead of the defaults, if set. * rungpg.c (struct engine_gpg): New member file_name. (gpg_get_version): Change return type to char pointer, and do not cache result. (gpg_release): Free gpg->file_name. (gpg_new): Take new arguments file_name and home_dir. Set the --homedir argument if HOME_DIR is not NULL. Set gpg->file_name. (start): Use gpg->file_name instead _gpgme_get_gpg_path, if set. * engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release): New prototypes. (_gpgme_engine_new): Change first argument to gpgme_engine_info_t info. * engine.c: Include . (gpgme_get_engine_info): Set *INFO within the lock. Move ENGINE_INFO and ENGINE_INFO_LOCK to .... (engine_info, engine_info_lock): ... here. New static variables. (engine_get_version): Add file_name argument to get_version invocation. Change return type to char pointer. (gpgme_engine_check_version): Rewritten to free() the return value of engine_get_version after using it. (_gpgme_engine_info_release): New function. (gpgme_get_engine_info): Rewritten. (_gpgme_engine_info_copy): New function. (_gpgme_set_engine_info): New function. (gpgme_set_engine_info): New function. (_gpgme_engine_new): Change first argument to gpgme_engine_info_t info, and use that. * gpgme.h (struct _gpgme_engine_info): Change type of file_name and version to char * (remove the const). New member home_dir. (gpgme_set_engine_info, gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New prototypes. * context.h (struct gpgme_context): New member engine_info. * gpgme.c (gpgme_new): Allocate CTX->engine_info. (gpgme_release): Deallocate CTX->engine_info. (gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New functions. * op-support.c (_gpgme_op_reset): Look for correct engine info and pass it to _gpgme_engine_new. * version.c (gpgme_check_version): Adjust to _gpgme_compare_versions returning an int. (_gpgme_compare_versions): Return an int value, not a const char pointer. * ops.h (_gpgme_compare_versions): Same for prototype. 2004-10-03 Marcus Brinkmann * verify.c (parse_trust): If no reason is provided, set SIG->validity_reason to 0. (calc_sig_summary): Set GPGME_SIGSUM_CRL_TOO_OLD if appropriate. 2004-10-22 Marcus Brinkmann * engine-gpgsm.c (map_assuan_error): Return 0 if ERR is 0. (start): Call map_assuan_error on return value of assuan_write_line. 2004-10-05 Marcus Brinkmann * op-support.c (_gpgme_op_data_lookup): Use char pointer for pointer arithmetic. 2004-09-30 Marcus Brinkmann * gpgme.m4: Implement the --api-version check. * rungpg.c (read_status): Move the polling of the output data pipe to just before removing the command fd, from just before adding it. This avoids buffering problems. * data.c (_gpgme_data_inbound_handler): Use _gpgme_io_read, not read, to improve debug output. 2004-09-29 Marcus Brinkmann * gpgme.h (GPGME_IMPORT_NEW, GPGME_IMPORT_UID, GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_SECRET, (GPGME_KEYLIST_MODE_LOCAL, GPGME_KEYLIST_MODERN_EXTERN, GPGME_KEYLIST_MODE_SIGS, GPGME_KEYLIST_MODE_VALIDATE): Change from enum to macros. (gpgme_keylist_mode_t): Define as unsigned int. (gpgme_key_t): Change type of keylist_mode to gpgme_keylist_mode_t. 2004-09-23 Marcus Brinkmann * data.c (_gpgme_data_outbound_handler): Close the file descriptor if we get an EPIPE. * data-stream.c (stream_seek): Call ftello and return the current offset. * data.h (struct gpgme_data): Change type of data.mem.offset to off_t. * data.c (gpgme_data_seek): Check dh->cbs->seek callback, not read callback. If SEEK_CUR, adjust the offset by the pending buffer size. Clear pending buffer on success. 2004-09-14 Marcus Brinkmann * gpgme.m4: Add copyright notice. 2004-08-18 Marcus Brinkmann * passphrase.c (_gpgme_passphrase_status_handler): Always run the status handler. 2004-08-17 Marcus Brinkmann * rungpg.c (build_argv): Use --no-sk-comment, not --no-comment. 2004-06-23 Marcus Brinkmann * key.c (_gpgme_key_append_name): Make sure tail points to the byte following the uid. (_gpgme_key_add_sig): Likewise. Don't use calloc, but malloc and memset. 2004-06-02 Marcus Brinkmann * libgpgme.vers: Remove C-style comment, which is not supported by older binutils. 2004-05-21 Marcus Brinkmann * gpgme-config.in (Options): Support --api-version. * libgpgme.vers: List all gpgme symbols under version GPGME_1.0. * decrypt.c (_gpgme_decrypt_status_handler): Fix last change. * verify.c (parse_error): Likewise. * verify.c (parse_error): Do not skip location of where token. * gpgme.h (gpgme_status_code_t): Add GPGME_STATUS_REVKEYSIG. * verify.c (_gpgme_verify_status_handler): Add handling of GPGME_STATUS_REVKEYSIG. (parse_trust): Likewise. 2004-05-21 Marcus Brinkmann * gpgme.h (struct _gpgme_decrypt_result): New fields wrong_key_usage and _unused. * decrypt.c (_gpgme_decrypt_status_handler): Don't skip over character after a matched string, as in a protocol error this could skip over the trailing binary zero. Handle decrypt.keyusage error notifications. * gpgme.h (struct _gpgme_key): New member keylist_mode. * keylist.c (keylist_colon_handler): Set the keylist_mode of KEY. 2004-04-29 Marcus Brinkmann * gpgme.h (struct _gpgme_signature): Change member WRONG_KEY_USAGE to unsigned int. Same for member _unused. * keylist.c (set_mainkey_trust_info): Rewritten. (set_subkey_capability): Handle 'd' (disabled). (set_mainkey_capability): Rewritten. 2004-04-22 Marcus Brinkmann * gpgme.m4: Quote first argument to AC_DEFUN. 2004-04-21 Werner Koch * key.c (gpgme_key_unref): Allow passing NULL like free does. The rule of least surprise. 2004-04-15 Werner Koch * verify.c (prepare_new_sig, _gpgme_verify_status_handler): Remove unused result.signatures items. * keylist.c (gpgme_get_key): Return an error if FPR is NULL. 2004-04-08 Werner Koch * verify.c (_gpgme_verify_status_handler): Ignore the error status if we can't process it. * decrypt-verify.c (decrypt_verify_status_handler): Backed out yesterday's hack. It is not any longer required. 2004-04-07 Werner Koch * decrypt-verify.c (decrypt_verify_status_handler): Hack to cope with meaningless error codes from the verify status function. 2004-04-05 Werner Koch * gpgme.h: Add GPGME_STATUS_NEWSIG. * verify.c (parse_error): Compare only the last part of the where token. (prepare_new_sig): New. (parse_new_sig): Use prepare_new_sig when required. (_gpgme_verify_status_handler): Handle STATUS_NEWSIG. * engine-gpgsm.c (gpgsm_keylist_ext): Send with-validation option. Fixed pattern construction. (status_handler): Add debugging output. 2004-03-23 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Protect _only_ tty related code with isatty(). Submitted by Bernhard Herzog. 2004-03-11 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Protect all tty related code with isatty(). * rungpg.c (gpg_cancel): Set GPG->fd_data_map to NULL after releasing it. * engine-gpgsm.c (gpgsm_cancel): Only call assuan_disconnect if GPGSM->assuan_ctx is not NULL. Set it to NULL afterwards. 2004-03-07 Marcus Brinkmann * gpgme-config.in: Do not emit include and lib directory for prefix "/usr" or "". 2004-03-03 Werner Koch * engine-gpgsm.c (gpgsm_export_ext): Properly insert a space beween patterns. 2004-02-18 Werner Koch * gpgme-config.in: Ignore setting of --prefix. 2004-02-25 Marcus Brinkmann * rungpg.c (gpg_cancel): New function. (gpg_release): Call it here. (_gpgme_engine_ops_gpg): Add it here. * engine-gpgsm.c (gpgsm_cancel): Fix last change. 2004-02-24 Marcus Brinkmann * gpgme.c (gpgme_cancel): New function. * engine-backend.h (struct engine_ops): New member cancel. * engine.h (_gpgme_engine_cancel): New prototype. * engine.c (_gpgme_engine_cancel): New function. * engine-gpgsm.c (_gpgme_engine_ops_gpgsm): Add new member cancel. (gpgsm_cancel): New function. (gpgsm_release): Use it. * rungpg.c (_gpgme_engine_ops_gpg): Add new member cancel. 2004-02-17 Werner Koch * gpgme.h: Add GPGME_KEYLIST_MODE_VALIDATE. * engine-gpgsm.c (gpgsm_keylist): Send this to gpgsm. 2004-02-15 Werner Koch * memrchr.c (memrchr): Fixed implementation. Problem pointed out by Adriaan de Groot. 2004-02-01 Marcus Brinkmann * rungpg.c (build_argv): Use --no-comment, not --comment "". * data-compat.c (gpgme_data_new_from_filepart): Call fseeko if available. * data-stream.c (stream_seek): Likewise. 2004-01-16 Werner Koch * conversion.c (_gpgme_map_gnupg_error): Handle numerical codes as used by GnuPG 1.9.x 2004-01-13 Marcus Brinkmann * gpgme.h (struct _gpgme_key_sig): Fix comment on REVOKED. 2004-01-12 Werner Koch * sign.c: Include util.h for prototype of _gpgme_parse_timestamp. 2003-12-25 Marcus Brinkmann * gpgme.h (_GPGME_D_CLASS): Revert this change. (struct _gpgme_key_sig): For C++ compilers, rename class member to _obsolete_class. Add new member sig_class. (struct _gpgme_new_signature): Same here. * key.c (gpgme_key_sig_get_ulong_attr): Use CERTSIG->sig_class, not CERTSIG->class. * keylist.c (keylist_colon_handler): Likewise for KEYSIG, but keep setting KEYSIG->class, too. Rename variable CLASS to SIG_CLASS. * sign.c (parse_sig_created): Set SIG->sig_class. 2003-12-22 Werner Koch * gpgme.h (_GPGME_D_CLASS): Kludge for C++ compatibility without changing the C API. 2003-11-19 Werner Koch * conversion.c (_gpgme_parse_timestamp): New. (atoi_1, atoi_2, atoi_4): New. * keylist.c (parse_timestamp): Removed. Changed all callers to use the new function. * verify.c (parse_valid_sig): Ditto. Repalced the errno check. * sign.c (parse_sig_created): Ditto. 2003-10-31 Werner Koch * keylist.c (parse_timestamp): Detect ISO 8601 timestamps and try to convert them. 2003-10-10 Marcus Brinkmann * genkey.c (get_key_parameter): Make a copy of the key parameters. Submitted by Miguel Coca . 2003-10-06 Marcus Brinkmann * data-compat.c: Include before for broken systems. * engine-gpgsm.c (map_assuan_error): If ERR is -1, return sensible error. * io.h (_gpgme_io_subsystem_init): New prototype. * posix-io.c (_gpgme_io_subsystem_init): Add function. (_gpgme_io_spawn): Do not fixup signal handler here. * version.c (do_subsystem_inits): Call _gpgme_io_subsystem_init. * debug.c (debug_init): Drop const qualifier from E. * ath.h (struct ath_ops): Make ADDR argument of CONNECT prototype const. (ath_connect): Make ADDR argument const. * ath-pthread.c (ath_connect): Likewise. * ath-pth.c (ath_connect): Likewise. * ath-compat.c (ath_connect): Likewise. * ath.c (ath_connect): Likewise. * ath.h [HAVE_SYS_SELECT_H]: Include for fd_set. [!HAVE_SYS_SELECT_H]: Include . * conversion.c (_gpgme_hextobyte): Drop "unsigned" from type of SRC argument. * util.h (_gpgme_hextobyte): Likewise for prototype. * gpgme.h: Remove trailing comma in enum. * rungpg.c: Do not include , , , , , or "unistd.h". 2003-10-02 Marcus Brinkmann * engine-backend.h (struct engine_ops): Add argument TYPE. * engine.c (_gpgme_engine_op_edit): Likewise. * engine.h: Likewise. * rungpg.c (gpg_edit): Likewise. Use it. * edit.c (edit_start): Likewise. Pass it on. (gpgme_op_edit_start, gpgme_op_edit): Likewise. (gpgme_op_card_edit_start, gpgme_op_card_edit): New functions. 2003-09-30 Marcus Brinkmann * gpgme.h (gpg_strerror_r): Change prototype to match gpg_strerror_r change. * error.c (gpg_strerror_r): Likewise, also update implementation. * gpgme.c (gpgme_hash_algo_name): Change name of RMD160 to RIPEMD160, name of TIGER to TIGER192, name of CRC32-RFC1510 to CRC32RFC1510, and name of CRC24-RFC2440 to CRC24RFC2440. 2003-09-14 Marcus Brinkmann * gpgme.h: Add prototype for gpgme_set_locale. * gpgme.h: Define macro _GPGME_INLINE depending on the compiler characteristics and use that instead __inline__. * context.h (struct gpgme_context): New members lc_ctype and lc_messages. * gpgme.c: Include . (def_lc_lock, def_lc_ctype, def_lc_messages): New static variables. (gpgme_set_locale): New function. * engine.c (_gpgme_engine_new): Add arguments lc_ctype and lc_messages. * engine.h (_gpgme_engine_new): Likewise. * engine-gpgsm.c (gpgsm_new): Likewise. * rungpg.c (gpg_new): Likewise. * engine-backend.h (struct engine_ops): Likewise to NEW. * op-support.c (_gpgme_op_reset): Likewise to invocation of _gpgme_engine_new. 2003-09-13 Marcus Brinkmann * gpgme.h (gpgme_strerror_r): New prototype. * error.c (gpgme_strerror_r): New function. * get-env.c: New file. * util.h (_gpgme_getenv): Add prototype. * Makefile.am (libgpgme_real_la_SOURCES): Add get-env.c. * rungpg.c (build_argv): Use _gpgme_getenv. * debug.c (debug_init): Likewise. * engine-gpgsm.c (gpgsm_new): Likewise. (gpgsm_new): Use ttyname_r. * w32-io.c (_gpgme_io_spawn): Disable debugging for now. 2003-09-03 Marcus Brinkmann * gpgme-config.in: Use $libdir, not @libdir@, for the echo command. * gpgme-config.in: Rewritten. * gpgme.m4: Rewritten. 2003-08-19 Marcus Brinkmann The ath files (ath.h, ath.c, ath-pth.c, ath-pthread.c, ath-compat.c, ath-pth-compat.c and ath-pthread-compat.c) have been updated to have better thread support, and the Makefile.am was changed to reflect that. * util.h [!HAVE_FOPENCOOKIE]: Remove fopencookie declaration. * engine-gpgsm.c (gpgsm_assuan_simple_command): Set ERR to return value of status_fnc. * rungpg.c (start): Return SAVED_ERRNO, not errno. 2003-08-18 Marcus Brinkmann * rungpg.c (start): Use saved_errno instead errno. 2003-08-18 Marcus Brinkmann * funopen.c, putc_unlocked.c, isascii.c, memrchr.c: New files. * fopencookie.c: File removed. 2003-08-15 Marcus Brinkmann * gpgme-config.in: Put gpg-error related flags after gpgme's. 2003-08-14 Marcus Brinkmann * gpgme.h (struct _gpgme_new_signature): Rename member CLASS to _OBSOLETE_CLASS, add member CLASS with type unsigned int. * sign.c (parse_sig_created): Also set SIG->_unused_class for backward compatibility. 2003-08-04 Marcus Brinkmann * verify.c (parse_new_sig): Fix status parsing case. 2003-07-31 Marcus Brinkmann * gpgme.h (struct _gpgme_subkey): Add flag CAN_AUTHENTICATE. Lower _UNUSED to 23 bits. (struct _gpgme_key): Likewise. * keylist.c (set_mainkey_capability): Support 'a' and 'A'. (set_subkey_capability): Support 'a'. * keylist.c (gpgme_get_key): Check if there is more than one key listed, and return GPG_ERR_AMBIGUOUS_NAME in that case. * util.h (_gpgme_decode_c_string): Change type of LEN argument to size_t. (_gpgme_decode_percent_string): Likewise. * conversion.c (_gpgme_decode_c_string): Likewise. (_gpgme_decode_percent_string): Likewise. (_gpgme_map_gnupg_error): Change type of I to unsigned int. * signers.c (gpgme_signers_clear): Likewise. (gpgme_signers_enum): New unsigned variable SEQNO, set to SEQ. Use SEQNO instead SEQ. * wait.c (fd_table_put): Change type of I and J to unsigned int. * wait-global.c (_gpgme_wait_global_event_cb): Change type of IDX to unsigned int. (gpgme_wait): Change type of I and IDX to unsigned int. * wait-private.c (_gpgme_wait_on_condition): Change type of IDX and I to unsigned int. * posix-io.c (_gpgme_io_close): Cast return value of macro DIM to int to suppress gcc warning. (_gpgme_io_set_close_notify): Likewise. (_gpgme_io_select): Change type of I to unsigned int. * engine.c (gpgme_get_engine_info): Change type of PROTO to unsigned int. * wait-user.c (_gpgme_user_io_cb_handler): Change type of IDX and I to unsigned int. 2003-07-29 Marcus Brinkmann * decrypt-verify.c (decrypt_verify_status_handler): Expand silly and wrong expression. * encrypt-sign.c (encrypt_sign_status_handler): Likewise. * encrypt.c (encrypt_sym_status_handler): Likewise. * sign.c (sign_status_handler): Likewise. * verify.c (verify_status_handler): Likewise. * decrypt.c (decrypt_status_handler): Likewise. * engine.c (gpgme_get_engine_info): Initialize NULL. 2003-07-23 Marcus Brinkmann * gpgme-config.in (gpg_error_libs): Quote GPG_ERROR_CFLAGS and GPG_ERROR_LIBS when setting the corresponding variables. Reported by Stéphane Corthésy. 2003-07-22 Marcus Brinkmann * engine-gpgsm.c (set_recipients): Move declaration of NEWLEN to the beginning of the block. 2003-06-22 Marcus Brinkmann * data-mem.c (mem_write): Copy original buffer content. 2003-06-22 Marcus Brinkmann * gpgme.h (gpgme_user_ids_release, gpgme_user_ids_append): Remove prototypes. 2003-06-06 Marcus Brinkmann * Makefile.am (AM_CPPFLAGS): Add @GPG_ERROR_CFLAGS@. * gpgme-config.in (gpg_error_libs, gpg_error_cflags): New variables. Print them. * op-support.c (_gpgme_parse_inv_userid): Rename to _gpgme_parse_inv_recp and change to new datatype. * ops.h (_gpgme_parse_inv_key): Fix prototype. * gpgme.h (struct _gpgme_invalid_user_id): Rename to __gpgme_invalid_key. Rename field ID to KEY. (gpgme_invalid_user_id_t): Rename to gpgme_invalid_key_t. (struct _gpgme_op_encrypt_result): Here, too. (struct _gpgme_op_sign_result): Likewise. * encrypt.c (struct op_data): Likewise. (release_op_data): Likewise. * sign.c (struct op_data): Likewise. (release_op_data): Likewise. * posix-io.c (_gpgme_io_read): Save errno across debug calls. (_gpgme_io_write): Likewise. (_gpgme_io_pipe): Likewise. (_gpgme_io_select): Likewise. * rungpg.c (struct engine_gpg): Remove arg_error. (add_arg): Don't set arg_error. (add_data): Likewise. (start): Don't check arg_error. (gpg_new): Check return value of add_arg. * verify.c (parse_notation): Free allocated memory at error. 2003-06-05 Marcus Brinkmann Everywhere: Use libgpg-error error codes. * Makefile.am (EXTRA_DIST): Remove mkerrors. (BUILT_SOURCES): Remove errors.c. (MOSTLYCLEANFILES): Likewise. (libgpgme_la_SOURCES): Likewise. Add error.c. (errors.c): Remove target. * mkerrors: File removed. * error.c: New file. * gpgme.h (gpgme_error_t): Change to type gpg_error_t. (gpgme_err_code_t, gpgme_err_source_t): New types. (gpgme_err_code, gpgme_err_source, gpgme_error, gpgme_err_make): New static inline functions. (gpgme_strsource, gpgme_err_code_from_errno, gpgme_err_code_to_errno, gpgme_err_make_from_errno, gpgme_error_from_errno): New prototypes. 2003-05-29 Marcus Brinkmann * gpgme.h (gpgme_op_export_start): Change second arg to const char *. (gpgme_op_export): Likewise. (gpgme_op_export_ext_start): New prototype. (gpgme_op_export_ext): Likewise. * engine.h: Likewise for _gpgme_engine_op_export and _gpgme_engine_op_export_ext. * engine-backend.h (struct engine_ops): Change second argument of prototype of export to const char *, and add reserverd int as third argument. Add prototype for export_ext. * engine.c (_gpgme_engine_op_export_ext): New function. (_gpgme_engine_op_export): Change second argument of prototype of export to const char *, and add reserverd int as third argument. * rungpg.c (gpg_export): Change second argument of prototype of export to const char *, and add reserverd int as third argument. (gpg_export_ext): New function. (gpg_keylist_ext): Break loop at error. (_gpgme_engine_ops_gpg): Add gpg_export_ext. * engine-gpgsm.c (gpgsm_export): Change second argument of prototype of export to const char *, and add reserverd int as third argument. (gpgsm_export_ext): New function. (_gpgme_engine_ops_gpgsm): Add gpgsm_export_ext. * export.c (export_start): Change second argument of prototype of export to const char *, and add reserverd int as third argument. (gpgme_op_export_start): Likewise. (export_ext_start): New function. (gpgme_op_export_ext_start): Likewise. (gpgme_op_export_ext): Likewise. * gpgme.h (gpgme_keylist_mode_t): New type for anonymous enum. (gpgme_sigsum_t): New type for anonymous enum. * encrypt-sign.c (encrypt_sign_start): Check for errors earlier, and return an error if RECP is not set. * Makefile.am (libgpgme_la_SOURCES): Remove user-id.c. * user-id.c: Remove file. * ops.h: Remove prototype for _gpgme_user_ids_all_valid. * gpgme.h (gpgme_encrypt_flags_t): New type. (gpgme_op_encrypt_start): Change second parameter to type gpgme_key_t[], and add third parameter. (gpgme_op_encrypt): Likewise. (gpgme_op_encrypt_sign_start): Likewise. (gpgme_op_encrypt_sign): Likewise. * encrypt.c (encrypt_start): Likewise. (gpgme_op_encrypt_start): Likewise. (gpgme_op_encrypt): Likewise. Pass flags to engine. * encrypt-sign.c (encrypt_sign_start): Likewise. (gpgme_op_encrypt_sign_start): Likewise. (gpgme_op_encrypt_sign): Likewise. * engine-backend.h (struct engine_ops): Likewise for prototypes of encrypt and encrypt_sign. * engine.h: Likewise for prototypes of _gpgme_engine_op_encrypt and _gpgme_engine_op_encrypt_sign. * engine.c (_gpgme_engine_op_encrypt): Likewise. (_gpgme_engine_op_encrypt_sign): Likewise. * rungpg.c (gpg_encrypt): Likewise. (gpg_encrypt_sign): Likewise. * rungpg.c (gpg_encrypt): Check flags for always trust option. * engine-gpgsm.c (gpgsm_encrypt): Likewise. (set_recipients): Rewritten to use keys instead user IDs. * rungpg.c (append_args_from_recipients): Rewritten to use keys instead user IDs. * encrypt.c (_gpgme_encrypt_status_handler): Change errors returned to GPGME_Invalid_Key and GPGME_General_Error. 2003-05-28 Marcus Brinkmann * engine-gpgsm.c: Rename GpgsmObject to engine_gpgsm_t. (struct gpgsm_object_s): Rename to struct engine_gpgsm. * rungpg.c: Rename GpgObject to engine_gpg_t. (struct gpg_object_s): Rename to struct engine_gpg. * context.h (struct gpgme_context): Change EngineObject to engine_object_t. (enum ctx_op_data_type): Rename to ctx_op_data_id_t. (ctx_op_data_t): New type. (struct gpgme_context): Use it. * ops.h (_gpgme_op_data_lookup): Use new type name. * op-support.c (_gpgme_op_data_lookup): Likewise. * engine.c: Rename EngineObject to engine_t in the file. Also EngineStatusHandler to engine_status_handler_t, EngineCommandHandler to engine_command_handler_t and EngineColonLineHandler to engine_colon_line_handler. * rungpg.c (start): Likewise. * engine-gpgsm.c: Likewise. * engine-backend.h (struct engine_ops): Likewise * engine.h (struct engine_object_s): Rename to struct engine. (EngineObject): Rename to engine_t. Also everywhere else in the file. (EngineStatusHandler): Rename to engine_status_handler_t. (EngineColonLineHandler): Rename to engine_colon_line_handler_t. (EngineCommandHandler): Rename to engine_command_handler_t. * engine-gpgsm.c (gpgsm_export): Fix bug in last change. * Makefile.am (libgpgme_la_SOURCES): Remove recipient.c, add user-id.c. * gpgme.h (gpgme_recipients_t): Removed. (gpgme_recipients_new, gpgme_recipients_release, gpgme_recipients_add_name, gpgme_recipients_add_name_with_validity, gpgme_recipients_count, gpgme_recipients_enum_open, gpgme_recipients_enum_read, gpgme_recipients_enum_close): Removed. (gpgme_op_encrypt, gpgme_op_encrypt_start, gpgme_op_encrypt_sign, gpgme_op_encrypt_sign_start, gpgme_op_export_start, gpgme_op_export): Change second argument to gpgme_user_id_t. (gpgme_user_ids_release): New prototype. (gpgme_user_ids_append): Likewise. * ops.h (_gpgme_recipients_all_valid): Remove. (_gpgme_user_ids_all_valid): Add. * context.h (struct gpgme_recipients): Removed. * user-id.c: New file. * recipient.c: Removed file. * rungpg.c (append_args_from_recipients): Change last arg to gpgme_user_id_t. Reimplement. (gpg_encrypt): Change second arg to gpgme_user_id_t. (gpg_encrypt_sign): Likewise. (gpg_export): Likewise. Rewrite user ID list code. * engine.c (_gpgme_engine_op_encrypt): Change second arg to gpgme_user_id_t. (_gpgme_engine_op_encrypt_sign): Likewise. (_gpgme_engine_op_export): Likewise. * engine.h (_gpgme_engine_op_encrypt, _gpgme_engine_op_encrypt_sign, _gpgme_engine_op_export): Likewise. * engine-gpgsm.c (set_recipients): Likewise. Rewrite loop code. (gpgsm_encrypt): Likewise. (gpgsm_export): Likewise. * engine-backend.h (struct engine_ops): Likewise for members ENCRYPT, ENCRYPT_SIGN and EXPORT. * export.c (export_start, gpgme_op_export_start, gpgme_op_export): Likewise. * encrypt.c (encrypt_start): Likewise. Don't check for count of recipients. (gpgme_op_encrypt_start): Likewise. (gpgme_op_encrypt): Likewise. * encrypt-sign.c (encrypt_sign_start): Likewise. (gpgme_op_encrypt_sign): Likewise. (gpgme_op_encrypt_sign_start): Likewise. 2003-05-27 Marcus Brinkmann * gpgme.h (struct _gpgme_op_import_result): Add skipped_new_keys. * import.c (parse_import_res): Add skipped_new_keys parser. * op-support.c (_gpgme_parse_inv_userid): Add missing break statements. * encrypt.c (gpgme_op_encrypt): Use gpgme_error_t instead of int. 2003-05-27 Marcus Brinkmann * encrypt.c (gpgme_op_encrypt_result): Use intermediate variable HOOK to avoid compiler warning. Don't ask, you don't want to know. (_gpgme_encrypt_status_handler): Likewise. (_gpgme_op_encrypt_init_result): Likewise. * decrypt.c (gpgme_op_decrypt_result): Likewise. (_gpgme_decrypt_status_handler): Likewise. (_gpgme_op_decrypt_init_result): Likewise. * verify.c (gpgme_op_verify_result): Likewise. (_gpgme_verify_status_handler): Likewise. (_gpgme_op_verify_init_result): Likewise. * edit.c (edit_status_handler): Likewise. (command_handler): Likewise. (edit_start): Likewise. * genkey.c (gpgme_op_genkey_result): Likewise. (genkey_status_handler): Likewise. (genkey_start): Likewise. * import.c (gpgme_op_import_result): Likewise. (import_status_handler): Likewise. (_gpgme_op_import_start): Likewise. * trustlist.c (gpgme_op_trustlist_next): Likewise. (_gpgme_op_trustlist_event_cb): Likewise. (gpgme_op_trustlist_start): Likewise. * keylist.c (gpgme_op_keylist_result): Likewise. (keylist_colon_handler): Likewise. (keylist_status_handler): Likewise. (_gpgme_op_keylist_event_cb): Likewise. (gpgme_op_keylist_start): Likewise. (gpgme_op_keylist_ext_start): Likewise. (gpgme_op_keylist_next): Likewise. * passphrase.c (_gpgme_passphrase_status_handler): Likewise. (_gpgme_passphrase_command_handler_internal): Likewise. * sign.c (gpgme_op_sign_result): Likewise. (_gpgme_sign_status_handler): Likewise. (_gpgme_op_sign_init_result): Likewise. * passphrase.c (_gpgme_passphrase_command_handler_internal): Fix access to pointer type. 2003-05-26 Marcus Brinkmann * engine.h (EngineCommandHandler): Change last argument to int fd. * gpgme.h (gpgme_passphrase_cb_t): Rewritten to take parts of the description and fd. (gpgme_edit_cb_t): Change last argument to int fd. * ops.h (_gpgme_passphrase_command_handler_internal): New prototype. * passphrase.c: Include . (op_data_t): Rename userid_hint to uid_hint, remove last_pw_handle. (release_op_data): Check values before calling free. (_gpgme_passphrase_status_handler): Likewise. (_gpgme_passphrase_command_handler_internal): New function. (_gpgme_passphrase_command_handler): Rewritten. * edit.c (edit_status_handler): Pass -1 as fd argument. (command_handler): Update prototype. New variable processed. Use it to store return value of _gpgme_passphrase_command_handler_internal which is now used instead _gpgme_passphrase_command_handler. Use it also to check if we should call the user's edit function. Pass fd to user's edit function. * rungpg.c (struct gpg_object_s): Change type of cmd.cb_data to void *. (gpg_release): Check value before calling free. Do not release cmd.cb_data. (command_cb): Function removed. (command_handler): New function. Thus we don't use a data object for command handler stuff anymore, but handle it directly. This allows proper error reporting (cancel of passphrase requests, for example). Also all callbacks work via direct writes to the file descriptor (so that passphrases are not kept in insecure memory). (gpg_set_command_handler): Rewritten to use even more ugly hacks. (read_status): Check cmd.keyword before calling free. Install command_handler as the I/O callback handler with GPG as private data. * rungpg.c (gpg_new): Add --enable-progress-filter to gpg invocation. * decrypt-verify.c (_gpgme_op_decrypt_verify_start): Rename to decrypt_verify_start. (gpgme_op_decrypt_verify_start): Call decrypt_verify_start. (gpgme_op_decrypt_verify): Likewise. * verify.c (verify_status_handler): New function that also calls progress status handler. (_gpgme_op_verify_start): Set status handler to verify_status_handler. Rename to (verify_start). (gpgme_op_verify_start): Call verify_start. (gpgme_op_verify): Likewise. * encrypt.c (encrypt_status_handler): New function. (_gpgme_encrypt_sym_status_handler): Call progress status handler. Make static. Rename to encrypt_sym_status_handler. (encrypt_start): Set status handler to encrypt_sym_status_handler or encrypt_status_handler. * sign.c (sign_status_handler): New function. (sign_start): Set status handler to sign_status_handler. * decrypt.c (decrypt_status_handler): New function that also calls progress status handler. (decrypt_start): Set status handler to decrypt_status_handler. * encrypt-sign.c (encrypt_sign_status_handler): Likewise. * decrypt-verify.c (decrypt_verify_status_handler): Call _gpgme_progress_status_handler. * conversion.c (_gpgme_decode_c_string): Add missing break statement. * recipient.c (gpgme_recipients_add_name_with_validity): Add one to buffer to allocate. 2003-05-19 Marcus Brinkmann * verify.c (parse_new_sig): Fix ERRSIG case. Submitted by Benjamin Lee . 2003-05-18 Marcus Brinkmann * gpgme.h: The following types are renamed. The old name is kept as a deprecated typedef. (GpgmeCtx): Rename to gpgme_ctx_t. (GpgmeData): Rename to gpgme_data_t. (GpgmeRecipients): Rename to gpgme_recipients_t. (GpgmeError): Rename to gpgme_error_t. (GpgmeDataEncoding): Rename to gpgme_data_encoding_t. (GpgmePubKeyAlgo): Rename to gpgme_pubkey_algo_t. (GpgmeHashAlgo): Rename to gpgme_hash_algo_t. (GpgmeSigStat): Rename to gpgme_sig_stat_t. (GpgmeSigMode): Rename to gpgme_sig_mode_t. (GpgmeAttr): Rename to gpgme_attr_t. (GpgmeValidity): Rename to gpgme_validity_t. (GpgmeProtocol): Rename to gpgme_protocol_t. (GpgmeStatusCode): Rename to gpgme_status_code_t. (GpgmeEngineInfo): Rename to gpgme_engine_info_t. (GpgmeSubkey): Rename to gpgme_subkey_t. (GpgmeKeySig): Rename to gpgme_keysig_t. (GpgmeUserID): Rename to gpgme_user_id_t. (GpgmePassphraseCb): Rename to gpgme_passphrase_cb_t. (GpgmeProgressCb): Rename to gpgme_progress_cb_t. (GpgmeEditCb): Rename to gpgme_edit_cb_t. (GpgmeIOCb): Rename to gpgme_io_cb_t. (GpgmeRegisterIOCb): Rename to gpgme_register_io_cb_t. (GpgmeRemoveIOCb): Rename to gpgme_remove_io_cb_t. (GpgmeEventIO): Rename to gpgme_event_io_t. (GpgmeEventIOCb): Rename to gpgme_event_io_cb_t. (GpgmeIOCbs): Rename to gpgme_io_cbs. (gpgme_io_cbs_t): New type. (GpgmeDataReadCb): Rename to gpgme_data_read_cb_t. (GpgmeDataWriteCb): Rename to gpgme_data_write_cb_t. (GpgmeDataSeekCb): Rename to gpgme_data_seek_cb_t. (GpgmeDataReleaseCb): Rename to gpgme_data_release_cb_t. (GpgmeDataCbs): Rename to gpgme_data_cbs. (gpgme_data_cbs_t): New type. (GpgmeInvalidUserID): Rename to gpgme_invalid_user_id_t. (GpgmeEncryptResult): Rename to gpgme_encrypt_result_t. (GpgmeDecryptResult): Rename to gpgme_decrypt_result_t. (GpgmeNewSignature): Rename to gpgme_new_signature_t. (GpgmeSignResult): Rename to gpgme_sign_result_t. (GpgmeSigNotation): Rename to gpgme_sig_notation_t. (GpgmeSignature): Rename to gpgme_signature_t. (GpgmeVerifyResult): Rename to gpgme_verify_result_t. (GpgmeImportStatus): Rename to gpgme_import_status_t. (GpgmeImportResult): Rename to gpgme_import_result_t. (GpgmeGenKeyResult): Rename to gpgme_genkey_result_t. (GpgmeKeyListResult): Rename to gpgme_keylist_result_t. (GpgmeTrustItem): Rename to gpgme_trust_item_t. * gpgme.h (gpgme_deprecated_error_t): New type, swallowing macros GPGME_No_Recipients, GPGME_Invalid_Recipient and GPGME_No_Passphrase. * data.h (struct gpgme_data_s): Rename to struct gpgme_data. * context.h (struct gpgme_context_s): Rename to struct gpgme_context. (struct gpgme_recipients_s): Rename to gpgme_recipients. 2003-05-18 Marcus Brinkmann * keylist.c (finish_key): Clear OPD->tmp_uid. 2003-05-18 Marcus Brinkmann * verify.c (_gpgme_verify_status_handler): Return GPGME_No_Data for NODATA status without signatures. 2003-05-05 Marcus Brinkmann * key.c (_gpgme_key_append_name): Use decoded string to parse user id. (_gpgme_key_add_sig): Likewise. 2003-05-04 Marcus Brinkmann * context.h (struct gpgme_context_s): Remove member op_info. * key.c (_gpgme_key_add_sig): Initialize SIG->uid. * gpgme.h (GpgmeError): Add deprecated values for GPGME_Invalid_Type and GPGME_Invalid_Mode. 2003-04-30 Marcus Brinkmann * 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 , , , and , but . (_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. * gpgme.h (struct _gpgme_key): New structure. (GpgmeKey): Define using _gpgme_key. (struct _gpgme_subkey): New structure. (GpgmeSubKey): New type. (struct _gpgme_key_sig): New structure. (GpgmeKeySig): New type. (struct _gpgme_user_id): New structure. (GpgmeUserID): New type. (struct _gpgme_op_keylist_result): New structure. (GpgmeKeyListResult): New type. (gpgme_op_keylist_result): New function. (gpgme_key_get_as_xml): Remove prototype. * context.h (struct gpgme_context_s): Remove members tmp_key, tmp_uid, key_cond and key_queue. (struct key_queue_item_s): Remove structure. (struct user_id_s): Remove structure. (struct gpgme_recipients_s): Replace with simple GpgmeUserID list. * gpgme.c (gpgme_release): Do not release CTX->tmp_key. * ops.h (_gpgme_key_add_subkey, _gpgme_key_append_name, _gpgme_key_add_sig, _gpgme_trust_item_new): New prototypes. * rungpg.c (command_cb): Return GpgmeError instead int. New variable ERR. Use it to hold return value of cmd handler. (gpg_delete): Access fingerprint of key directly. (append_args_from_signers): Likewise. (gpg_edit): Likewise. (append_args_from_recipients): Use GpgmeUserID for recipient list. * engine-gpgsm.c: Do not include "key.h". (gpgsm_delete): Access fingerprint of key directly. (gpgsm_sign): Likewise. (set_recipients): Use GpgmeUserID for recipients. Invert invalid user ID flag. * key.h: File removed. * key.c: Completely reworked to use exposed GpgmeKey data types. * keylist.c: Likewise. * recipient.c: Completely reworked to use GpgmeUserID. 2003-04-29 Marcus Brinkmann * gpgme.h (gpgme_get_key): Remove force_update argument. * key-cache.c: File removed. * Makefile.am (libgpgme_la_SOURCES): Remove key-cache.c. * ops.h (_gpgme_key_cache_add, _gpgme_key_cache_get): Remove prototypes. * keylist.c (_gpgme_op_keylist_event_cb): Don't call _gpgme_key_cache_add. (gpgme_get_key): New function. * verify.c (gpgme_get_sig_key): Remove last argument to gpgme_get_key invocation. * gpgme.h (struct _gpgme_trust_item): New structure. (GpgmeTrustItem): New type. (gpgme_trust_item_ref, gpgme_trust_item_unref): New prototypes. * context.h (struct trust_queue_item_s): Remove structure. (struct gpgme_context_s): Remove trust_queue member. * Makefile.am (libgpgme_la_SOURCES): Add trust-item.c. * trust-item.c: New file. * trustlist.c: Do not include or , but "gpgme.h". (struct trust_queue_item_s): Change to new type op_data_t. (trust_status_handler): Change first argument to void *. (trust_colon_handler): Likewise. (_gpgme_op_trustlist_event_cb): Use op_data_t type. (gpgme_op_trustlist_start): Use op_data_t and rework error handling. (gpgme_op_trustlist_next): Use op_data_t. (gpgme_trust_item_release): Remove function. (gpgme_trust_item_get_string_attr): Likewise. (gpgme_trust_item_get_int_attr): Likewise. * verify.c (calc_sig_summary): Do not set GPGME_SIGSUM_SYS_ERROR for bad signatures. 2003-04-28 Marcus Brinkmann * context.h: Remove OPDATA_VERIFY_COLLECTING. (struct gpgme_context_s): Remove member notation. * gpgme.h: Make enum for GPGME_KEYLIST_MODE_* values. * gpgme.h (struct _gpgme_sig_notation): New structure. (GpgmeSigNotation): New type. (struct _gpgme_signature): New structure. (GpgmeSignature): New type. (struct _gpgme_op_verify_result): New structure. (GpgmeVerifyResult): New type. (gpgme_op_verify_result): New prototype. (gpgme_get_notation): Remove prototype. * ops.h (_gpgme_op_verify_init_result): New prototype. (_gpgme_verify_status_handler): Change first argument to void *. * util.h (_gpgme_decode_percent_string, _gpgme_map_gnupg_error): New prototypes. * conversion.c (_gpgme_decode_percent_string): New function. (gnupg_errors): New static global. (_gpgme_map_gnupg_error): New function. * gpgme.c (gpgme_release): Don't release CTX->notation. (gpgme_get_notation): Remove function. * decrypt-verify.c (_gpgme_op_decrypt_verify_start): Call _gpgme_op_verify_init_result. * verify.c: Do not include , and "key.h", but do include "gpgme.h". (struct verify_result): Replace with ... (op_data_t): ... this type. (release_verify_result): Remove function. (release_op_data): New function. (is_token): Remove function. (skip_token): Remove function. (copy_token): Remove function. (gpgme_op_verify_result): New function. (calc_sig_summary): Rewritten. (finish_sig): Remove function. (parse_new_sig): New function. (parse_valid_sig): New function. (parse_notation): New function. (parse_trust): New function. (parse_error): New function. (_gpgme_verify_status_handler): Rewritten. Change first argument to void *. (_gpgme_op_verify_start): Rework error handling. Call _gpgme_op_verify_init_result. (gpgme_op_verify): Do not release or clear CTX->notation. (gpgme_get_sig_status): Rewritten. (gpgme_get_sig_string_attr): Likewise. (gpgme_get_sig_ulong_attr): Likewise. (gpgme_get_sig_key): Likewise. * gpgme.h (struct _gpgme_op_decrypt_result): New structure. (GpgmeDecryptResult): New type. (gpgme_op_decrypt_result): New prototype. * ops.h (_gpgme_op_decrypt_init_result): New prototype. (_gpgme_decrypt_status_handler): Fix prototype. (_gpgme_decrypt_start): Remove prototype. * decrypt-verify.c: Do not include , , and , "util.h" and "context.h", but "gpgme.h". (decrypt_verify_status_handler): Change first argument to void *, and rework error handling. (_gpgme_op_decrypt_verify_start): New function. (gpgme_op_decrypt_verify_start): Rewrite using _gpgme_op_decrypt_verify_start. (gpgme_op_decrypt_verify): Likewise. * decrypt.c: Include , "gpgme.h" and "util.h". (struct decrypt_result): Change to typedef op_data_t, rewritten. (is_token): Remove function. (release_op_data): New function. (skip_token): Remove function. (gpgme_op_decrypt_result): New function. (_gpgme_decrypt_status_handler): Change first argument to void *. Rework error handling. (_gpgme_decrypt_start): Rename to ... (decrypt_start): ... this. Call _gpgme_op_decrypt_init_result. (_gpgme_op_decrypt_init_result): New function. (gpgme_op_decrypt_start): Use decrypt_start. (gpgme_op_decrypt): Likewise. 2003-04-27 Marcus Brinkmann * encrypt-sign.c: Do not include , , , , and "util.h", but "gpgme.h". (_gpgme_op_encrypt_sign_start): Rename to ... (encrypt_sign_start): ... this. (gpgme_op_encrypt_sign_start): Use encrypt_sign_start, not _gpgme_op_encrypt_sign_start. (gpgme_op_encrypt_sign): Likewise. * gpgme.h (GpgmeEncryptResult): New data type. (gpgme_op_encrypt_result): New prototype. * ops.h (_gpgme_op_encrypt_init_result): New prototype. (_gpgme_op_encrypt_status_handler): Fix prototype. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call _gpgme_op_encrypt_init_result. * encrypt.c: Do not include , , "util.h" and "wait.h". Include and "gpgme.h". (SKIP_TOKEN_OR_RETURN): Remove macro. (struct encrypt_result): Rename to ... (op_data_t): ... new data type. Rewrite for user result data. (append_xml_encinfo): Remove function. (release_op_data): New function. (gpgme_op_encrypt_result): New function. (_gpgme_op_encrypt_status_handler): Change first argument to void *. Rewrite result parsing. (_gpgme_op_encrypt_sym_status_handler): Change first argument to void *. (_gpgme_op_encrypt_init_result): New function. (_gpgme_op_encrypt_start): Rename to ... (encrypt_start): ... this. (gpgme_op_encrypt_start): Use encrypt_start, not gpgme_op_encrypt_start. (gpgme_op_encrypt): Likewise. * 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 and . (_gpgme_parse_inv_userid): New function. * sign.c: Include and "gpgme.h", but not , 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. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call _gpgme_op_sign_init_result. * delete.c: Include 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-25 Marcus Brinkmann * gpgme.h: Change GPGME_IMPORT_PRIVATE to GPGME_IMPORT_SECRET. * import.c (parse_import_res): Parse unchanged field. * 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 added as 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 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. * edit.c: Do not include , "util.h", but "gpgme.h". (edit_resut): Change to typedef for op_data_t. (edit_status_handler): Change first argument to void *. Rework error handling. (command_handler): Rework error handling. (_gpgme_op_edit_start): Rename to ... (edit_start): ... this. Rework error handling. (gpgme_op_edit_start): Rewrite using edit_start. (gpgme_op_edit): Likewise. * ops.h (_gpgme_passphrase_start): Remove prototype. * passphrase.c: Do not include , "util.h" or "debug.h", but "gpgme.h". (struct passphrase_result): Change to typedef for op_data_t. (release_passphrase_result): Rename to release_op_data. (_gpgme_passphrase_status_handler): Change first argument to void *. Use new op_data_t type. (_gpgme_passphrase_command_handler): Use new op_data_t type. (_gpgme_passphrase_start): Remove function. * decrypt.c (_gpgme_decrypt_start): Rewrite error handling. Do not call _gpgme_passphrase_start, but install command handler. * encrypt.c (_gpgme_op_encrypt_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * context.h (struct gpgme_context_s): Remove member initialized, use_cms and help_data_1. Add member protocol. Make use_armor and use_textmode bit flags. Make keylist_mode, include_certs, signers_len and signers_size unsigned. * gpgme.c (gpgme_new): Initialize CTX->protocol. (gpgme_set_protocol): Do not check CTX. Use CTX->protocol. (gpgme_get_protocol): Likewise. (gpgme_release): Do not release CTX->help_data_1. * op-support.c (_gpgme_op_reset): Use CTX->protocol. * wait-private.c (_gpgme_wait_private_event_cb): Remove variable CTX. * data.c: Do not include , but "gpgme.h". (_gpgme_data_inbound_handler): Expand _gpgme_data_append, because it will go. Do not assert DH. (_gpgme_data_outbound_handler): Do not assert DH. * export.c: Do not include , "debug.h" and "util.h", but "gpgme.h". (export_status_handler): Change type of first argument to void *. (_gpgme_op_export_start): Rename to ... (export_start): ... this. Rework error handling. (gpgme_op_export_start): Rewritten to use export_start instead _gpgme_op_export_start. (gpgme_op_export): Likewise. * gpgme.h (GpgmeError): Add GPGME_Busy, GPGME_No_Request. (GPGME_No_Recipients, GPGME_Invalid_Recipient, GPGME_No_Passphrase): New macros. * key.c (gpgme_key_get_string_attr): Fix validity attribute. 2003-04-24 Marcus Brinkmann * gpgme.h (struct _gpgme_op_genkey_result): New structure. (GpgmeGenKeyResult): New type. (gpgme_op_genkey): Drop last argument. (gpgme_op_genkey_result): New function. * genkey.c: Do not include "util.h", but "gpgme.h". (struct genkey_result): Replace with ... (op_data_t): ... this new type. (release_genkey_result): Replace with ... (release_op_data): ... this new function. (gpgme_op_genkey_result): New function. (genkey_status_handler): Rewritten using new op_data_t type. (get_key_parameter): New function. (_gpgme_op_genkey_start): Renamed to (genkey_start): ... this and rewritten. (gpgme_op_genkey_start): Use genkey_start instead _gpgme_op_genkey_start. (gpgme_op_genkey): Rewritten. Remove FPR argument. * context.h (struct gpgme_context_s): Remove member verbosity. * gpgme.c (gpgme_new): Do not set member verbosity. * engine.h (_gpgme_engine_set_verbosity): Remove prototype. * engine.c (_gpgme_engine_set_verbosity): Remove function. * engine-backend.h (struct engine_ops): Remove set_verbosity. * engine-gpgsm.c (_gpgme_engine_ops_gpgsm): Remove set_verbosity member. * rungpg.c (_gpgme_engine_ops_gpg): Likewise. (gpg_set_verbosity): Remove function. * decrypt.c (_gpgme_decrypt_start): Don't call _gpgme_engine_set_verbosity. * delete.c (_gpgme_op_delete_start): Likewise. * edit.c (_gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_op_encrypt_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * export.c (_gpgme_op_export_start): Likewise. * genkey.c (_gpgme_op_genkey_start): Likewise. * import.c (_gpgme_op_import_start): Likewise. * keylist.c (gpgme_op_keylist_start): Likewise. (gpgme_op_keylist_ext_start): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * verify.c (_gpgme_op_verify_start): Likewise. * Makefile.am (libgpgme_la_SOURCES): Add key-cache.c. * key.c (key_cache_initialized, key_cache_size, key_cache_max_chain_length, ): Removed. (struct key_cache_item_s, key_cache_lock, key_cache, key_cache_unused_items, hash_key, _gpgme_key_cache_add, _gpgme_key_cache_get, gpgme_get_key): Moved to ... * key-cache.c: ... here. New file. * key.h (_gpgme_key_cache_init): Remove prototypes. (_gpgme_key_cache_add,_gpgme_key_cache_get): Move to ... * ops.h: ... here. * version.c: Do not include "key.h". (do_subsystem_inits): Do not call _gpgme_key_cache_init. * mkstatus: Strip trailing comma. * gpgme.h (GpgmeStatus): Pretty print. * gpgme.h (GpgmeError): Rename GPGME_No_Passphrase to GPGME_Bad_Passphrase. * passphrase.c (_gpgme_passphrase_status_handler): Use GPGME_Bad_Passphrase instead GPGME_No_Passphrase. * gpgme.h (GpgmeError): Rename GPGME_No_Recipients to GPGME_No_UserID and GPGME_Invalid_Recipient to GPGME_Invalid_UserID. * encrypt.c (_gpgme_encrypt_status_handler): Use GPGME_No_UserID instead GPGME_No_Recipients and GPGME_Invalid_UserID instead GPGME_Invalid_Recipient. (_gpgme_op_encrypt_start): Likewise. * gpgme.h (GpgmeError): Remove GPGME_Busy and GPGME_No_Request. * wait-user.c (_gpgme_wait_user_event_cb): Don't clear CTX->pending. * wait-private.c (_gpgme_wait_private_event_cb): Likewise. * wait-global.c (gpgme_wait): Likewise. * verify.c (_gpgme_op_verify_start): Likewise. (gpgme_get_sig_status): Don't check pending flag. (gpgme_get_sig_string_attr): Likewise. (gpgme_get_sig_ulong_attr): Likewise. (gpgme_get_sig_key): Likewise. * op-support.c (_gpgme_op_reset): Likewise. * trustlist.c (gpgme_op_trustlist_start): Don't clear pending flag. (gpgme_op_trustlist_next): Don't check or clear pending flag. (gpgme_op_trustlist_end): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * context.h (struct gpgme_context_s): Remove member PENDING. * decrypt.c (_gpgme_decrypt_start): Likewise. * delete.c (_gpgme_op_delete_start): Likewise. * edit.c (_gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_op_encrypt_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * export.c (_gpgme_op_export_start): Likewise. * genkey.c (_gpgme_op_genkey_start): Likewise. * import.c (_gpgme_op_import_start): Likewise. * key.c (gpgme_get_key): Likewise. * keylist.c (gpgme_op_keylist_start): Likewise. (gpgme_op_keylist_ext_start): Likewise. (gpgme_op_keylist_next): Likewise. (gpgme_op_keylist_end): Likewise. * data-compat.c (gpgme_error_to_errno): Don't convert EBUSY. 2003-02-06 Marcus Brinkmann * gpgme.h (GpgmePassphraseCb): Change type to return GpgmeError, and add argument for returning the result string. (gpgme_cancel): Remove prototype. * gpgme.c (gpgme_cancel): Remove function. * context.h (struct gpgme_context_s): Remove member cancel. * passphrase.c (_gpgme_passphrase_command_handler): Call the passphrase callback in the new way. 2003-01-30 Marcus Brinkmann * edit.c (_gpgme_edit_status_handler): Call the progress status handler. 2003-02-05 Marcus Brinkmann * wait-user.c (_gpgme_wait_user_remove_io_cb): Move check for no I/O handlers left to ... (_gpgme_user_io_cb_handler): ... here. 2003-02-04 Marcus Brinkmann * trustlist.c (trustlist_colon_handler): Release ITEM if name could not be allocated. (gpgme_trust_item_release): Only release name if it is allocated. Reported by Marc Mutz . 2003-02-04 Marcus Brinkmann * rungpg.c (read_status): If he status handler returns an error, return it. (status_handler): If read_status fails, just return the error. 2003-02-01 Marcus Brinkmann * engine-gpgsm.c (start): Handle all errors, not only most of them. (xtoi_1, xtoi_2): Remove macro. (status_handler): Replace use of xtoi_2 with _gpgme_hextobyte. 2003-02-01 Marcus Brinkmann * engine-gpgsm.c (map_assuan_error): Replace ASSUAN_Bad_Certificate_Path with ASSUAN_Bad_Certificate_Chain. (gpgsm_new): Use assuan_pipe_connect instead assuan_pipe_connect2. * util.h (DIMof): Remove macro. * ops.h (_gpgme_op_event_cb, _gpgme_op_event_cb_user, _gpgme_data_unread): Prototypes removed. 2003-01-30 Marcus Brinkmann * types.h: File removed. * Makefile.am (libgpgme_la_SOURCES): Remove types.h. * io.h (struct spawn_fd_item_s): Do not include "types.h". * key.h: Likewise. * context.h: Likewise. * cengine-gpgsm.h: Likewise. * engine.h: Include "gpgme.h" instead "types.h". Add prototypes for EngineStatusHandler, EngineColonLineHandler and EngineCommandHandler. (_gpgme_engine_set_status_handler): Change parameter type from GpgmeStatusHandler to EngineStatusHandler. (_gpgme_engine_set_command_handler): Change parameter type from GpgmeCommandHandler to EngineCommandHandler. (_gpgme_engine_set_colon_line_handler): Change parameter type from GpgmeColonLineHandler to EngineColonLineHandler. * engine-backend.h: Include "engine.h" instead "types.h". (struct engine_ops): Change Gpgme*Handler parameters in members set_command_handler, set_colon_line_handler and set_status_handler to Engine*Handler. * engine.c (_gpgme_engine_set_status_handler): Change parameter type from GpgmeStatusHandler to EngineStatusHandler. (_gpgme_engine_set_command_handler): Change parameter type from GpgmeCommandHandler to EngineCommandHandler. (_gpgme_engine_set_colon_line_handler): Change parameter type from GpgmeColonLineHandler to EngineColonLineHandler. * rungpg.c (struct gpg_object_s): Change type of member status.fnc from GpgmeStatusHandler to EngineStatusHandler. Change type of member colon.fnc from GpgmeColonLineHandler to EngineColonLineHandler. Change type of member cmd.fnc from GpgmeCommandHandler to EngineCommandHandler. * engine-gpgsm.c (struct gpgsm_object_s): Likewise. * rungpg.c (gpg_set_status_handler): Change parameter type from GpgmeStatusHandler to EngineStatusHandler. * engine-gpgsm.c (gpgsm_set_status_handler): Likewise. (assuan_simple_command): Likewise. * rungpg.c (gpg_set_colon_line_handler): Change parameter type from GpgmeColonLineHandler to EngineColonLineHandler. * engine-gpgsm.c (gpgsm_set_colon_line_handler): Likewise. * rungpg.c (gpg_set_command_handler): Change parameter type from GpgmeCommandHandler to EngineCommandHandler. * engine-gpgsm.c (status_handler): Do not close status fd at end of function. * ops.h (_gpgme_op_data_lookup): Add prototype. * op-support.c: Include . (_gpgme_op_data_lookup): New function. * decrypt.c (_gpgme_release_decrypt_result): Function removed. (struct decrypt_result_s): Rename to ... (struct decrypt_resul): ... this. (DecryptResult): New type. (_gpgme_decrypt_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. * sign.c (_gpgme_release_sign_result): Function removed. (release_sign_result): New function. (struct sign_result_s): Rename to ... (struct sign_result): ... this. (SignResult): New type. (_gpgme_sign_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. * encrypt.c (struct encrypt_result_s): Rename to ... (struct encrypt_result): ... this. (_gpgme_release_encrypt_result): Function removed. (release_encrypt_result): New function. (_gpgme_encrypt_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. * verify.c (struct verify_result_s): Rename to ... (struct verify_result): ... this. Remove member next. (VerifyResult): New type. (_gpgme_release_verify_result): Function removed. (release_verify_result): New function. (finish_sig): Change first argument to type VerifyResult. Diddle the type of the op_data structure. (add_notation): Change first argument to type VerifyResult. (_gpgme_verify_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. * passphrase.c (struct passphrase_result_s): Rename to ... (struct passphrase_result): ... this. Remove member next. (PassphraseResult): New type. (_gpgme_release_passphrase_result): Function removed. (release_passphrase_result): New function. (_gpgme_passphrase_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. (_gpgme_passphrase_command_handler): Likewise. * keylist.c (struct keylist_result_s): Rename to ... (struct keylist_result): ... this. Remove member next. (KeylistResult): New type. (_gpgme_release_keylist_result): Function removed. (release_keylist_result): New function. (keylist_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. * edit.c (struct edit_result_s): Rename to ... (struct edit_result): ... this. Remove member next. (EditResult): New type. (_gpgme_release_edit_result): Function removed. (release_edit_result): New function. (edit_status_handler): Don't use test_and_allocate_result, but use _gpgme_op_data_lookup to retrieve result data object. (command_handler): Likewise. * types.h (DecryptResult, SignResult, EncryptResult, PassphraseResult, ImportResult, DeleteResult, GenKeyResult, KeylistResult, EditResult): Types removed. * ops.h: Don't include "types.h", but "gpgme.h" and "context.h". (test_and_allocate_result): Remove macro. (_gpgme_release_decrypt_result): Remove prototype. (_gpgme_decrypt_result): Remove prototype. (_gpgme_release_sign_result): Remove prototype. (_gpgme_release_encrypt_result): Remove prototype. (_gpgme_release_passphrase_result): Remove prototype. (_gpgme_release_import_result): Remove prototype. (_gpgme_release_delete_result): Remove prototype. (_gpgme_release_genkey_result): Remove prototype. (_gpgme_release_keylist_result): Remove prototype. (_gpgme_release_edit_result): Remove prototype. (_gpgme_release_verify_result): Remove prototype. * gpgme.c (_gpgme_release_result): Rewritten. * context.h (enum ctx_op_data_type): New enum. (struct ctx_op_data): New structure. (struct gpgme_context_s): Replace the member result with a member op_data. (fail_on_pending_request): Remove macro. * op-support.c (_gpgme_op_reset): Expand macro fail_on_pending_request. * util.h: Don't include "types.h" or "debug.h", but include "gpgme.h". 2003-01-30 Marcus Brinkmann * types.h (EngineObject): Move typedef to ... * engine.h: ... here. * types.h (GpgObject): Move typedef to ... * rungpg.c: ... here. * types.h (GpgsmObject): Move typedef to ... * engine-gpgsm.c: ... here. * util.h (return_if_fail, return_null_if_fail, return_val_if_fail): Remove macro. * gpgme.c (gpgme_cancel): Don't use return_if_fail. * key.c (gpgme_key_ref): Likewise. * signers.c (gpgme_signers_enum): Likewise. (gpgme_signers_clear): Likewise. * engine-backend.h (struct engine_ops): Rename get_path to get_file_name. * gpgme.h (struct _gpgme_engine_info): Rename member path to file_name. * version.c: Do not include , , context.h and util.h. Other clean ups. (parse_version_number): Protect more seriously against overflow. (gpgme_get_engine_info): Move to ... * engine.c (gpgme_get_engine_info): ... here. (_gpgme_engine_get_info): Function removed. (_gpgme_engine_get_path): Make static and rename to ... (engine_get_file_name): .. this. (_gpgme_engine_get_version): Make static and rename to ... (engine_get_version): ... this. (_gpgme_engine_get_req_version): Make static and rename to ... (engine_get_req_version): ... this. * engine.h (_gpgme_engine_get_path, _gpgme_engine_get_version, _gpgme_engine_req_version, _gpgme_engine_get_info.): Remove prototypes. * gpgme.h (enum GpgmeProtocol): Remove GPGME_PROTOCOL_AUTO. * gpgme.c (gpgme_set_protocol): Don't handle GPGME_PROTOCOL_AUTO. (gpgme_get_protocol_name): New function. * engine-backend.h (struct engine_ops): New member get_req_version, remove member check_version. * engine.h (_gpgme_Engine_get_version): New prototype. * rungpg.c (gpg_get_req_version): New function. (gpg_check_version): Function removed. (_gpgme_engine_ops_gpg): Add gpg_get_req_version, remove gpg_check_version. * engine-gpgsm.c (gpgsm_get_req_version): New function. (gpgsm_check_version): Function removed. (_gpgme_engine_ops_gpgsm): Add gpgsm_get_req_version, remove gpgsm_check_version. * engine.c: Include ops.h. (_gpgme_engine_get_req_version): New function. (gpgme_engine_check_version): Rewritten. * version.c (gpgme_get_engine_info): Rewritten. * gpgme.h (gpgme_engine_info): New structure. (GpgmeEngineInfo): New type. 2003-01-29 Marcus Brinkmann * types.h: Remove byte and ulong types. * util.h (_gpgme_hextobyte): Change prototype to unsigned char instead byte. * conversion.c (_gpgme_hextobyte): Change argument to unsigned char instead byte. (_gpgme_decode_c_string): Likewise, and beautify. Also support a few more escaped characters. Be more strict about buffer size. (_gpgme_data_append_percentstring_for_xml): Change type of SRC, BUF and DST to unsigned char instead byte. * progress.c (_gpgme_progress_status_handler): Use unsigned char instead byte. * debug.c (trim_spaces): Likewise. * util.h (mk_error): Remove macro. * conversion.c, data.c, data-compat.c, decrypt.c, delete.c, edit.c, encrypt.c, encrypt-sign.c, engine.c, engine-gpgsm.c, export.c, genkey.c, gpgme.c, import.c, key.c, keylist.c, passphrase.c, progress.c, recipient.c, rungpg.c, sign.c, signers.c, trustlist.c, verify.c, wait.c, wait-global.c, wait-private (literally everywhere): Expand the mk_error macro. * context.h (wait_on_request_or_fail): Remove macro. * 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 . (_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 , and . (_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 , , and . (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 and . (_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 , and . (export_status_handler): Change return type to GpgmeError. Don't check ctx->error. * genkey.c: Do not include and . (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 , and . (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 . (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. * key.c (gpgme_key_sig_get_string_attr): Use validity_to_string instead otrust_to_string to calculate validity. 2003-01-19 Miguel Coca * w32-io.c (_gpgme_io_select): Add missing argument in calls to DEBUG_BEGIN. * w32-util.c: Include "sema.h". (find_program_in_registry): Change DEBUG1 to DEBUG2, fixes compilation error. 2003-01-19 Marcus Brinkmann * rungpg.c (_gpgme_engine_ops_gpg): Remove gpg_start. (gpg_start): Rename to ... (start): ... this function. Change arguments to GpgObject. (gpg_decrypt): Call start. (gpg_edit): Likewise. (gpg_encrypt): Likewise. (gpg_encrypt_sign): Likewise. (gpg_export): Likewise. (gpg_import): Likewise. (gpg_keylist): Likewise. (gpg_keylist_ext): Likewise. (gpg_trustlist): Likewise. (gpg_verify): Likewise. * engine-gpgsm.c (_gpgme_engine_ops_encrypt): Remove gpgsm_start. (gpgsm_start): Rename to ... (struct gpgsm_object_s): Remove member command. (gpgsm_release): Don't free command. (start): ... this function. Change arguments to GpgsmObject and const char *. (gpgsm_decrypt): Call start. (gpgsm_delete): Likewise. (gpgsm_encrypt): Likewise. (gpgsm_export): Likewise. (gpgsm_genkey): Likewise. (gpgsm_import): Likewise. (gpgsm_keylist): Likewise. (gpgsm_keylist_ext): Likewise. (gpgsm_verify): Likewise. * decrypt.c (_gpgme_decrypt_start): Don't call _gpgme_engine_start. * delete.c (_gpgme_op_delete_start): Likewise. * edit.c (_gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_op_encrypt_start): * encrypt-sign.c (_gpgme_op_encrypt_sign_start): * export.c (_gpgme_op_export_start): Likewise. * genkey.c (_gpgme_op_genkey_start): Likewise. * import.c (_gpgme_op_import_start): Likewise. * keylist.c (gpgme_op_keylist_ext_start): Likewise. (gpgme_op_keylist_start): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * trustlist.c (gpgme_op_trustlist_start): Likewise. * verify.c (_gpgme_op_verify_start): Likewise. * engine-backend.h (struct engine_ops): Remove member start. * engine.h (_gpgme_engine_start): Remove prototype. * engine.c (_gpgme_engine_start): Remove function. 2003-01-06 Werner Koch * keylist.c (set_mainkey_capability): Handle 'd' and 'D' used since gpg 1.3 to denote disabled keys. 2003-01-06 Marcus Brinkmann * data-mem.c: Include . * engine.c: Likewise. 2003-01-06 Marcus Brinkmann * Makefile.am (libgpgme_la_DEPENDENCIES): Correct bug in last change. 2002-12-24 Marcus Brinkmann * gpgme.h (gpgme_op_verify, gpgme_op_decrypt_verify): Drop R_STAT argument. * decrypt-verify.c (gpgme_op_decrypt_verify): Drop R_STAT argument. * verify.c (gpgme_op_verify): Drop R_STAT argument. (_gpgme_intersect_stati): Function removed. * ops.h (_gpgme_intersect_stati): Remove prototype. 2002-12-24 Marcus Brinkmann * libgpgme.vers: New file. * Makefile.am (EXTRA_DIST): Add libgpgme.vers. (libgpgme_version_script_cmd): New variable. (libgpgme_la_LDFLAGS): Add libgpgme_version_script_cmd here. (libgpgme_la_DEPENDENCIES): New variable. 2002-12-23 Marcus Brinkmann * key.c (gpgme_key_get_string_attr): Don't accept GPGME_ATTR_IS_SECRET. (otrust_to_string): New function. (gpgme_key_get_as_xml): Use it. (validity_to_string): New function. (gpgme_key_get_string_attr): Beautify using above functions. (gpgme_key_get_ulong_attr): Likewise. 2002-12-23 Marcus Brinkmann * data-mem.c (mem_release): Fix gcc warning. * data-user.c (user_release): Likewise. 2002-12-06 Marcus Brinkmann * data.h (gpgme_data_release_cb): Change return type to void. (gpgme_data_read_cb): Change return type to ssize_t. * data.c (gpgme_data_read): Likewise. * data-stream.c (stream_read): Likewise. * data-fd.c (fd_read): Likewise. * data-mem.c (mem_read): Likewise. (mem_release): Change return type to void. * data-user.c (user_read): Change return type to ssize_t. (user_release): Change return type to void. * data-compat.c (old_user_read): Change return type to ssize_t. * gpgme.h (GpgmeDataReadCb): Likewise. (gpgme_data_read): Likewise. (GpgmeDataSeekCb): Change return type to off_t. 2002-12-04 Marcus Brinkmann * gpgme.h: Add prototype for gpgme_get_key. * key.c (gpgme_get_key): New function. * verify.c (gpgme_get_sig_key): Rewrite using gpgme_get_key. * gpgme.h: Add prototypes for new interfaces gpgme_key_sig_get_string_attr and gpgme_key_get_ulong_attr. (enum GpgmeAttr): New attribute GPGME_ATTR_SIG_CLASS. * gpgme.c (gpgme_set_keylist_mode): Allow GPGME_KEYLIST_MODE_SIGS. * key.h (struct certsig_s): New members ALGO, NAME_PART, EMAIL_PART, COMMENT_PART, NAME, SIG_STAT and SIG_CLASS. * conversion.c (_gpgme_decode_c_string): Add new parameter LEN. Use that to determine if allocation is desired or not. * util.h: Adjust prototype of _gpgme_decode_c_string. * keylist.c (keylist_colon_handler): Adjust caller of _gpgme_decode_c_string. * key.h (struct gpgme_key_s): New member last_uid. * key.c (_gpgme_key_append_name): Rewritten using _gpgme_decode_c_string and the last_uid pointer. (my_isdigit): Macro removed. (ALLOC_CHUNK): Likewise. * keylist.c (set_userid_flags): Use last_uid member of KEY. * context.h (struct user_id_s): New member last_certsig. * key.h: Add prototype for _gpgme_key_add_certsig. * key.c (_gpgme_key_add_certsig): New function. (set_user_id_part): Move function before _gpgme_key_add_certsig. (parse_user_id): Change first argument to SRC, add new arguments NAME, EMAIL and COMMENT. Change code to use these arguments instead going through UID. Move function before _gpgme_add_certsig. (parse_x509_user_id): Likewise. (_gpgme_key_append_name): Adjust arguments to parse_x509_user_id and parse_user_id invocation. (one_certsig_as_xml): New function. (one_uid_as_xml): Print signatures. * context.h (struct gpgme_context_s): New member TMP_UID. * keylist.c (keylist_colon_handler): Rewritten, implement "sig" record entries. * key.c (get_certsig): New function. (gpgme_key_sig_get_string_attr): Likewise. (gpgme_key_sig_get_ulong_attr): Likewise. * keylist.c: Include . (my_isdigit): Macro removed. (set_mainkey_trust_info): Use isdigit, not my_isdigit. (set_userid_flags): Likewise. (set_subkey_trust_info): Likewise. (set_ownertrust): Likewise. (finish_key): Move function up a bit and remove prototype. * rungpg.c (gpg_keylist_ext): Correct precedence of signature listing mode. (gpg_keylist_ext): Implement signature listing mode. 2002-11-25 Marcus Brinkmann * rungpg.c (_gpgme_gpg_spawn): Do not set parent fds to -1. * posix-io.c (_gpgme_io_spawn): Call _gpgme_io_close instead close for parent fds. * w32-io.c (_gpgme_io_spawn): Call _gpgme_io_close instead CloseHandle for parent fds. 2002-11-22 Marcus Brinkmann * gpgme.h [_MSC_VER]: Define ssize_t as long. 2002-11-22 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_new): Save the result of a first setlocale before doing another setlocale. 2002-11-21 Marcus Brinkmann * decrypt.c: Some beautyfication. * verify.c (_gpgme_verify_status_handler): Treat GPGME_STATUS_UNEXPECTED like GPGME_STATUS_NODATA. Reported by Miguel Coca . 2002-11-19 Marcus Brinkmann * genkey.c: Only include if [HAVE_CONFIG_H]. (struct genkey_result_s): Add new member FPR. (_gpgme_release_genkey_result): Free RESULT->fpr if set. (genkey_status_handler): Extract the fingerprint from the status line. (gpgme_op_genkey): Add new argument FPR and return the fingerprint in it. * gpgme.h: Adjust prototype of gpgme_op_genkey. 2002-11-19 Marcus Brinkmann * rungpg.c (gpg_keylist): Add --with-fingerprint to gpg invocation twice, to get fingerprints on subkeys. Suggested by Timo Schulz . (gpg_keylist_ext): Likewise. 2002-11-05 Marcus Brinkmann * import.c (append_xml_impinfo): Use _gpgme_data_append_string_for_xml rather than _gpgme_data_append_string for the field content. Submitted by Miguel Coca . 2002-10-10 Marcus Brinkmann * rungpg.h, engine-gpgsm.h: File removed. * engine-backend.h: New file. * Makefile.am (gpgsm_components): New variable, set depending on automake conditional HAVE_GPGSM. (libgpgme_la_SOURCES): Add engine-backend.h, remove rungpg.h and engine-gpgsm.h. Replace engine-gpgsm.c with ${gpgsm_components}. (status-table.h): Depend on gpgme.h, not rungpg.h. * conversion.c: Include . * engine-gpgsm.c: Do not set ENABLE_GPGSM here. Include "engine-backend.h" instead "engine-gpgsm.h". Reorder some functions and remove all function prototypes. (_gpgme_gpgsm_get_version): Make static and rename to ... (gpgsm_get_version): ... this. (_gpgme_gpgsm_check_version): Make static and rename to ... (gpgsm_check_version): ... this. (_gpgme_gpgsm_new): Make static. Change argument type from GpgsmObject * to void **. Call gpgsm_release instead _gpgme_gpgsm_release. (_gpgme_gpgsm_op_decrypt): Make static and rename to ... (gpgsm_check_decrypt): ... this. (_gpgme_gpgsm_op_delete): Make static and rename to ... (gpgsm_check_delete): ... this. (_gpgme_gpgsm_set_recipients): Make static and rename to ... (gpgsm_check_set_recipients): ... this. (_gpgme_gpgsm_op_encrypt): Make static and rename to ... (gpgsm_encrypt): ... this. (_gpgme_gpgsm_op_export): Make static and rename to ... (gpgsm_export): ... this. (_gpgme_gpgsm_op_genkey): Make static and rename to ... (gpgsm_genkey): ... this. (_gpgme_gpgsm_op_import): Make static and rename to ... (gpgsm_import): ... this. (_gpgme_gpgsm_op_keylist): Make static and rename to ... (gpgsm_keylist): ... this. (_gpgme_gpgsm_op_keylist_ext): Make static and rename to ... (gpgsm_keylist_ext): ... this. (_gpgme_gpgsm_op_sign): Make static and rename to ... (gpgsm_sign): ... this. (_gpgme_gpgsm_op_trustlist): Make static and rename to ... (gpgsm_trustlist): ... this. (_gpgme_gpgsm_op_verify): Make static and rename to ... (gpgsm_verify): ... this. (gpgsm_status_handler): Rename to ... (status_handler): ... this. (_gpgme_gpgsm_set_status_handler): Make static and rename to ... (gpgsm_set_status_handler): ... this. (_gpgme_gpgsm_set_colon_line_handler): Make static and rename to ... (gpgsm_set_colon_line_handler): ... this. (_gpgme_gpgsm_add_io_cb): Rename to ... (add_io_cb): ... this. (_gpgme_gpgsm_start): Make static and rename to ... (gpgsm_start): ... this. (_gpgme_gpgsm_set_io_cb): Make static and rename to ... (gpgsm_set_io_cb): ... this. (_gpgme_gpgsm_io_event): Make static and rename to ... (gpgsm_io_event): ... this. (struct _gpgme_engine_ops_gpgsm): New variable. [!ENABLE_GPGSM]: Removed. * engine.c: Do not include , , , , "io.h", "rungpg.h" and "engine-gpgsm.h". Include and "engine-backend.h". (struct engine_object_s): Rewritten. (engine_ops): New variable. * engine.c (_gpgme_engine_get_path, _gpgme_engine_get_version, _gpgme_engine_check_version, _gpgme_engine_new, _gpgme_engine_release, _gpgme_engine_set_verbosity, _gpgme_engine_set_status_handler, _gpgme_engine_set_command_handler, _gpgme_engine_set_colon_line_handler, _gpgme_engine_op_decrypt, _gpgme_engine_op_delete, _gpgme_engine_op_edit, _gpgme_engine_op_encrypt, _gpgme_engine_op_encrypt_sign, _gpgme_engine_op_export, _gpgme_engine_op_genkey, _gpgme_engine_op_import, _gpgme_engine_op_keylist, _gpgme_engine_op_keylist_ext, _gpgme_engine_op_sign, _gpgme_engine_op_trustlist, _gpgme_engine_op_verify, _gpgme_engine_start, _gpgme_engine_set_io_cbs, _gpgme_engine_io_event): Reimplement. * engine.h: Fix a few comments and a variable name in a prototype. * ops.h: Do not include "rungpg.h". * passphrase.c: Include config.h only if [HAVE_CONFIG_H]. Do not include "rungpg.h". * recipient.c: Likewise. * signers.c: Likewise. * version.c: Likewise. * rungpg.c: Likewise. Include "engine-backend.h". Reorder functions and remove prototypes. (_gpgme_gpg_get_version): Make static and rename to ... (gpg_get_version): ... this. (_gpgme_gpg_check_version): Make static and rename to ... (gpg_check_version): ... this. (_gpgme_gpg_new): Make static. Change argument type from GpgObject * to void **. Call gpg_release instead _gpgme_gpg_release. (_gpgme_gpg_op_decrypt): Make static and rename to ... (gpg_check_decrypt): ... this. (_gpgme_gpg_op_delete): Make static and rename to ... (gpg_check_delete): ... this. (_gpgme_gpg_set_recipients): Make static and rename to ... (gpg_check_set_recipients): ... this. (_gpgme_gpg_op_encrypt): Make static and rename to ... (gpg_encrypt): ... this. (_gpgme_gpg_op_export): Make static and rename to ... (gpg_export): ... this. (_gpgme_gpg_op_genkey): Make static and rename to ... (gpg_genkey): ... this. (_gpgme_gpg_op_import): Make static and rename to ... (gpg_import): ... this. (_gpgme_gpg_op_keylist): Make static and rename to ... (gpg_keylist): ... this. (_gpgme_gpg_op_keylist_ext): Make static and rename to ... (gpg_keylist_ext): ... this. (_gpgme_gpg_op_sign): Make static and rename to ... (gpg_sign): ... this. (_gpgme_gpg_op_trustlist): Make static and rename to ... (gpg_trustlist): ... this. (_gpgme_gpg_op_verify): Make static and rename to ... (gpg_verify): ... this. (gpg_status_handler): Rename to ... (status_handler): ... this. (_gpgme_gpg_set_status_handler): Make static and rename to ... (gpg_set_status_handler): ... this. (_gpgme_gpg_set_colon_line_handler): Make static and rename to ... (gpg_set_colon_line_handler): ... this. (gpgme_gpg_add_io_cb): Rename to ... (add_io_cb): ... this. (_gpgme_gpg_start): Make static and rename to ... (gpg_start): ... this. (_gpgme_gpg_set_io_cb): Make static and rename to ... (gpg_set_io_cb): ... this. (_gpgme_gpg_io_event): Make static and rename to ... (gpg_io_event): ... this. (struct _gpgme_engine_ops_gpg): New variable. 2002-10-10 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_verify) [!ENABLE_GPGSM]: Add missing argument. 2002-10-09 Marcus Brinkmann * data.h, data-user.c, data-stream.c, data-mem.c, data-fd.c, data-compat.c: New file. Really check them in this time, completes 2002-10-08 change. * rungpg.h (GpgStatusHandler): Rename type to GpgmeStatusHandler and move to ... * types.h (GpgmeStatusHandler): ... here. * rungpg.h (GpgColonLineHandler): Rename type to GpgmeColonLineHandler. and move to ... * types.h (GpgmeColonLineHandler): ... here. * rungpg.h (GpgCommandHandler): Rename type to GpgmeCommandHandler. and move to ... * types.h (GpgmeCommandHandler): ... here. * engine.h: Don't include "rungpg.h". (_gpgme_engine_set_status_handler): Change type of argument from GpgStatusHandler to GpgmeStatusHandler. (_gpgme_engine_set_colon_line_handler): Change type of argument from GpgColonLineHandler to GpgmeColonLineHandler. (_gpgme_engine_set_command_handler): Change type of argument from GpgCommandHandler to GpgmeCommandHandler. * engine-gpgsm.h: Don't include "rungpg.h". (_gpgme_gpgsm_set_status_handler): Change type of argument from GpgStatusHandler to GpgmeStatusHandler. (_gpgme_gpgsm_set_colon_line_handler): Change type of argument from GpgColonLineHandler to GpgmeColonLineHandler. * engine-gpgsm.c: Do not include "rungpg.h". (struct gpgsm_object_s): Change type of status.fnc to GpgmeStatusHandler. Change type of colon.fnc to GpgmeColonLineHandler. (gpgsm_assuan_simple_command): Change type of argument from GpgStatusHandler to GpgmeStatusHandler. (_gpgme_gpgsm_set_status_handler): Likewise. (_gpgme_gpgsm_set_colon_line_handler): Change type of argument from GpgColonLineHandler to GpgmeColonLineHandler. * rungpg.h (_gpgme_gpg_set_status_handler): Change type of argument from GpgStatusHandler to GpgmeStatusHandler. (_gpgme_gpg_set_colon_line_handler): Change type of argument from GpgColonLineHandler to GpgmeColonLineHandler. (_gpgme_gpg_set_command_handler): Change type of argument from GpgCommandHandler to GpgmeCommandHandler. * rungpg.c (struct gpg_object_s): Change type of status.fnc to GpgmeStatusHandler. Change type of colon.fnc to GpgmeColonLineHandler. Change type of cmd.fnc to GpgmeCommandLineHandler. (_gpgme_gpg_set_status_handler): Change type of argument FNC to GpgmeStatusHandler. (_gpgme_gpg_set_colon_line_handler): Change type of argument FNC to GpgmeColonLineHandler. (_gpgme_gpg_set_command_handler): Change type of argument FNC to GpgmeCommandHandler. * engine.c (_gpgme_engine_set_status_handler): Change type of argument FNC to GpgmeStatusHandler. (_gpgme_engine_set_colon_line_handler): Change type of argument FNC to GpgmeColonLineHandler. (_gpgme_engine_set_command_handler): Change type of argument FNC to GpgmeCommandHandler. * rungpg.h (_gpgme_gpg_enable_pipemode): Remove prototype. * rungpg.c (struct gpg_object_s): Remove PM. (pipemode_cb): Prototype removed. (add_pm_data): Function removed. (_gpgme_gpg_enable_pipemode): Likewise. (pipemode_copy): Likewise. (pipemode_cb): Likewise. (add_arg): Don't check for pipemode. (add_data): Likewise. (_gpgme_gpg_set_status_handler): Likewise. (_gpgme_gpg_set_colon_line_handler): Likewise. (_gpgme_gpg_set_command_handler): Likewise. (_gpgme_gpg_spawn): Likewise. (_gpgme_gpg_spawn): Don't set PM.active. (_gpgme_gpg_op_verify): Remove pipemode case. * verify.c (_gpgme_op_verify_start): Remove pipemode case. * rungpg.h (_gpgme_gpg_add_arg, _gpgme_gpg_add_data, _gpgme_gpg_add_pm_data, _gpgme_gpg_housecleaning, _gpgme_gpg_set_simple_line_handler): Prototype removed. (_gpgme_gpg_set_verbosity): New prototype. * rungpg.c (_gpgme_gpg_add_data): Make static and rename to ... (add_data): ... this. (_gpgme_gpg_add_pm_data): Call add_data, not _gpgme_gpg_add_data. (_gpgme_gpg_set_command_handler): Likewise. (_gpgme_gpg_op_decrypt, _gpgme_gpg_op_edit, _gpgme_gpg_op_encrypt, _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_sign, _gpgme_gpg_op_verify): Likewise. (_gpgme_gpg_add_pm_data): Rename to ... (add_pm_data): ... this. (_gpgme_gpg_op_verify): Call add_pm_data, not _gpgme_gpg_add_pm_data. (_gpgme_gpg_add_arg): Make static and rename to ... (add_arg): ... this. (_gpgme_gpg_set_command_handler, _gpgme_gpg_new, _gpgme_gpg_op_decrypt, _gpgme_gpg_op_delete, _gpgme_append_gpg_args_from_signers, _gpgme_gpg_op_edit, _gpgme_append_gpg_args_from_recipients, _gpgme_gpg_op_encrypt, _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_keylist, _gpgme_gpg_op_keylist_ext, _gpgme_gpg_op_trustlist, _gpgme_gpg_op_sign, _gpgme_gpg_op_verify): Use add_arg, not _gpgme_gpg_add_arg. (_gpgme_gpg_set_verbosity): New function. (struct gpg_object_s): Remove member simple from colon. (_gpgme_gpg_set_colon_line_handler): Don't initialize simple. (_gpgme_gpg_set_simple_line_handler): Removed function. (read_colon_line): Don't check the GPG->colon.simple. * engine.c (_gpgme_engine_set_verbosity): Call _gpgme_gpg_set_verbosity instead _gpgme_gpg_add_arg. 2002-10-08 Marcus Brinkmann * util.h (_gpgme_malloc, _gpgme_realloc, _gpgme_calloc, _gpgme_strdup, _gpgme_free): Remove prototypes. (xtrymalloc, xtrycalloc, xtryrealloc, xtrystrdup, xfree): Remove macros. * util.c: File removed. * Makefile.am (libgpgme_la_SOURCES): Remove util.h. * conversion.c (_gpgme_decode_c_string): Use malloc instead of xtrymalloc, realloc instead of xtryrealloc, calloc instead of xtrycalloc, free instead of xfree. (_gpgme_data_append_percentstring_for_xml): Likewise. * data.c (_gpgme_data_new, _gpgme_data_release): Likewise. * data-compat.c (gpgme_data_new_from_filepart): Likewise. * data-mem.c (mem_write, mem_release, gpgme_data_new_from_mem, _gpgme_data_get_as_string): Likewise. * debug.c (debug_init): Likewise. * decrypt.c (_gpgme_release_decrypt_result): Likewise. * delete.c (_gpgme_release_delete_result): Likewise. * edit.c (_gpgme_release_edit_result, _gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_release_encrypt_result): Likewise. * engine.c (_gpgme_engine_get_info, _gpgme_engine_new, _gpgme_engine_release): Likewise. * engine-gpgsm.c (_gpgme_gpgsm_new, _gpgme_gpgsm_release, _gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete, gpgsm_set_recipients, _gpgme_gpgsm_op_encrypt, _gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey, _gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist, _gpgme_gpgsm_op_keylist_ext, _gpgme_gpgsm_op_sign, _gpgme_gpgsm_op_verify, gpgsm_status_handler): Likewise. * genkey.c (_gpgme_release_genkey_result): Likewise. * gpgme.c (gpgme_new, gpgme_release): Likewise. * import.c (_gpgme_release_import_result): Likewise. * key.c (_gpgme_key_cache_init, _gpgme_key_cache_add, key_new, add_subkey, gpgme_key_release, _gpgme_key_append_name): Likewise. * keylist.c (_gpgme_release_keylist_result, keylist_colon_handler, _gpgme_op_keylist_event_cb, gpgme_op_keylist_next): Likewise. * ops.h (test_and_allocate_result): Likewise. * passphrase.c (_gpgme_release_passphrase_result, _gpgme_passphrase_status_handler, _gpgme_passphrase_command_handler): Likewise. * progress.c (_gpgme_progress_status_handler): Likewise. * recipient.c (gpgme_recipients_new, gpgme_recipients_release, gpgme_recipients_add_name_with_validity): Likewise. * rungpg.c (_gpgme_gpg_new, _gpgme_gpg_release, _gpgme_gpg_add_arg, _gpgme_gpg_add_data, _gpgme_gpg_set_colon_line_handler, free_argv, free_fd_data_map, build_argv, _gpgme_gpg_spawn, read_status, read_colon_line): Likewise. * sign.c (_gpgme_release_sign_result): Likewise. * signers.c (_gpgme_signers_add): Likewise. * trustlist.c (trust_item_new, trustlist_colon_handler, _gpgme_op_trustlist_event_cb, gpgme_op_trustlist_next, gpgme_trustitem_release): Likewise. * verify.c (_gpgme_release_verify_result, finish_sig): Likewise. * version.c (gpgme_get_engine_info, _gpgme_get_program_version): Likewise. * w32-io.c (create_reader, create_writer, destroy_reader, destroy_writer, build_commandline, _gpgme_io_spawn): Likewise. * w32-sema.c (critsect_init, _gpgme_sema_cs_destroy): Likewise. * w32-util.c (read_w32_registry_string): Likewise. * wait.c (_gpgme_fd_table_deinit, _gpgme_fd_table_put, _gpgme_wait_event_cb, _gpgme_add_io_cb, _gpgme_remove_io_cb) * data-compat.c: Include . 2002-10-08 Marcus Brinkmann New data object component: * gpgme.h (GpgmeDataReadCb, GpgmeDataWriteCb, GpgmeDataSeekCb, GpgmeDataReleaseCb): New types. (struct GpgmeDataCbs): New structure. (gpgme_data_read): Changed prototype to match that of read() closely. (gpgme_data_write): Similar for write(). (gpgme_data_seek, gpgme_data_new_from_cbs, gpgme_data_new_from_fd, gpgme_data_new_from_stream): New prototypes. (gpgme_data_get_type, gpgme_check_engine): Prototype removed. * Makefile.am (libgpgme_la_SOURCES): Add data.h, data-fd.c, data-stream.c, data-mem.c, data-user.c and data-compat.c. * data.c: Reimplemented from scratch. * (data-compat.c, data-fd.c, data.h, data-mem.c, data-stream.c, data-user.c): New file. * context.h (struct gpgme_data_s): Removed. * conversion.c: Include and . (_gpgme_data_append): New function. * data.c (_gpgme_data_append_string): Move to ... * conversion.c (_gpgme_data_append_string): ... here. * data.c (_gpgme_data_append_for_xml): Move to ... * conversion.c (_gpgme_data_append_for_xml): ... here. * data.c (_gpgme_data_append_string_for_xml): Move to ... * conversion.c (_gpgme_data_append_string_for_xml): ... here. * data.c (_gpgme_data_append_percentstring_for_xml): Move to ... * conversion.c (_gpgme_data_append_percentstring_for_xml): ... here. * ops.h (_gpgme_data_get_mode, _gpgme_data_set_mode): Prototype removed. * types.h (GpgmeDataMode): Type removed. * decrypt.c (_gpgme_decrypt_start): Don't check data type or mode. * edit.c (_gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_op_encrypt_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. * export.c (_gpgme_op_export_start): Likewise. * genkey.c (_gpgme_op_genkey_start): Likewise. * import.c (_gpgme_op_import_start): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * verify.c (_gpgme_op_verify_start): Likewise. * encrypt.c (gpgme_op_encrypt): Remove hack that returns invalid no recipient if no data was returned. * encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns no recipient if no data was returned. * encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns no recipient if no data was returned. * engine.c (_gpgme_engine_op_verify): Add new argument to differentiate detached from normal signatures. * engine.h (_gpgme_engine_op_verify): Likewise for prototype. * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise. Don't check mode of data argument. * engine-gpgsm.h (_gpgme_gpgsm_op_verify): Likewise for prototype. * gpgme.h (gpgme_op_verify_start): Likewise for prototype. (gpgme_op_verify): Likewise for prototype. * rungpg.c (_gpgme_gpg_op_verify): Likewise. * rungpg.h (_gpgme_gpg_op_verify): Likewise for prototype. * verify.c (_gpgme_op_verify_start): Likewise. (gpgme_op_verify_start): Likewise. (gpgme_op_verify): Likewise. * rungpg.c (struct arg_and_data_s): New member INBOUND to hold direction of data object. (_gpgme_gpg_add_data): Add new argument INBOUND. Use it to determine direction of data object. (_gpgme_gpg_add_pm_data, _gpgme_gpg_set_command_handler, _gpgme_gpg_op_decrypt, _gpgme_gpg_op_edit, _gpgme_gpg_op_encrypt, _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_sign, _gpgme_gpg_op_verify): Add new argument to _gpgme_gpg_add_data invocation. (build_argv): Use new member INBOUND to determine direction of file descriptor. Don't check the data type. * rungpg.h (_gpgme_gpg_add_data): Add new argument to prototype. * gpgme.c (gpgme_get_op_info): Don't call _gpgme_data_get_as_string if CTX->op_info is NULL. * version.c (gpgme_check_engine): Function removed. 2002-09-30 Werner Koch * keylist.c (keylist_colon_handler): Take care when printing a NULL with the DEBUG. * engine-gpgsm.c (struct gpgsm_object_s): New member ANY. (gpgsm_status_handler): Run the colon function to indicate EOF. (_gpgme_gpgsm_set_colon_line_handler): Better reset ANY here. 2002-09-28 Marcus Brinkmann * conversion.c (_gpgme_hextobyte): Prevent superfluous multiplication with base. Reported by Stéphane Corthésy. * keylist.c (gpgme_op_keylist_ext_start): Use private asynchronous operation type in invocation of _gpgme_op_reset. 2002-09-20 Werner Koch * ath.c: Include sys/time.h if sys/select.h is not available. 2002-09-13 Marcus Brinkmann * keylist.c (keylist_status_handler): Do not call finish_key() here. (gpgme_op_keylist_ext_start): Set CTX->tmp_key to NULL. 2002-09-03 Marcus Brinkmann * Makefile.am (assuan_libobjs): Remove @LTLIBOBJS@ as we link them into gpgme unconditionally. (libgpgme_la_LIBADD): Change @LIBOBJS@ into @LTLIBOBJS@. 2002-09-02 Marcus Brinkmann * Makefile.am (assuan_libobjs): Use @LTLIBOBJS@ instead @LIBOBJS@. 2002-09-02 Marcus Brinkmann * debug.c (_gpgme_debug_add): Test *LINE, not LINE. (_gpgme_debug_end): Likewise. Reported by Dr. Stefan Dalibor . 2002-09-02 Marcus Brinkmann * posix-io.c (_gpgme_io_select): Don't use a non-constant struct initializer. * version.c (_gpgme_get_program_version): Likewise. Reported by Dr. Stefan Dalibor . 2002-09-02 Marcus Brinkmann * conversion.c (_gpgme_decode_c_string): Set DESTP before modifying DEST. * conversion.c (_gpgme_decode_c_string): Fix off by one error in last change. * rungpg.c (_gpgme_append_gpg_args_from_signers): Move before _gpgme_op_edit so its prototype is known early on. * conversion.c: New file. * util.h: Add prototypes for _gpgme_decode_c_string and _gpgme_hextobyte. * keylist.c (keylist_colon_handler): Call _gpgme_decode_c_string on issuer name. * Makefile.am (libgpgme_la_SOURCES): Add conversion.c * key.c (_gpgme_key_append_name): Replace calls to hextobyte by calls to _gpgme_hextobyte. (hash_key): Likewise. 2002-09-01 Marcus Brinkmann * op-support.c (_gpgme_op_reset): Set CTX->pending after calling _gpgme_engine_release, as this will reset pending to zero in the event done callback on cancelled operations. 2002-08-30 Marcus Brinkmann * rungpg.c (_gpgme_gpg_op_edit): Add args from signers. Suggested by Miguel Coca . * rungpg.c (_gpgme_gpg_op_edit): Add bogus ctx argument. * rungpg.h: Also to prototype. * engine.c (_gpgme_engine_op_edit): Likewise. * engine.h: Likewise. * edit.c (_gpgme_op_edit_start): Likewise. 2002-08-29 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement signer selection. * vasprintf.c (va_copy): Define macro if not yet defined. 2002-08-29 Marcus Brinkmann * passphrase.c (_gpgme_passphrase_status_handler): Reset CTX->result.passphrase->no_passphrase if passphrase is given (good or bad). Submitted by Jean DIRAISON . 2002-08-28 Marcus Brinkmann * posix-io.c (_gpgme_io_spawn): Use a double-fork approach. Return 0 on success, -1 on error. * version.c (_gpgme_get_program_version): Don't wait for the child. * engine.c (_gpgme_engine_housecleaning): Function removed. (do_reaping): Likewise. (_gpgme_engine_add_child_to_reap_list): Likewise. (struct reap_s): Removed. (reap_list): Likewise. (reap_list_lock): Likewise. * engine.h (_gpgme_engine_io_event): Remove prototypes for _gpgme_engine_housecleaning and _gpgme_engine_add_child_to_reap_list. * rungpg.c (_gpgme_gpg_release): Don't add child to reap list. (struct gpg_object_s): Remove PID member. (_gpgme_gpg_new): Don't initialize GPG->pid. (_gpgme_gpg_spawn): Don't set GPG->pid. * wait.c (run_idle): Removed. (gpgme_wait): Run idle_function directly. 2002-08-21 Marcus Brinkmann * encrypt-sign.c (encrypt_sign_status_handler): Remove dead variables encrypt_info and encrypt_info_len. * trustlist.c (gpgme_op_trustlist_start): Set colon line handler. * posix-sema.c (sema_fatal): Remove function. All these reported by Stéphane Corthésy. 2002-08-23 Werner Koch * gpgme-config.in: Made --prefix work for --libs. 2002-08-21 Marcus Brinkmann * ath.h: Update list of symbols that get a prefix: Rename the ath_mutex_*_available symbols to ath_*_available. 2002-08-21 Marcus Brinkmann * stpcpy.c: New file from gnulib. * Makefile.am (assuan_libobjs): Remove jnlib. 2002-08-20 Marcus Brinkmann * gpgme.h: Add prototype for gpgme_op_import_ext. * import.c (struct import_result_s): New member `nr_considered'. Rename `any_imported' to `nr_imported'. (import_status_handler): Increment nr_imported. Set nr_considered if appropriate. (gpgme_op_import_ext): New function. (gpgme_op_import): Implement in terms of gpgme_op_import_ext. 2002-08-20 Werner Koch * gpgme.m4: Replaced with a new and faster version. This does not anymore try to build test programs. If we really need test programs, we should add an option to gpgme-config to do so. * vasprintf.c (int_vasprintf): Hack to handle NULL passed for %s. 2002-08-20 Marcus Brinkmann * gpgme.c (_gpgme_set_op_info): Append data on subsequent calls. * encrypt-sign.c (encrypt_sign_status_handler): Remove op_info handling. 2002-08-19 Werner Koch * decrypt.c (is_token,skip_token): Duplicated from verify.c (gpgme_op_decrypt): Hack to properly return Decryption_Failed.. (_gpgme_decrypt_status_handler): Create an operation info. 2002-08-14 Werner Koch * key.h (struct certsig_s): New. Use it in gpgme_key_s. * key.c (gpgme_key_release): Release it. We need to add more code of course. (_gpgme_key_append_name): Use memset to intialize the struct. * gpgme.h (GPGME_KEYLIST_MODE_SIGS): New. * rungpg.c (_gpgme_gpg_op_keylist): Include sigs in listing depending non the list mode. * key.c (gpgme_key_get_string_attr): Use GPGME_ATTR_TYPE to return information about the key type (PGP or X.509). (gpgme_key_get_ulong_attr): Likewise. * keylist.c (keylist_colon_handler): Include 1 in the check for valid algorithms so that RSA is usable. Store the issuer name and serial number also for "crs" records. Parse the expire date for subkeys. (set_userid_flags): Put them onto the last appended key. 2002-07-29 Marcus Brinkmann * rungpg.c (_gpgme_gpg_op_edit): Use --with-colons. 2002-07-28 Marcus Brinkmann * data.c (gpgme_data_read): For GPGME_DATA_TYPE_NONE, return EOF instead an error. The following changes make it possible to flush an inbound data pipe before invoking a command handler: * posix-io.c (_gpgme_io_select): Accept new argument NONBLOCK to _gpgme_io_select. Set timeout of 0 if this is set. * w32-io.c (_gpgme_io_select): Likewise. * io.h: Add new argument NONBLOCK to _gpgme_io_select prototype. * wait.c (do_select): Add new argument to _gpgme_io_select invocation. * rungpg.h (_gpgme_gpg_set_command_handler): Add new argument linked_data to prototype. * engine.h (_gpgme_engine_set_command_handler): Likewise. * engine.c (_gpgme_engine_set_command_handler): Likewise. * passphrase.c (_gpgme_passphrase_start): Pass NULL as linked_data argument to _gpgme_engine_set_command_handler. * rungpg.c (struct gpg_object_s): New members linked_data and linked_idx in CMD. (_gpgme_gpg_new): Initialize those new members. (_gpgme_gpg_set_command_handler): Accept new argument linked_data. (build_argv): Handle linked_data in the same hack as cb_data. (read_status): If linked_data is in use, flush the pipe before activating the command handler. * gpgme.h: Add prototypes for gpgme_op_edit_start and gpgme_op_edit. The next changes export the status codes to the user: * decrypt.c (_gpgme_decrypt_status_handler): Likewise, also prefix all STATUS_ with GPGME_. * delete.c (delete_status_handler): Likewise. * decrypt-verify.c (decrypt_verify_status_handler): Likewise. * encrypt.c (_gpgme_encrypt_status_handler): Likewise. (_gpgme_encrypt_sym_status_handler): Likewise. * encrypt-sign.c (encrypt_sign_status_handler): Likewise. * engine-gpgsm.c (parse_status): Likewise. (gpgsm_status_handler): Likewise. (gpgsm_set_recipients): Likewise. * export.c (export_status_handler): Likewise. * genkey.c (genkey_status_handler): Likewise. * import.c (append_xml_impinfo): Likewise. (import_status_handler): Likewise. * keylist.c (keylist_status_handler): Likewise. * passphrase.c (_gpgme_passphrase_status_handler): Likewise. (command_handler): Likewise. * progress.c (_gpgme_progress_status_handler): Likewise. * sign.c (_gpgme_sign_status_handler): Likewise. * trustlist.c (trustlist_status_handler): Likewise. * verify.c (_gpgme_verify_status_handler): Likewise. * gpgme.h (GpgmeEditCb): New type. * rungpg.h (GpgStatusCode): Rename and move to ... * gpgme.h (GpgmeStatusCode): ... this and here. * Makefile.am (status-table.h): Run mkstatus on gpgme.h, not rungpg.h. * mkstatus: Prefix STATUS with GPGME_. * rungpg.h (GpgStatusHandler, GpgCommandHandler): Change type accordingly. * ops.h (_gpgme_verify_status_handler, _gpgme_decrypt_status_handler, _gpgme_sign_status_handler, _gpgme_encrypt_status_handler, _gpgme_passphrase_status_handler, _gpgme_progress_status_handler): Likewise. * rungpg.c (struct gpg_object_s): Likewise for CMD.code. These changes add an edit operation to GPGME: * context.h (struct gpgme_context_s): New member RESULT.edit. * ops.h: Add prototype for _gpgme_release_edit_result and _gpgme_passphrase_command_handler. * passphrase.c (command_handler): Make non-static and rename to ... (_gpgme_passphrase_command_handler): ... this. (_gpgme_passphrase_start): Use new name for command handler. * types.h: Add EditResult type. * gpgme.c (_gpgme_release_result): Release EDIT result. * edit.c: New file. * Makefile.am (libgpgme_la_SOURCES): Add edit.c. (libgpgme_la_LDADD): Rename to libgpgme_la_LIBADD, and include assuan_libobjs. (assuan_libobjs): New variable, set this instead libgpgme_la_LIBADD. * engine.h (_gpgme_engine_op_edit): New prototype. * engine.c (_gpgme_engine_op_edit): New function. * rungpg.h (_gpgme_gpg_op_edit): New prototype. * rungpg.c (_gpgme_gpg_op_edit): New function. 2002-07-27 Marcus Brinkmann * delete.c (delete_problem): New case ambigious specification. (delete_status_handler): Handle new case (poorly). 2002-07-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_delete): Implement this. 2002-07-25 Marcus Brinkmann * Makefile.am (libgpgme_la_LDADD): Add @LIBOBJS@ for vasprintf and fopencookie. * vasprintf.c: Update to more recent libiberty version. * debug.h: Replace #elsif with #elif. Submitted by Stéphane Corthésy: * util.h (vasprintf): Correct prototype. * encrypt-sign.c: Include . (encrypt_sign_status_handler): Change type of ENCRYPT_INFO_LEN to size_t. * ath-pthread.c: Include , not . * ath-pth.c: Likewise. 2002-07-25 Marcus Brinkmann * wait.c (fdt_global): Make static. Reported by Stéphane Corthésy. * rungpg.c (_gpgme_gpg_op_keylist_ext): Skip empty string patterns. Reported by Stéphane Corthésy. * key.c (gpgme_key_get_as_xml): Add OTRUST attribute. Requested by Stéphane Corthésy. (gpgme_key_get_string_attr): Add GPGME_ATTR_SIG_SUMMARY case to silence gcc warning. * rungpg.c (_gpgme_gpg_new): Always set utf8 as charset. 2002-07-03 Marcus Brinkmann * gpgme.c (gpgme_set_io_cbs): Deal with CTX being NULL. * gpgme.c (_gpgme_op_event_cb_user): New function. * op-support.c (_gpgme_op_reset): Support a new mode of operation for private or user event loop. Use new user event callback wrapper. * trustlist.c (gpgme_op_trustlist_start): Use this new mode. * keylist.c (gpgme_op_keylist_start): Likewise. * rungpg.c (_gpgme_gpg_io_event): New function. * rungpg.h (_gpgme_gpg_io_event): New prototype. * engine-gpgsm.c (_gpgme_gpg_io_event): New function. * engine-gpgsm.h (_gpgme_gpgsm_io_event): New prototype. * engine.c (_gpgme_engine_io_event): New function. * engine.h (_gpgme_engine_io_event): New prototype. * keylist.c (finish_key): Call _gpgme_engine_io_event, and move the real work for the default IO callback routines to ... (_gpgme_op_keylist_event_cb): ... here. New function. * trustlist.c (trustlist_colon_handler): Signal GPGME_EVENT_NEXT_TRUSTITEM. Move queue manipulation to ... (_gpgme_op_trustlist_event_cb): ... here. New function. * gpgme.c (_gpgme_op_event_cb): Call _gpgme_op_keylist_event_cb and _gpgme_op_trustlist_event_cb when appropriate. * ops.h (_gpgme_op_keylist_event_cb): New prototype. (_gpgme_op_trustlist_event_cb): Likewise. * op-support.c (_gpgme_op_reset): Add comment why we don't use the user provided event handler directly. * gpgme.h (GpgmeRegisterIOCb): Return GpgmeError value, and TAG in a pointer argument. * wait.c (_gpgme_add_io_cb): Likewise. * wait.h (_gpgme_add_io_cb): Likewise for prototype. * rungpg.c (_gpgme_gpg_add_io_cb): Call IO_CBS->add with new argument. Fix up error handling. * engine-gpgsm.c (_gpgme_gpgsm_add_io_cb): Call IO_CBS->add with new argument, fix up error handling. 2002-07-03 Werner Koch * encrypt.c (status_handler_finish): New. (_gpgme_encrypt_status_handler): Moved some code out to the new function and call this function also in case we get into the status handler with an error which might happen due to a kludge in engine-gpgsm.c 2002-06-28 Marcus Brinkmann * keylist.c (gpgme_op_keylist_ext_start): Always use our own FD table (eg use synchronous mode). 2002-06-28 Marcus Brinkmann * ops.h (_gpgme_wait_on_condition): Remove HANG argument from prototype and change return type to GpgmeError. (_gpgme_wait_one): New prototype. * wait.c (gpgme_wait): Replace with the meat from _gpgme_wait_on_condition here, and remove the support for conditions. (_gpgme_wait_on_condition): Remove HANG argument from prototype and change return type to GpgmeError. Replace with meat from _gpgme_wait_one and add support for conditions. (_gpgme_wait_one): Just call _gpgme_wait_on_condition without condition. * keylist.c (gpgme_op_keylist_ext_start): Always use our own FD table (eg use synchronous mode). (gpgme_op_keylist_next): Remove HANG argument from _gpgme_wait_on_condition. Check its return value. * trustlist.c (gpgme_op_trustlist_start): Always use our own FD table (eg use synchronous mode). (gpgme_op_trustlist_next): Remove HANG argument from _gpgme_wait_on_condition. Check its return value. 2002-06-27 Marcus Brinkmann * gpgme.h: Fix documentation of key attribute retrieval functions. 2002-06-26 Werner Koch * engine-gpgsm.c (map_assuan_error): Map No_Data_Available to EOF. * import.c (append_xml_impinfo): Kludge to print fingerprint instead of keyid for use with gpgsm. (import_status_handler): Set a flag to know whether any import occured. (gpgme_op_import): Reurn -1 if no certificate ewas imported. 2002-06-25 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_set_io_cbs) [ENABLE_GPGSM]: Fixed function arguments. 2002-06-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_export): Only export the keys listed in RECP. * export.c (gpgme_op_export): If no data was returned, return GPGME_No_Recipients. 2002-06-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_export): Implement. 2002-06-21 Marcus Brinkmann * engine-gpgsm.c (gpgsm_assuan_simple_command): Return ERR. (parse_status): New function. (gpgsm_status_handler): Use parse_status. (gpgsm_assuan_simple_command): Accept new arguments STATUS_FNC and STATUS_FNC_VALUE and process status messages. (gpgsm_set_recipients): Pass new arugments to gpgsm_assuan_simple_command. (gpgsm_set_fd): Likewise. (_gpgme_gpgsm_op_keylist): Likewise. (_gpgme_gpgsm_op_keylist_ext): Likewise. (_gpgme_gpgsm_op_sign): Likewise. 2002-06-21 Marcus Brinkmann * wait.c (_gpgme_remove_io_cb): Unlock FDT->lock. 2002-06-20 Werner Koch * rungpg.c (build_argv): Ignore GPG_AGENT_INFO if set but empty. * verify.c (calc_sig_summary): Set bad policy for wrong key usage. (skip_token): New. (_gpgme_verify_status_handler): Watch out for wrong key usage. (gpgme_get_sig_string_attr): Hack to return info on the key usage. Does now make use of the former RESERVED argument which has been renamed to WHATIDX. (gpgme_get_sig_ulong_attr): Renamed RESERVED to WHATIDX. 2002-06-14 Marcus Brinkmann * wait.c (do_select): Return -1 on error, and 0 if nothing to run. (_gpgme_wait_one): Only set HANG to zero if do_select returned an error, or there are no more file descriptors to wait on. (_gpgme_wait_on_condition): Ignore return value from do_select for now. 2002-06-13 Werner Koch * verify.c (gpgme_op_verify): Make sure that we never access an unitialized result structure. 2002-06-12 Werner Koch * keylist.c (struct keylist_result_s): New. (_gpgme_release_keylist_result): Release it here (keylist_status_handler): Handle truncated. (append_xml_keylistinfo): New. * gpgme.c (_gpgme_release_result): and use it here. * types.h: Declare the new type here. * context.h (struct gpgme_context_s): Use it here. 2002-06-11 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd. (_gpgme_gpgsm_new): Duplicate status file descriptor, so we can use our own close notification mechanism without interfering with assuan. 2002-06-11 Werner Koch * gpgme.h: Add GPGME_ATTR_SIG_SUMMARY and the GPGME_SIGSUM_ constants. * verify.c (calc_sig_summary): New. (gpgme_get_sig_ulong_attr): And use it here. 2002-06-10 Werner Koch * rungpg.h: Add new status codes TRUNCATED and ERROR. * verify.c (is_token, copy_token): New. (_gpgme_verify_status_handler): Use copy_token, handle the new ERROR status and store the errorcode used withgpgsm and trust status codes. * gpgme.h: New attribute ERRTOK. * key.c (gpgme_key_get_string_attr): Add dummy case for it. (gpgme_get_sig_string_attr): Use it here to return the last error. 2002-06-10 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the close notification for the status fd to ... (_gpgme_gpgsm_new): ... here. * wait.h: Include "sema.h". Remove prototypes of _gpgme_remove_proc_from_wait_queue and _gpgme_register_pipe_handler. Add prototypes of _gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put, _gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and _gpgme_wait_one.. * wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK, FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE, CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct proc_s. Replace struct wait_item_s. (_gpgme_fd_table_init): New function. (_gpgme_fd_table_deinit): Likewise. (_gpgme_fd_table_put): Likewise. (set_process_done): Remove function. (do_select): Take argument FDT. Use that to decide which fds to select on. (_gpgme_remove_proc_from_wait_queue): Remove function. (_gpgme_wait_event_cb): New function. (_gpgme_wait_one): Likewise. (_gpgme_register_pipe_hanldler): Remove function. (_gpgme_add_io_cb): New function. (_gpgme_remove_io_cb): Likewise. (_gpgme_freeze_fd): Remove function. (_gpgme_thaw_fd): Remove function. * rungpg.c (struct fd_data_map_s): Add new member TAG. (struct gpg_object_s): Likewise for STATUS and COLON. Add member IDX to CMD. Add new member IO_CBS. (close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE. For each I/O callback, check if it should be unregistered. If all callbacks have been unregistered, trigger GPGME_EVENT_DONE. Remove member RUNNING. (_gpgme_gpg_new): Initialize new members. (_gpgme_gpg_release): Check PID not RUNNING. Don't call _gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set. (build_argv): Store away the index instead the file descriptor for CMD. (_gpgme_gpg_add_io_cb): New function. (_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO callbacks. (gpg_status_handler): Change return type to void, remove PID argument, close filedescriptor if EOF or error occurs. (read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd. Use IO_CBS->remove instead _gpgme_freeze_fd. (gpg_colon_line_handler): Change return type to void, remove PID argument, close filedescriptor if EOF or error occurs. (command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd. (_gpgme_gpg_set_io_cbs): New function. * rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for _gpgme_gpg_set_io_cbs. * gpgme.h (GpgmeIOCb): New type. (GpgmeRegisterIOCb): Likewise. (GpgmeRemoveIOCb): Likewise. (GpgmeEventIO): Likewise. (GpgmeEventIOCb): Likewise. (struct GpgmeIOCbs): New structure to hold I/O callbacks. (gpgme_set_op_io_cbs): New prototype. (gpgme_get_op_io_cbs): Likewise. * ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from _gpgme_data_inbound_handler and _gpgme_data_outbound_handler prototype. Add prototype for _gpgme_op_reset. Add synchronous argument to _gpgme_decrypt_start prototype. * io.h: Beautification. * gpgme.c: Include "wait.h". (gpgme_new): Initialize FDT. (gpgme_set_io_cbs): New function. (gpgme_get_io_cbs): Likewise. (_gpgme_op_event_cb): Likewise. * data.c (_gpgme_data_inbound_handler): Change return type to void. Drop PID argument. Close FD on error and EOF. (write_mem_data): Don't close FD here ... (write_cb_data): ... or here ... (_gpgme_data_outbound_handler): ... but here. Change return type to void. Drop PID argument. * context.h: Include "wait.h". (struct gpgme_context_s): New members FDT and IO_CBS. * op-support.c: New file. * Makefile.am (libgpgme_la_SOURCES): Add op-support.c. * ops.h: Add prototype for _gpgme_op_reset(). * decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use _gpgme_op_reset. (gpgme_op_decrypt_start): Add synchronous argument. (gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead gpgme_wait. * delete.c (gpgme_op_delete_start): Rename to ... (_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_delete_start): Just a wrapper around _gpgme_op_delete_start now. (gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * encrypt.c: Include "wait.h". (ggpgme_op_encrypt_start): Rename to ... (_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_encrypt_start): Just a wrapper around _gpgme_op_encrypt_start now. (gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ... (_gpgme_op_encrypt_sign_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_encrypt_sign_start): Just a wrapper around _gpgme_op_encrypt_sign_start now. (gpgme_op_encrypt_sign): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * export.c (gpgme_op_export_start): Rename to ... (_gpgme_op_export_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_export_start): Just a wrapper around _gpgme_op_export_start now. (gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * genkey.c (gpgme_op_genkey_start): Rename to ... (_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_genkey_start): Just a wrapper around _gpgme_op_genkey_start now. (gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * import.c (gpgme_op_import_start): Rename to ... (_gpgme_op_import_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_import_start): Just a wrapper around _gpgme_op_import_start now. (gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset. (gpgme_op_keylist_ext_start): Likewise. * sign.c (gpgme_op_sign_start): Rename to ... (_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start now. (gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset. * verify.c (gpgme_op_verify_start): Rename to ... (_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS. Use _gpgme_op_reset. Make function static. (gpgme_op_verify_start): Just a wrapper around _gpgme_op_verify_start now. (gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one instead gpgme_wait. * engine-gpgsm.c (iocb_data_t): New type. (struct gpgsm_object_s): New member status_cb. Replace input_fd and input_data with input_cb. Replace output_fd and output_data with output_cb. Replace message_fd and message_data with message_cb. New member io_cbs. (_gpgme_gpgsm_new): Initialize all new members (and drop the old ones). (close_notify_handler): New variable POSSIBLY_DONE. For each I/O callback, check if it should be unregistered. If all callbacks have been unregistered, trigger GPGME_EVENT_DONE. (_gpgme_gpgsm_release): Remove variable PID. Use new variable names to close the file descriptors. (_gpgme_gpgsm_op_decrypt): Use new variable names, (_gpgme_gpgsm_op_encrypt): Likewise. (_gpgme_gpgsm_op_genkey): Likewise. (_gpgme_gpgsm_op_import): Likewise. (_gpgme_gpgsm_op_keylist): Likewise. (_gpgme_gpgsm_op_keylist_ext): Likewise. (_gpgme_gpgsm_op_sign): Likewise. (_gpgme_gpgsm_op_verify): Likewise. (gpgsm_status_handler): Drop argument PID. Change return type to void. Close status pipe before returning because of EOF or error. (_gpgme_gpgsm_add_io_cb): New function. (_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register callback function. (_gpgme_gpgsm_set_io_cbs): New function. * engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs. * engine.c (_gpgme_engine_set_io_cbs): New function. * engine.h: New prototype for _gpgme_engine_set_io_cbs. 2002-06-04 Marcus Brinkmann * Makefile.am (libgpgme_la_SOURCES): Remove mutex.h. 2002-06-03 Marcus Brinkmann * key.c: Include . (_gpgme_key_append_name): Skip one more char when processing escaped char. Submitted by Marc Mutz . Handle hexadecimal encodings. Also reported by Marc. Thanks! 2002-06-02 Marcus Brinkmann * ath.h: Enable the _gpgme_ prefix. Fix all those prefix macros. * posix-sema.c: Use that prefix here. * posix-io.c: Include "ath.h". (_gpgme_io_read): Use _gpgme_ath_read instead read. (_gpgme_io_write): Use _gpgme_ath_write instead write. (_gpgme_io_waitpid): Use _gpgme_ath_waitpid instead waitpid. (_gpgme_io_select): Use _gpgme_ath_select instead select. 2002-06-02 Marcus Brinkmann * Makefile.am (ath_components): New variable. (ath_components_pthread): Likewise. (ath_components_pth): Likewise. (system_components): Add ath_componentes. * ath.h: New file. * ath.c: Likewise. * ath-pthread.c: Likewise. * ath-pth.c: Likewise. * posix-sema.c (_gpgme_sema_cs_enter): Rework to use the ATH interface. * mutex.h: Remove file. 2002-05-30 Werner Koch * key.c (gpgme_key_get_string_attr): Return NULL when asking for an issuer with IDX > 0. We don't support altIssuerNames for now. 2002-05-22 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext): Aehmm, added missing variable definition. Oohh - Marcus was faster. 2002-05-22 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext): Fix last change. 2002-05-21 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_op_keylist) (_gpgme_gpgsm_op_keylist_ext): Pass the keylist mode to gpgsm. 2002-05-10 Werner Koch * key.h (gpgme_key_s): Add OTRUST. * keylist.c (set_ownertrust): New. (keylist_colon_handler): Get the ownertrust value * key.c (gpgme_key_get_string_attr,gpgme_key_get_ulong_attr): Return that value. 2002-05-08 Marcus Brinkmann * w32-util.c: New static variable GET_PATH_LOCK. (_gpgme_get_gpg_path): Remove superfluous NULL initializer. Take lock while determining path. (_gpgme_get_gpgsm_path): Likewise. * version.c (do_subsystem_inits): Set DONE to 1 after initialization. (gpgme_get_engine_info): New variable ENGINE_INFO_LOCK. Take lock while determining engine info. * rungpg.c (_gpgme_gpg_get_version): New variable GPG_VERSION_LOCK. Take the lock while determining the program version. * posix-io.c: Include "sema.h". (_gpgme_io_spawn): New variable FIXED_SIGNALS_LOCK. Take the lock while fixing the signals. (_gpgme_io_select): Make READFDS and WRITEFDS non-static. * key.c: Include "sema.h". New globals KEY_CACHE_LOCK and KEY_REF_LOCK. (capabilities_to_string): Make STRINGS very const. (_gpgme_key_cache_add): Lock the key cache. (_gpgme_key_cache_get): Likewise. (gpgme_key_ref, gpgme_key_release): Lock the key_ref_lock. * import.c (append_xml_impinfo): Make IMPORTED_FIELDS and IMPORT_RES_FIELDS very const. Make FIELD and FIELD_NAME a litle const. * engine.c (_gpgme_engine_get_info): New variable ENGINE_INFO_LOCK. Take lock while determining engine info. * engine-gpgsm.c: Include "sema.h". (_gpgme_gpgsm_get_version): New variable GPGSM_VERSION_LOCK. Take lock while getting program version. 2002-05-08 Marcus Brinkmann * debug.h: New file. * Makefile.am (libgpgme_la_SOURCES): Add debug.h. * util.h: Removed all prototypes and declarations related to debugging. Include "debug.h". * debug.c (debug_level): Comment variable and remove superfluous zero initializer. (errfp): Likewise. (_gpgme_debug_enabled): Function removed. (struct debug_control_s): Definition removed. (_gpgme_debug_level): Function removed. (_gpgme_debug_begin): Rewritten to use vasprintf. Accept a pritnf-style format specification and a variable number of arguments. (_gpgme_debug_add): Rewritten using vasprintf. Expect that format starts out with "%s" for simplicity. (_gpgme_debug_end): Rewritten using vasprintf. Do not accept a TEXT argument anymore. * posix-io.c (_gpgme_io_select): Use new level argument for DEBUG_BEGIN instead explicit if construct. * debug.c (debug_init): Remove superfluous zero initializer, remove volatile flag of INITIALIZED. Do not use the double-checked locking algorithm, it is fundamentally flawed and will empty your fridge (on a more serious note, despite the volatile flag it doesn't give you the guarantee you would expect, for example on a DEC Alpha or an SMP machine. The volatile only serializes accesses to the volatile variable, but not to the other variables). 2002-05-03 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_new): Redirect any gpgsm error output to /dev/null. * verify.c (gpgme_get_sig_key): Set the protocol of the listctx. * gpgme.c (gpgme_get_protocol): New. * data.c (gpgme_data_write): Changed type of BUFFER to void*. (gpgme_data_read): Ditto. * verify.c (_gpgme_verify_status_handler): Handle TRUST_* status lines so that a claim can be made without looking up the key. (gpgme_get_sig_string_attr): New. (gpgme_get_sig_ulong_attr): New. * gpgme.h (GpgmeAttr): Added GPGME_ATTR_SIG_STATUS. * rungpg.h: Add new status codes from gpg 1.0.7 and formatted the list to align with the status.h file from gnupg. * gpgme.h (GpgmeSigStat): Add _GOOD_EXP and _GOOD_EXPKEY. * verify.c (_gpgme_verify_status_handler, finish_sig): Handle these new status codes. Store the expiration time 2002-04-27 Werner Koch * gpgme.h (GpgmeData_Encoding): New. * data.c (gpgme_data_get_encoding,gpgme_data_set_encoding): New. * engine-gpgsm.c (map_input_enc): New. Use it in all local functions where the INPUT command gets send. 2002-04-27 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Close the output descriptor only when we don't need it anymore. Close the message descriptor if we don't need it. 2002-04-26 Werner Koch * Makefile.am (libgpgme_la_LIBADD): Use libtool libraries. 2002-04-25 Marcus Brinkmann * rungpg.c (_gpgme_gpg_release): Call gpgme_data_release on GPG->cmd.cb_data, not xfree. 2002-04-25 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_new): Set the display, ttyname, ttytype, lc_ctype and lc_messages options in the server. 2002-04-24 Marcus Brinkmann * engine-gpgsm.c (map_assuan_error): Add new error codes. 2002-04-23 Werner Koch * key.c (gpgme_key_get_ulong_attr): Swapped use of can_encrypt and can_certify to return the requested values. 2002-04-23 Marcus Brinkmann * gpgme.c (gpgme_get_progress_cb): Allow either return parameter to be NULL. (gpgme_get_passphrase_cb): Likewise. 2002-04-22 Marcus Brinkmann * gpgme.c (gpgme_get_passphrase_cb): New function. (gpgme_get_progress_cb): New function. * gpgme.h: Add new prototypes for gpgme_get_passphrase_cb and gpgme_get_progress_cb. 2002-03-28 Werner Koch * gpgme.h (GpgmeAttr): Add values for issuer and chaining. * key.h (gpgme_key_s): Add issuer and chaining elements for X509. * keylist.c (keylist_colon_handler): Store them. * key.c (gpgme_key_release): Free them. (gpgme_key_get_as_xml,gpgme_key_get_string_attr): Print them. 2002-03-26 Werner Koch * Makefile.am (libgpgme_la_SOURCES): Add mutex.h 2002-03-21 Werner Koch * util.h [!HAVE_FOPENCOOKIE]: Make sure off_t and ssize_t are defined. 2002-03-18 Marcus Brinkmann * Makefile.am (system_components): New variable, set depending on HAVE_DOSISH_SYSTEM. (libgpgme_la_SOURCES): Use system_components. Remove `syshdr.h'. * syshdr.h: File removed. * posix-io.c: Remove !HAVE_DOSISH_SYSTEM safeguard. Clean up source. * posix-sema.c: Likewise. * posix-util.c: Likewise. * w32-io.c: Remove HAVE_DOSISH_SYSTEM safeguard. * w32-sema.c: Likewise. * w32-util.c: Likewise. * posix-io.c: Include `unistd.h', do not include `syshdr.h'. * posix-sema.c: Likewise. * w32-io.c: Include `io.h', do not include `syshdr.h' * w32-sema.c: Likewise. * w32-util.c: Likewise. * data.c: Do not include `syshdr.h'. * wait.c: Likewise. * wait.h: Code cleanup. * mutex.h: New file. * posix-sema.c: Implement. 2002-03-08 Werner Koch * util.h [!HAVE_FOPENCOOKIE]: Fixed type. Thanks to Frank Heckenbach. 2002-03-07 Werner Koch * gpgme.h (gpgme_op_keylist_ext_start): Add prototype. 2002-03-06 Marcus Brinkmann * encrypt.c (_gpgme_encrypt_sym_status_handler): New function. (gpgme_op_encrypt_start): New variable SYMMETRIC, set it if RECP is null, and if it is set, use _gpgme_encrypt_sym_status_handler as status handler and run _gpgme_passphrase_start. * rungpg.c (_gpgme_gpg_op_encrypt): If RECP is zero, do symmetric encryption. * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): If RECP is zero, return error value. * rungpg.c (_gpgme_gpg_op_verify): Add "--" argument. 2002-03-03 Marcus Brinkmann * passphrase.c (_gpgme_passphrase_status_handler): Also set the error No_Passphrase if only a bad passphrase was provided. 2002-03-03 Marcus Brinkmann * rungpg.c (_gpgme_gpg_op_verify): If TEXT is of mode GPGME_DATA_MODE_IN, construct a command line that stores the plaintext in TEXT. * verify.c (gpgme_op_verify_start): Accept TEXT being uninitialized, and in this case interpret SIG as a normal or cleartext signature and TEXT as a return data object. * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise. 2002-03-03 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext) [!ENABLE_GPGSM]: Add stub function. 2002-02-28 Werner Koch * key.h (subkey_s): New member expires_at. * keylist.c (keylist_colon_handler): Set it here * key.c (gpgme_key_get_as_xml,gpgme_key_get_ulong_attr): Return it. 2002-02-27 Marcus Brinkmann * rungpg.h (_gpgme_gpg_op_keylist_ext): New prototype. * rungpg.c (_gpgme_gpg_op_keylist_ext): New function. * engine-gpgsm.h (_gpgme_gpgsm_op_keylist_ext): New prototype. * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext): New function. * engine.h (_gpgme_engine_op_keylist_ext): New prototype. * engine.c (_gpgme_engine_op_keylist_ext): New function. * keylist.c (gpgme_op_keylist_ext_start): New function. 2002-02-27 Marcus Brinkmann * gpgme.h: Add new error code GPGME_Invalid_Recipient. * encrypt.c (struct encrypt_result_s): New member invalid_recipients, rename no_recipients to no_valid_recipients. (_gpgme_encrypt_status_handler): Include error for invalid recipients. * engine-gpgsm.c (gpgsm_set_recipients): Change type of first argument to GpgsmObject. Use that to report back the status about the recipients. 2002-02-26 Marcus Brinkmann * verify.c (_gpgme_verify_status_handler): Fix the last change. 2002-02-25 Marcus Brinkmann * engine.c (_gpgme_engine_op_encrypt_sign): New function. * engine.h (_gpgme_engine_op_encrypt_sign): New prototype. * rungpg.c (_gpgme_append_gpg_args_from_signers): New function. (_gpgme_gpg_op_sign): Use that new function. (_gpgme_gpg_op_encrypt_sign): New function. * rungpg.h (_gpgme_gpg_op_encrypt_sign): New prototype. * gpgme.h (gpgme_op_encrypt_sign_start): New prototype. (gpgme_op_encrypt_sign): Likewise. * Makefile.am (libgpgme_la_SOURCES): Add encrypt-sign.c. * ops.h (_gpgme_encrypt_status_handler): Add prototype. (_gpgme_sign_status_handler): Add prototype. * sign.c (sign_status_handler): Rename to ... (_gpgme_sign_status_handler): ... this and make non-static. * encrypt.c (encrypt_status_handler): Rename to ... (_gpgme_encrypt_status_handler): ... this and make non-static. * encrypt.c (gpgme_op_encrypt_start): Use new status handler name. * sign.c (gpgme_op_sign_start): Likewise. 2002-02-25 Marcus Brinkmann * verify.c (_gpgme_verify_status_handler): Parse the args line to see if the problem is due to a missing key, and report that back to the user. 2002-02-25 Marcus Brinkmann * context.h (struct gpgme_context_s): New member include_certs. * gpgme.h (gpgme_set_include_certs): Add prototype. (gpgme_get_include_certs): Likewise. * gpgme.c (gpgme_set_include_certs): New function. (gpgme_get_include_certs): Likewise. (gpgme_new): Set include_certs to 1 (the default). * engine.c (_gpgme_engine_op_sign): Accept new argument include_certs, and pass it to _gpgme_gpgsm_op_sign. * engine.h (_gpgme_engine_op_sign): Likewise for prototype. * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Accept new argument include_certs and handle it. * engine-gpgsm.h (_gpgme_gpgsm_start): Add new argument include_certs. * sign.c (gpgme_op_sign_start): Add new argument to _gpgme_engine_op_sign call. 2002-02-14 Werner Koch * keylist.c (gpgme_op_keylist_start): Do not use a verbose listing. 2002-02-13 Werner Koch * vasprintf.c, fopencookie.c: Add replacement functions. * util.h: Add prototypes for them. 2002-02-09 Marcus Brinkmann * engine-gpgsm.c (gpgsm_assuan_simple_command): Return 0 if we reach the end of the function. 2002-02-09 Marcus Brinkmann * genkey.c (gpgme_op_genkey_start): Fix logic in validity check. (gpgme_op_genkey_start): Skip newlines after opening tag. * engine-gpgsm.c (_gpgme_gpgsm_start): Remove cruft. 2002-02-08 Marcus Brinkmann * genkey.c (gpgme_op_genkey_start): Allow PUBKEY and SECKEY to be set, and pass them down to the crypto engine. * engine-gpgsm.h (_gpgme_gpgsm_start): New arguments PUBKEY and SECKEY. * engine.h: Likewise. * rungpg.h (_gpgme_gpg_spawn): Likewise. * engine.c (_gpgme_engine_op_genkey): Likewise. Use those arguments. * rungpg.c (_gpgme_gpg_op_genkey): Likewise. Complain if those arguments are set. * engine-gpgsm.c (_gpgme_gpgsm_op_genkey): Likewise. Implement function. * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Beautify comment. 2002-02-06 Marcus Brinkmann * rungpg.c (_gpgme_gpg_op_keylist): Remove handling of keylist mode (for now). 2002-02-06 Marcus Brinkmann * wait.c (gpgme_wait): Add new argument STATUS, in which the status of the returned context is returned. (_gpgme_wait_on_condition): Rework the function a bit, to make it aware of cancelled processes, and to allow to use gpgme_wait with CTX being NULL (as documented in the source). (struct proc_s): New member REPORTED. * gpgme.h: Fix prototype. * verify.c (gpgme_op_verify): Fix use of gpgme_wait. * sign.c (gpgme_op_sign): Likewise. * import.c (gpgme_op_import): Likewise. * genkey.c (gpgme_op_genkey): Likewise. * export.c (gpgme_op_export): Likewise. * encrypt.c (gpgme_op_encrypt): Likewise. * delete.c (gpgme_op_delete): Likewise. * decrypt-verify.c (gpgme_op_decrypt_verify): Likewise. 2002-02-06 Marcus Brinkmann * gpgme.c (gpgme_set_keylist_mode): Possibly return an error value. (gpgme_get_keylist_mode): New function. (gpgme_new): Set the default for keylist_mode member of CTX. * gpgme.h (gpgme_set_keylist_mode): Fix prototype. (gpgme_get_keylist_mode): New prototype. (GPGME_KEYLIST_MODE_LOCAL): New macro. (GPGME_KEYLIST_MODE_EXTERN): Likewise.. 2002-02-02 Marcus Brinkmann This patch has gotten a bit large... mmh. The main thing that happens here is that error values are now not determined in the operation function after gpgme_wait completed, but in the status handler when EOF is received. It should always be the case that either an error is flagged or EOF is received, so that after a gpgme_wait you should never have the situation that no error is flagged and EOF is not received. One problem is that the engine status handlers don't have access to the context, a horrible kludge works around this for now. All errors that happen during a pending operation should be catched and reported in ctx->error, including out-of-core and cancellation. This rounds up neatly a couple of loose ends, and makes it possible to pass up any errors in the communication with the backend as well. As a bonus, there will be a function to access gpgme->wait, so that the operations can truly be implemented with their _start function. * engine-gpgsm.c (gpgsm_status_handler): Horrible kludge to report error back to the context. * rungpg.c (gpg_status_handler): Same horrible kludge applied here. * engine-gpgsm.c (gpgsm_assuan_simple_command): Add error checking. * wait.c (_gpgme_wait_on_condition): If canceled, set CTX->error to a value indication that. * verify.c (add_notation): Set error, not out_of_core. (finish_sig): Likewise. (gpgme_op_verify_start): Don't clear out_of_core. (_gpgme_verify_status_handler): At EOF, clean up the notation data. (gpgme_op_verify): And don't do it here. * trustlist.c (trustlist_status_handler): Check error, not out_of_core. (gpgme_op_trustlist_start): Don't clear out_of_core. (gpgme_op_trustlist_next): Check error, not out_of_core. (gpgme_op_trustlist_end): Likewise. * ops.h (test_and_allocate_result): New macro. (_gpgme_passphrase_result): Remove prototype. * delete.c (gpgme_op_delete): Return error from context. (delete_status_handler): Use macro test_and_allocate_result. Perform error checking at EOF. (gpgme_op_delete_start): Release result. * passphrase.c (_gpgme_passphrase_status_handler): Use macro test_and_allocate_result, and perform error checking here. (_gpgme_passphrase_result): Function removed. * sign.c (gpgme_op_sign_start): Do not set out_of_core to zero. (gpgme_op_sign): Just return the error value from the context. (sign_status_handler): Only progress if no error is set yet. If we process an EOF, set the resulting error value (if any). * decrypt.c (_gpgme_decrypt_result): Function removed. (create_result_struct): Function removed. (_gpgme_decrypt_status_handler): Use macro test_and_allocate_result, caclulate error on EOF, do not progress with errors. (_gpgme_decrypt_start): Do not set out_of_core to zero. (gpgme_op_decrypt): Just return the error value from the context. * encrypt.c (encrypt_status_handler): Perform the error checking here. (gpgme_op_encrypt_start): Do not clear out_of_core. * export.c (export_status_handler): Return if error is set in context. (gpgme_op_export_start): Release result. (gpgme_op_export): Return error from context. * decrypt-verify.c (gpgme_op_decrypt_verify): Return the error in the context. * genkey.c (genkey_status_handler): Use macro test_and_allocate_result. Perform error checking at EOF. (gpgme_op_genkey): Just return the error from context. * import.c (gpgme_op_import): Return the error from context. (import_status_handler): Use macro test_and_allocate_result. * keylist.c (gpgme_op_keylist_start): Do not clear out_of_core. (gpgme_op_keylist_next): Return error of context. (keylist_colon_handler): Set error instead out_of_code. (finish_key): Likewise. * context.h: Remove member out_of_core, add member error. * gpgme.c (_gpgme_release_result): Clear error flag. * engine.h (_gpgme_engine_get_error): New prototype. * engine.c (_gpgme_engine_get_error): New function. * engine-gpgsm.c (_gpgme_gpgsm_get_error): New function. * engine-gpgsm.c (map_assuan_error): New function. (gpgsm_assuan_simple_command): Change return type to GpgmeError, use the new function to map error values. (gpgsm_set_fd): Change return type tp GpgmeError. (_gpgme_gpgsm_op_decrypt): Change type of ERR to GpgmeError. (gpgsm_set_recipients): Likewise. Change type of return value equivalently. Adjust error values. (_gpgme_gpgsm_op_import): Likewise. (_gpgme_gpgsm_op_sign): Likewise. (struct gpgsm_object_s): New member error. (gpgsm_status_handler): Set error if error occurs. Determine error number from ERR line received. If assuan_read_line fails, terminate the connection. 2002-02-01 Marcus Brinkmann * Makefile.am (MOSTLYCLEANFILES): New variable. 2002-02-01 Marcus Brinkmann * engine-gpgsm.c (gpgsm_status_handler): At error, terminate the connection to the server. 2002-01-31 Marcus Brinkmann * rungpg.h: Add STATUS_KEY_CREATED. * progress.c: New file. * Makefile.am (libgpgme_la_SOURCES): Add progress.c. * genkey.c (genkey_status_handler): Use _gpgme_progress_status_handler. Add check for status. (struct genkey_result_s): New structure. (_gpgme_release_genkey_result): New function. (gpgme_op_genkey): Check for error. * gpgme.c (_gpgme_release_result): Call _gpgme_release_genkey_result. * ops.h (_gpgme_release_genkey_result): Add prototype. * types.h (GenKeyResult): New type. * context.h (gpgme_context_s): Add GenKeyResult to member result. 2002-01-30 Marcus Brinkmann * gpgme.c (_gpgme_release_result): Call _gpgme_release_delete_result. * ops.h (_gpgme_release_delete_result): Add prototype. * types.h (DeleteResult): New type. * context.h (gpgme_context_s): Add DeleteResult to member result. * delete.c (enum delete_problem): New type. (struct delete_result_s): New structure. (_gpgme_release_delete_result): New function. (delete_status_handler): Implement more status codes. (gpgme_op_delete): Return error on failure. * import.c (MAX_IMPORTED_FIELDS): Bump up to 14. 2002-01-30 Marcus Brinkmann * import.c (struct import_result_s): New structure. (_gpgme_release_import_result): New function. (append_xml_impinfo): Likewise. (import_status_handler): Implement. * gpgme.c (_gpgme_release_result): Add call to _gpgme_release_import_result. * ops.h (_gpgme_release_import_result): Add prototype. * types.h (ImportResult): New type. * context.h (gpgme_context_s): Add ImportResult to member result. * encrypt.c (gpgme_op_encrypt): Code clean up. 2002-01-30 Marcus Brinkmann * gpgme.h: Add lots of comment and fix the formatting. Add gpgme_trustlist_end prototype. 2002-01-29 Marcus Brinkmann * gpgme.h: Add new type GpgmeIdleFunc. Change type of gpgme_register_idle to return and accept this type. * wait.c (gpgme_register_idle): Fix type. Save and return old value of idle_function. 2002-01-29 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Implement secret only mode. * keylist.c (keylist_colon_handler): Add support for the new "crs" record type. 2002-01-22 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_release): Call assuan_disconnect, not assuan_pipe_disconnect. * Makefile.am (libgpgme_la_LIBADD): Change to link assuan and jnlib (needed by assuan) statically into libgpgme. Linking a static library into a shared library this way is not portable. 2002-01-22 Marcus Brinkmann * gpgme.h (GpgmePassphraseCb): Change type of R_HD from void* to void**. 2002-01-22 Marcus Brinkmann * data.c (gpgme_data_new_from_filepart): Change type of LENGTH from off_t to size_t. * gpgme.h: Likewise. 2002-01-22 Marcus Brinkmann * wait.c (_gpgme_wait_on_condition): If the process finished, reset the pending flag. Also if the operation was cancelled. (struct proc_s): Rename READY to DONE. (wait_item_s): Likewise. (set_process_ready): Rename to ... (set_process_done): ... this. (_gpgme_remove_proc_from_wait_queue): Call set_process_done instead set_process_ready. (_gpgme_wait_on_condition): Likewise. (do_select): Rename READY to DONE. * verify.c (gpgme_op_verify): Do not set pending to zero here. * sign.c (gpgme_op_sign): Likewise. * import.c (gpgme_op_import): Likewise. * genkey.c (gpgme_op_genkey): Likewise. * export.c (gpgme_op_export): Likewise. * encrypt.c (gpgme_op_encrypt): Likewise. * delete.c (gpgme_op_delete): Likewise. * decrypt-verify.c (gpgme_op_decrypt_verify): Likewise. * decrypt.c (gpgme_op_decrypt): Likewise. 2002-01-22 Marcus Brinkmann * export.c: Cleanup. 2002-01-15 Marcus Brinkmann * trustlist.c: Various source clean ups. (my_isdigit): Removed. (gpgme_op_trustlist_end): New function. 2002-01-13 Marcus Brinkmann * gpgme.c: Various source clean ups, like renaming C to CTX where appropriate. (gpgme_new): Clear R_CTX before starting the work. (my_isdigit): Removed. (my_isxdigit): Likewise. * data.c: Various source clean ups. (gpgme_data_new_from_mem): Check BUFFER after clearing R_DH. (gpgme_data_new_with_read_cb): Similar for READ_CB. (gpgme_data_new_from_file): Loop over fread while EINTR. (gpgme_data_new_from_filepart): Rediddled a bit. Allow LENGTH to be zero. Loop over fread while EINTR. (my_isdigit): Removed. (my_isxdigit): Likewise. 2001-12-21 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_new): Replace General_Error with Pipe_Error where appropriate. 2001-12-19 Marcus Brinkmann * engine.c: Include `string.h'. Reported by Stéphane Corthésy. * version.c (get_engine_info): Remove prototype. 2001-12-19 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_new): New variable CHILD_FDS. Fill it with the servers fds, and pass it to assuan_pipe_connect. 2001-12-18 Marcus Brinkmann * keylist.c (gpgme_op_keylist_end): New function. * gpgme.h (gpgme_op_keylist_end): New prototype. * engine.h (gpgme_engine_check_version): Move prototype to ... * gpgme.h (gpgme_engine_check_version): ... here. * genkey.c (gpgme_op_genkey_start): Remove unused variable. 2001-12-18 Marcus Brinkmann * version.c (gpgme_get_engine_info): Reimplemented. (gpgme_check_engine): Reimplemented. (_gpgme_compare_versions): Return NULL if MY_VERSION is NULL. * engine.c: Include `io.h'. (gpgme_engine_get_info): New function. * engine.h (gpgme_engine_check_version, _gpgme_engine_get_info): Add prototype. 2001-12-18 Marcus Brinkmann * rungpg.c (struct reap_s, reap_list, reap_list_lock): Moved to ... * engine.c (struct reap_s, reap_list, reap_list_lock): ... here. Include `time.h', `sys/types.h', `assert.h', and `sema.h'. * rungpg.c (_gpgme_engine_add_child_to_reap_list): New function. (do_reaping, _gpgme_gpg_housecleaning): Moved to ... * engine.c (do_reaping, _gpgme_engine_housecleaning): ... here. * rungpg.c (_gpgme_gpg_release): Replace code that is now in its own function by call to _gpgme_engine_add_child_to_reap_list(). * wait.c: Include `engine.h'. (run_idle): Call _gpgme_engine_housecleaning(), not _gpgme_gpg_housecleaning(). 2001-12-18 Marcus Brinkmann * key.c (_gpgme_key_append_name): Append, not prepend, the uid. Initialize the next field of the uid structure. (gpgme_key_get_as_xml): Do not list last uid first. 2001-12-17 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New function [!ENABLE_GPGSM]. 2001-12-14 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Put TEXT into message_data, not SIG. (_gpgme_gpgsm_op_sign): Use `--detached', not `--detach'. * sign.c (sign_status_handler): Call _gpgme_passphrase_status_handler early. 2001-12-14 Marcus Brinkmann * engine-gpgsm.c: Revert last change. 2001-12-14 Marcus Brinkmann * engine-gpgsm.c (gpgsm_status_handler): Freeze the output file handler when ending this operation, otherwise the wait function will sit on it. 2001-12-14 Marcus Brinkmann * engine-gpgsm.c (struct gpgsm_object_s): New member colon.attic. (_gpgme_gpgsm_new): Initialize some more members. (_gpgme_gpgsm_release): Free the colon line handler's attic line. (gpgsm_status_handler): Rework the inline-data processing. 2001-12-13 Marcus Brinkmann * rungpg.c (_gpgme_gpg_spawn): Do not add the fds to the child list that are not dup'ed, for those the close-on-exec flag is set now. * version.c (_gpgme_get_program_version): Remove first entry in CFD, as the close-on-exec flag is now set for this fd. 2001-12-13 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): Do not add `armor' option to `ENCRYPT'. * engine-gpgsm.c (gpgsm_set_recipients): Free LINE when returning successfully. 2001-12-13 Marcus Brinkmann * engine-gpgsm.c (close_notify_handler): New function. (_gpgme_gpgsm_new): Manage the file descriptors a bit differently. Do not set close-on-exec flags. (_gpgme_gpgsm_op_decrypt): Do not set message_fd to -1, this is done by the close handler. (_gpgme_gpgsm_op_encrypt): Likewise. (_gpgme_gpgsm_op_import): Likewise (also for output_fd). (_gpgme_gpgsm_op_keylist): Likewise (also for input_fd and output_fd). (_gpgme_gpgsm_op_sign): Likewise. (_gpgme_gpgsm_op_verify): Likewise, but for output_fd. * posix-io.c (_gpgme_io_pipe): Set the close-on-exec flag for the non-inherited file descriptor index of the pipe. 2001-12-13 Werner Koch * engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New. (gpgsm_status_handler): Pass datalines to a colon handler * engine.c (_gpgme_engine_set_colon_line_handler): Set the colon handler for gpgsm. * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Allow NULL for pattern. (gpgsm_assuan_simple_command): Removed underscore from assuan_write_line. (_gpgme_gpgsm_start): Ditto. (gpgsm_assuan_simple_command): Replaced interal Assuan read function by the new assuan_read_line. Removed the use of the internal header. (gpgsm_status_handler): Ditto. Use the new assuan_pending_line. (_gpgme_gpgsm_start): Use the documented way to get an fd from assuan. * keylist.c (keylist_colon_handler): Handle "crt" records * key.h (gpgme_key_s): Add an x509 flag. * key.c (parse_x509_user_id): New. (_gpgme_key_append_name): Handle x.509 names. 2001-12-05 Marcus Brinkmann * engine-gpgsm.c (gpgsm_status_handler): Make it work with current version of assuan. 2001-12-05 Marcus Brinkmann * engine-gpgsm.c (gpgsm_set_fd): Accept one more argument OPT. (_gpgme_gpgsm_op_encrypt): Pass armor argument to gpgsm_set_fd for output descriptor. (_gpgme_gpgsm_op_sign): Likewise. 2001-12-05 Marcus Brinkmann * keylist.c (gpgme_op_keylist_next): Set pending to 0 if EOF occurs. 2001-11-26 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Fix stupid typo. 2001-11-24 Marcus Brinkmann * engine-gpgsm.c (gpgsm_status_handler): Don't break if bsearch fails. Deal with assuan read line returning more than one line (for now). 2001-11-23 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement it according to the current protocol definition. 2001-11-23 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_new): Set CLOEXEC flag for parent ends of the pipe. 2001-11-22 Marcus Brinkmann * engine-gpgsm.c: Include stdlib.h and string.h. Also include, for now, rungpg.h and status-table.h. (gpgsm_status_handler): Implement more of the status handler. 2001-11-22 Marcus Brinkmann * engine.c (_gpgme_engine_op_decrypt): Implement CMS case. (_gpgme_engine_op_delete): Likewise. (_gpgme_engine_op_encrypt): Likewise. (_gpgme_engine_op_export): Likewise. (_gpgme_engine_op_genkey): Likewise. (_gpgme_engine_op_keylist): Likewise. (_gpgme_engine_op_sign): Likewise. (_gpgme_engine_op_trustlist): Likewise. * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): New function. (gpgsm_assuan_simple_command): Likewise. (gpgsm_set_recipients): Likewise. (gpgsm_set_fd): Reimplement using gpgsm_assuan_simple_command. (_gpgme_gpgsm_op_delete): New function. (_gpgme_gpgsm_op_export): Likewise. (_gpgme_gpgsm_op_genkey): Likewise. (_gpgme_gpgsm_op_sign): Likewise. (_gpgme_gpgsm_op_keylist): Likewise. (_gpgme_gpgsm_op_trustlist): Likewise. (_gpgme_gpgsm_release): Release command. (_gpgme_gpgsm_op_decrypt): Allocate command. (_gpgme_gpgsm_op_import): Likewise. (gpgsm_status_handler): Also treat `ERR' strings as EOF. 2001-11-22 Marcus Brinkmann * gpgme.h (gpgme_set_protocol): New prototype. 2001-11-22 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_op_decrypt): New function. (_gpgme_gpgsm_op_import): Likewise. 2001-11-22 Marcus Brinkmann * engine-gpgsm.c: Shuffle around header inclusion a bit, to still keep them seperate. (_gpgme_set_status_handler) [!ENABLE_GPGSM]: New function. 2001-11-22 Werner Koch * engine-gpgsm.c: Include more headers so that NULL and mk_error is defined even with an undefined GPGSM_PATH. 2001-11-22 Marcus Brinkmann * rungpg.c (gpg_inbound_handler, write_mem_data, write_cb_data, gpg_outbound_handler): Moved to ... * data.c (_gpgme_data_inbound_handler, write_mem_data, write_cb_data, _gpgme_data_outbound_handler): ... here. Make the _gpgme_* ones non-static. * data.c: Include io.h. * ops.h (_gpgme_data_inbound_handler): New prototype. (_gpgme_data_outbound_handler): Likewise. (_gpgme_gpg_spawn): Use these new functions. * engine-gpgsm.h (_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete, _gpgme_gpgsm_op_encrypt, _gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey, _gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist, _gpgme_gpgsm_op_sign, _gpgme_gpgsm_op_trustlist, _gpgme_gpgsm_op_verify, _gpgme_gpgsm_start, _gpgme_gpgsm_set_status_handler): New prototype. Include for status handler function. * engine-gpgsm.c (struct gpgsm_object_s): New members input_fd, input_data, output_fd, output_data, message_fd, message_data, command and status. (_gpgme_gpgsm_new): Open input, output and message pipes before connecting to the client. Close server's ends afterwards. (_gpgme_gpgsm_release): Close open file descriptors. Remove server process from wait queue. (_gpgme_gpgsm_op_verify, _gpgme_gpgsm_start, _gpgme_gpgsm_set_status_handler, gpgms_status_handler): New function. * engine.c (_gpgme_engine_start): Implement for GPGME_PROTOCOL_CMS. (_gpgme_engine_set_status_handler): Likewise. (_gpgme_engine_op_verify): Likewise. 2001-11-21 Marcus Brinkmann * context.h: Do not include rungpg.h, but engine.h. (struct gpgme_context_s): Replace member gpg with engine. * gpgme.c (gpgme_release): Release engine, not gpg. * recipient.c (_gpgme_append_gpg_args_from_recifgpients): Function moved ... * rungpg.c (_gpgme_append_gpg_args_from_recipients): ... here. Make static, change order of arguments, and return an error value. * ops.h (_gpgme_append_gpg_args_from_recipients): Removed prototype. * rungpg.h (_gpgme_gpg_op_verify): Add prototype. (_gpgme_gpg_op_encrypt): Likewise. (_gpgme_gpg_op_decrypt): Likewise. (_gpgme_gpg_op_delete): Likewise. (_gpgme_gpg_op_export): Likewise. (_gpgme_gpg_op_genkey): Likewise. (_gpgme_gpg_op_import): Likewise. (_gpgme_gpg_op_keylist): Likewise. (_gpgme_gpg_op_sign): Likewise. (_gpgme_gpg_op_trustlist): Likewise. * rungpg.c (_gpgme_gpg_op_verify): New function. (_gpgme_gpg_op_encrypt): Likewise. (_gpgme_gpg_op_decrypt): Likewise. (_gpgme_gpg_op_delete): Likewise. (_gpgme_gpg_op_export): Likewise. (_gpgme_gpg_op_genkey): Likewise. (_gpgme_gpg_op_import): Likewise. (_gpgme_gpg_op_keylist): Likewise. (_gpgme_gpg_op_sign): Likewise. (_gpgme_gpg_op_trustlist): Likewise. * engine.h (_gpgme_engine_set_status_handler): Add prototype. (_gpgme_engine_set_command_handler): Likewise. (_gpgme_engine_set_colon_line_handler): Likewise. (_gpgme_engine_op_decrypt): Likewise. (_gpgme_engine_op_delete): Likewise. (_gpgme_engine_op_encrypt): Likewise. (_gpgme_engine_op_export): Likewise. (_gpgme_engine_op_genkey): Likewise. (_gpgme_engine_op_import): Likewise. (_gpgme_engine_op_keylist): Likewise. (_gpgme_engine_op_sign): Likewise. (_gpgme_engine_op_trustlist): Likewise. (_gpgme_engine_op_verify): Likewise. (_gpgme_engine_start): Likewise. * engine.c (_gpgme_engine_set_status_handler): New function. (_gpgme_engine_set_command_handler): Likewise. (_gpgme_engine_set_colon_line_handler): Likewise. (_gpgme_engine_op_decrypt): Likewise. (_gpgme_engine_op_delete): Likewise. (_gpgme_engine_op_encrypt): Likewise. (_gpgme_engine_op_export): Likewise. (_gpgme_engine_op_genkey): Likewise. (_gpgme_engine_op_import): Likewise. (_gpgme_engine_op_keylist): Likewise. (_gpgme_engine_op_sign): Likewise. (_gpgme_engine_op_trustlist): Likewise. (_gpgme_engine_op_verify): Likewise. (_gpgme_engine_start): Likewise. * verify.c (gpgme_op_verify_start): Reimplement in terms of above functions. * encrypt.c (gpgme_op_encrypt_start): Likewise. * decrypt.c (_gpgme_decrypt_start): Likewise. * passphrase.c (_gpgme_passphrase_start): Likewise. * keylist.c (gpgme_op_keylist_start): Likewise. 2001-11-20 Marcus Brinkmann * types.h: Add types EngineObject and GpgsmObject. * Makefile.am (libgpgme_la_SOURCES): Add engine-gpgsm.h, engine-gpgsm.c, engine.h and engine.c. * engine.h: New file. * engine.c: Likewise. * engine-gpgsm.h: Likewise. * engine-gpgsm.c: Likewise. * rungpg.c (_gpgme_gpg_get_version): New function. (_gpgme_gpg_check_version): Likewise. * rungpg.h: Add prototypes for _gpgme_gpg_get_version and _gpgme_gpg_check_version. * version.c (compare_versions): Rename to ... (_gpgme_compare_versions): ... this. Make non-static. (gpgme_check_version): Use _gpgme_compare_versions rather than compare_versions. (gpgme_check_engine): Likewise. * ops.h (_gpgme_get_program_version): Add prototype. 2001-11-20 Marcus Brinkmann * Makefile.am (libgpgme_la_INCLUDES): Remove obsolete directive. (AM_CPPFLAGS): New directive [BUILD_ASSUAN]. (libgpgme_la_LIBADD): Likewise. 2001-11-20 Marcus Brinkmann * version.c: Remove global variables lineno and tmp_engine_version. (version_handler): Removed. (_gpgme_get_program_version): New function. (get_engine_info): Don't use context and version_handler, but _gpgme_get_program_version. * ops.h (_gpgme_get_program_version): Add prototype for _gpgme_get_program_version (we expect to use it elsewhere soon). 2001-11-18 Marcus Brinkmann * version.c (get_engine_info): If GnuPG is not available, return an error message. * posix-util.c (_gpgme_get_gpg_path): Allow GPG_PATH to be undefined. (_gpgme_get_gpgsm_path): New function. * w32-util.c (find_program_in_registry): New static function. (_gpgme_get_gpg_path): Allow GPG_PATH to be undefined. Rework to use find_program_in_registry. (_gpgme_get_gpgsm_path): New function. (util.h): Prototype _gpgme_get_gpgsm_path). * rungpg.c (_gpgme_gpg_spawn): Verify that _gpgme_get_gpg_path() returns non-null. 2001-11-16 Marcus Brinkmann * decrypt-verify.c: New file. * Makefile.am (libgpgme_la_SOURCES): Add decrypt-verify.c. * types.h: Add decrypt-verify types. * ops.h: Likewise. * context.h: Add result type for decrypt-verify. * gpgme.h: Add decrypt-verify prototypes. * decrypt.c (decrypt_status_handler): Renamed to ... (_gpgme_decrypt_status_handler): ... this. Make non-static. (_gpgme_decrypt_start): New function, derived from gpgme_op_decrypt_start. (gpgme_op_decrypt_start): Reimplement in terms of _gpgme_decrypt_start. (_gpgme_decrypt_result): New function to retrieve error value. (gpgme_op_decrypt): Use _gpgme_decrypt_result. * ops.h: Add prototypes for new functions. * verify.c (verify_status_handler): Renamed to ... (_gpgme_verify_status_handler): ... this. Make non-static. (gpgme_op_verify_start): Use new function name. (intersect_stati): Renamed to ... (_gpgme_intersect_stati): ... this. Make non-static. (gpgme_op_verify): Use new name. * ops.h: Add prototypes for new functions. 2001-11-16 Marcus Brinkmann * passphrase.c: New file. * Makefile.am (libgpgme_la_SOURCES): Add passphrase.c. * ops.h (_gpgme_passphrase_result): Add prototypes from passphrase.c. * types.h: Likewise. * context.h: Add member passphrase to result. * gpgme.c (_gpgme_release_result): Release passphrase member. * decrypt.c: Some formatting and variable name changes (like CTX instead C). (struct decrypt_result_s): Remove members now found in passphrase result. (_gpgme_release_decrypt_result): Don't release removed members. (decrypt_status_handler): Call _gpgme_passphrase_status_handler, and don't handle the cases catched there. (command_handler): Removed. (gpgme_op_decrypt_start): Don't set command handler, but invoke _gpgme_passphrase_start which does it. (gpgme_op_decrypt): Invoke _gpgme_passphrase_result and drop the cases covered by it. * sign.c Some formatting and variable name changes (like CTX instead C). (struct sign_result_s): Remove members now found in passphrase result. (_gpgme_release_sign_result): Don't release removed members. (sign_status_handler): Call _gpgme_passphrase_status_handler, and don't handle the cases catched there. (command_handler): Removed. (gpgme_op_sign_start): Don't set command handler, but invoke _gpgme_passphrase_start which does it. (gpgme_op_sign): Invoke _gpgme_passphrase_result and drop the cases covered by it. 2001-11-15 Marcus Brinkmann * decrypt.c (command_handler): Fix last change. 2001-11-15 Marcus Brinkmann * verify.c (_gpgme_release_verify_result): Rename RES to RESULT. Rename R2 to NEXT_RESULT. (intersect_stati): Rename RES to RESULT. (gpgme_get_sig_status): Likewise. Do not check return_type, but the member verify of result. (gpgme_get_sig_key): Likewise. * sign.c (_gpgme_release_sign_result): Rename RES to RESULT. If RESULT is zero, return. (sign_status_handler, command_handler): Do not check return_type, but the member sign of result. (gpgme_op_sign): Likewise. Drop assertion. * encrypt.c (_gpgme_release_encrypt_result): Rename RES to RESULT. If RESULT is zero, return. (encrypt_status_handler): Do not check return_type, but the member encrypt of result. (gpgme_op_encrypt): Likewise. Drop assertion. * decrypt.c (_gpgme_release_decrypt_result): Rename RES to RESULT. (create_result_struct): Do not set result_type. (command_handler, decrypt_status_handler): Do not check return_type, but the member decrypt of result. (gpgme_op_decrypt): Likewise. Drop assertion. * context.h (enum ResultType): Removed. (struct gpgme_context_s): Remove member result_type. (struct result): Replaces union result. * gpgme.c: Include string.h. (_gpgme_release_result): Release all members of c->result, which is now a struct. Zero out all members of the struct afterwards. 2001-11-11 Marcus Brinkmann * rungpg.c (_gpgme_gpg_release): Release GPG->cmd.cb_data. Release all members of the list GPG->arglist. Reported by Michael Schmidt . 2001-11-02 Marcus Brinkmann * rungpg.c (pipemode_copy): Change type of NBYTES to size_t. * key.c: Include string.h. * data.c: Likewise. * recipient.c: Likewise. 2001-10-29 Marcus Brinkmann * context.h: New member signers_len. * signers.c (gpgme_signers_clear): Require that signers are non-NULL with assertion. Use signers_len to determine how much keys to release. Add documentation. (gpgme_signers_add): Use signers_len to determine if the buffer is large enough. Use xtryrealloc rather than xtrymalloc and copying. Add documentation. (gpgme_signers_enum): Use signers_len to determine if key is available. Add documentation. 2001-10-22 Marcus Brinkmann * data.c (_gpgme_data_append): Check if LENGTH is smaller than ALLOC_CHUNK, not DH->length. 2001-10-17 Marcus Brinkmann * gpgme.c (gpgme_set_protocol): Fix last change. 2001-10-15 Werner Koch * gpgme.h (GpgmeProtocol): New. * gpgme.c (gpgme_set_protocol): New. 2001-09-26 Werner Koch * gpgme.c (gpgme_set_passphrase_cb): Ignore a NULL context. (gpgme_set_progress_cb): Ditto. Suggested by Mark Mutz. 2001-09-17 Werner Koch * keylist.c (finish_key): Shortcut for no tmp_key. Changed all callers to use this function without a check for tmp_key. * keylist.c (gpgme_op_keylist_next): Reset the key_cond after emptying the queue. Bug reported by Stéphane Corthésy. 2001-09-12 Werner Koch * data.c (gpgme_data_rewind): Allow rewind for callbacks. 2001-09-07 Werner Koch * rungpg.h: Add NO_RECP. * encrypt.c (encrypt_status_handler): Take on No_RECP. (gpgme_op_encrypt): Better error return. * verify.c (verify_status_handler): Take on NODATA. 2001-09-03 Werner Koch * rungpg.h: Added STATUS_INV_RECP. * gpgme.c (_gpgme_release_result): Add support for new EncryptResult object. * encrypt.c (append_xml_encinfo): New. (encrypt_status_handler): Add some status parsing. (_gpgme_release_encrypt_result): New. 2001-08-29 Werner Koch * recipient.c (gpgme_recipients_release): Free the list. By Timo. * keylist.c (keylist_colon_handler): Do a finish key if we receive an EOF here. This is probably the reason for a lot of bugs related to keylisting. It is so obvious. Kudos to Enno Cramer for pointing that out. 2001-08-28 Werner Koch * gpgme.c, gpgme.h (gpgme_get_op_info): New. (_gpgme_set_op_info): New. (_gpgme_release_result): Reset the op_info here. * sign.c (append_xml_siginfo): New. (sign_status_handler): Store the sig create information. 2001-07-31 Werner Koch * encrypt.c (gpgme_op_encrypt): Hack to detect no valid recipients. 2001-07-30 Werner Koch * gpgme.c (gpgme_get_armor,gpgme_get_textmode): New. * rungpg.c (build_argv): Disable armor comments * w32-io.c (build_commandline): Need to add quotes here 2001-07-24 Werner Koch * data.c (gpgme_data_read): Add a a way to return the available bytes. 2001-07-23 Werner Koch * util.c: Removed stpcpy() because we use the version from jnlib. 2001-07-19 Werner Koch * mkstatus: Define the collating sequence for sort. 2001-06-26 Werner Koch * rungpg.h: Add STATUS_UNEXPECTED as suggested by Timo. 2001-06-15 Werner Koch * keylist.c (set_userid_flags): Fixed the assigned values. Kudos to Timo for pointing this out. 2001-06-01 Werner Koch * debug.c (_gpgme_debug_begin): Fixed a /tmp race. Noted by Johannes Poehlmann. 2001-05-28 Werner Koch * version.c (gpgme_check_engine): Stop version number parsing at the opening angle and not the closing one. By Tommy Reynolds. 2001-05-01 José Carlos García Sogo * encrypt.c (gpgme_op_encrypt_start): Deleted the assert ( !c->gpg ) line, because it gave an error if another operation had been made before using the same context. * decrypt.c (gpgme_op_decrypt_start): The same as above. Also added one line to release the gpg object in the context (if any). 2001-04-26 Werner Koch * key.c, key.h (_gpgme_key_cache_init): New. (_gpgme_key_cache_add): New. (_gpgme_key_cache_get): New. * version.c (do_subsystem_inits): Init the cache. * keylist.c (finish_key): Put key into the cache * verify.c (gpgme_get_sig_key): First look into the cache. 2001-04-19 Werner Koch * keylist.c (parse_timestamp): Adjusted for the changed --fixed-list-mode of gpg 1.0.4h. 2001-04-05 Werner Koch * verify.c (gpgme_op_verify_start): Enabled pipemode for detached sigs. 2001-04-04 Werner Koch * w32-io.c (_gpgme_io_select): Don't select on the writer if there are still bytes pending. Timo found this not easy to track down race condition. 2001-04-02 Werner Koch * gpgme.h: Add GPGME_ATTR_KEY_{EXPIRED,DISABLED}. * key.c (gpgme_key_get_ulong_attr): And return those attribs. * verify.c (gpgme_get_sig_key): Set keyliosting mode depending on the mode set in the current context. Suggested by Timo. * key.c (gpgme_key_get_ulong_attr): Return can_certify and not can_encrypt. By Timo. 2001-03-30 Werner Koch * debug.c (debug_init): Allow to specify a debug file. (_gpgme_debug_level): New. * posix-io.c (_gpgme_io_read, _gpgme_io_write): Print output. (_gpgme_io_select): Debug only with level > 2. 2001-03-15 Werner Koch * rungpg.c: Included time.h. * key.h: New keyflags for capabilities. * keylist.c (set_mainkey_capability, set_subkey_capability): New. (keylist_colon_handler): Parse them. * gpgme.h: New attribute values for capabilties. * key.c (gpgme_key_get_string_attr): Return them. (capabilities_to_string): New. (gpgme_key_get_ulong_attr): Return the global caps. 2001-03-14 Werner Koch * w32-io.c (destroy_reader,destroy_writer): Fixed syntax error. Thanks to Jan Oliver Wagner. 2001-03-13 Werner Koch * context.h: Add invalid and revoke flags to user_id structure. * keylist.c (gpgme_op_keylist_start): Use --fixed-list-mode. (keylist_colon_handler): Adjust for that. (set_userid_flags): New. (set_mainkey_trust_info): Handle new key invalid flag (set_subkey_trust_info): Ditto. * gpgme.h: Add new attributes for key and user ID flags. * key.c (_gpgme_key_append_name): Init these flags (gpgme_key_get_as_xml): Print them. (one_uid_as_xml): New helper for above. (gpgme_key_get_string_attr, gpgme_key_get_ulong_attr): Return the new attributes. Enhanced, so that subkey information can be returned now. 2001-02-28 Werner Koch * w32-io.c (destroy_reader): Set stop_me flag. (writer,create_writer,destroy_writer,find_writer,kill_writer): New. (_gpgme_io_write): Use a writer thread to avaoid blocking. (_gpgme_io_close): Cleanup a writer thread (_gpgme_io_select): Repalce tthe faked wait on writing by a real waiting which is now possible due to the use of a writer thread. 2001-02-20 Werner Koch * w32-io.c (destroy_reader,kill_reader): New. (create_reader, reader): Add a new event to stop the thread. (_gpgme_io_close): Kill the reader thread. * posix-io.c (_gpgme_io_select): Handle frozen fds here. * 32-io.c (_gpgme_io_select): Ditto. Removed a bunch of unused code. * wait.c: Reworked the whole thing. * rungpg.c (_gpgme_gpg_new): Init pid to -1. (_gpgme_gpg_release): Remove the process from the wait queue. 2001-02-19 Werner Koch * w32-io.c (_gpgme_io_set_close_notify): New. (_gpgme_io_close): Do the notification. * posix-io.c (_gpgme_io_select): Use a 1 sec timeout and not 200 microseconds. * wait.c (remove_process): Don't close the fd here. (do_select): Set the fd to -1 and remove the is_closed flag everywhere. (_gpgme_wait_on_condition): Remove the assert on the queue and break out if we could not find the queue. The whole thing should be reworked. * posix-io.c (_gpgme_io_set_close_notify): New. (_gpgme_io_close): Do the notification. * rungpg.c (close_notify_handler): New. (_gpgme_gpg_new): Register a callback for the fd. (_gpgme_gpg_set_colon_line_handler): Ditto. (build_argv): Ditto 2001-02-13 Werner Koch * rungpg.c (struct reap_s): Replaced pid_t by int. * types.h: Add ulong typedef. * rungpg.c (do_reaping,_gpgme_gpg_housecleaning): New. (_gpgme_gpg_release): Reap children. * io.h, posix-io.c (_gpgme_io_kill): New. * w32-io.c (_gpgme_io_kill): New (dummy). * keylist.c (gpgme_op_keylist_start): Cancel a pending request. * posix-io.c (_gpgme_io_read): Add some debug output. (_gpgme_io_write): Ditto. (_gpgme_io_select): Increased the timeout. 2001-02-12 Werner Koch Enhanced the signature verification, so that it can how handle more than one signature and is able to return more information on the signatures. * verify.c (gpgme_get_sig_key): New. (gpgme_get_sig_status): New. * gpgme.h: Add stdio.h. (GpgmeSigStat): New status DIFF. 2001-02-01 Werner Koch * w32-io.c (set_synchronize): Add EVENT_MODIFY_STATE. Add Debug code to all Set/ResetEvent(). * rungpg.c (read_status): Check for end of stream only if we have an r. By Timo. 2001-01-31 Werner Koch * wait.c (_gpgme_wait_on_condition): Removed all exit code processing. (propagate_term_results,clear_active_fds): Removed. (count_active_fds): Renamed to .. (count_active_and_thawed_fds): .. this and count only thawed fds. * rungpg.c (gpg_colon_line_handler): Return colon.eof and not status.eof ;-) 2001-01-30 Werner Koch * w32-io.c (_gpgme_io_spawn): Use the supplied path arg. * version.c (get_engine_info): Return better error information. * posix-util.c, w32-util.c: New. (_gpgme_get_gpg_path): New, suggested by Jan-Oliver. * rungpg.c (_gpgme_gpg_spawn): Use new function to get GPG's path. * signers.c (gpgme_signers_add): Ooops, one should test code and not just write it; the newarr was not assigned. Thanks to José for pointing this out. Hmmm, still not tested, why shoudl a coder test his fix :-) * w32-io.c: Does now use reader threads, so that we can use WaitForMultipleObjects. * sema.h, posix-sema.c, w32-sema.c: Support for Critcial sections. Does currently only work for W32. * debug.c, util.h : New. Changed all fprintfs to use this new set of debugging functions. 2001-01-23 Werner Koch * data.c (_gpgme_data_release_and_return_string): Fixed string termination. 2001-01-22 Werner Koch * delete.c: New. * signers.c: New. * key.c (gpgme_key_ref, gpgme_key_unref): New. * sign.c (gpgme_op_sign_start): Allow the use of other keys. * version.c (gpgme_get_engine_info,gpgme_check_engine): New. * rungpg.c (_gpgme_gpg_set_simple_line_handler): New. 2001-01-05 Werner Koch * data.c (gpgme_data_rewind): Allow to rewind data_type_none. Copyright 2001,2002,2003,2004,2005,2006,2007 g10 Code GmbH This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/gpgme/data-mem.c b/gpgme/data-mem.c index bc718065..b58a3c04 100644 --- a/gpgme/data-mem.c +++ b/gpgme/data-mem.c @@ -1,273 +1,280 @@ /* data-mem.c - A memory based data object. Copyright (C) 2002, 2003, 2004, 2007 g10 Code GmbH This file is part of GPGME. GPGME is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. GPGME is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "data.h" #include "util.h" #include "debug.h" static ssize_t mem_read (gpgme_data_t dh, void *buffer, size_t size) { size_t amt = dh->data.mem.length - dh->data.mem.offset; const char *src; if (!amt) return 0; if (size < amt) amt = size; src = dh->data.mem.buffer ? dh->data.mem.buffer : dh->data.mem.orig_buffer; memcpy (buffer, src + dh->data.mem.offset, amt); dh->data.mem.offset += amt; return amt; } static ssize_t mem_write (gpgme_data_t dh, const void *buffer, size_t size) { size_t unused; if (!dh->data.mem.buffer && dh->data.mem.orig_buffer) { size_t new_size = dh->data.mem.size; char *new_buffer; if (new_size < dh->data.mem.offset + size) new_size = dh->data.mem.offset + size; new_buffer = malloc (new_size); if (!new_buffer) return -1; memcpy (new_buffer, dh->data.mem.orig_buffer, dh->data.mem.length); dh->data.mem.buffer = new_buffer; dh->data.mem.size = new_size; } unused = dh->data.mem.size - dh->data.mem.offset; if (unused < size) { /* Allocate a large enough buffer with exponential backoff. */ #define INITIAL_ALLOC 512 size_t new_size = dh->data.mem.size ? (2 * dh->data.mem.size) : INITIAL_ALLOC; char *new_buffer; if (new_size < dh->data.mem.offset + size) new_size = dh->data.mem.offset + size; new_buffer = realloc (dh->data.mem.buffer, new_size); if (!new_buffer && new_size > dh->data.mem.offset + size) { /* Maybe we were too greedy, try again. */ new_size = dh->data.mem.offset + size; new_buffer = realloc (dh->data.mem.buffer, new_size); } if (!new_buffer) return -1; dh->data.mem.buffer = new_buffer; dh->data.mem.size = new_size; } memcpy (dh->data.mem.buffer + dh->data.mem.offset, buffer, size); dh->data.mem.offset += size; if (dh->data.mem.length < dh->data.mem.offset) dh->data.mem.length = dh->data.mem.offset; return size; } static off_t mem_seek (gpgme_data_t dh, off_t offset, int whence) { switch (whence) { case SEEK_SET: if (offset < 0 || offset > dh->data.mem.length) { errno = EINVAL; return -1; } dh->data.mem.offset = offset; break; case SEEK_CUR: if ((offset > 0 && dh->data.mem.length - dh->data.mem.offset < offset) || (offset < 0 && dh->data.mem.offset < -offset)) { errno = EINVAL; return -1; } dh->data.mem.offset += offset; break; case SEEK_END: if (offset > 0 || -offset > dh->data.mem.length) { errno = EINVAL; return -1; } dh->data.mem.offset = dh->data.mem.length - offset; break; default: errno = EINVAL; return -1; } return dh->data.mem.offset; } static void mem_release (gpgme_data_t dh) { if (dh->data.mem.buffer) free (dh->data.mem.buffer); } static struct _gpgme_data_cbs mem_cbs = { mem_read, mem_write, mem_seek, mem_release, NULL }; /* Create a new data buffer and return it in R_DH. */ gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh) { gpgme_error_t err; TRACE_BEG (DEBUG_DATA, "gpgme_data_new", r_dh); err = _gpgme_data_new (r_dh, &mem_cbs); if (err) return TRACE_ERR (err); return TRACE_SUC1 ("r_dh=%p", *r_dh); } /* Create a new data buffer filled with SIZE bytes starting from BUFFER. If COPY is zero, copying is delayed until necessary, and the data is taken from the original location when needed. */ gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh, const char *buffer, size_t size, int copy) { gpgme_error_t err; TRACE_BEG4 (DEBUG_DATA, "gpgme_data_new_from_mem", r_dh, "buffer=%p, size=%u, copy=%i (%s)", buffer, size, copy, copy ? "yes" : "no"); err = _gpgme_data_new (r_dh, &mem_cbs); if (err) return TRACE_ERR (err); if (copy) { char *bufcpy = malloc (size); if (!bufcpy) { int saved_errno = errno; _gpgme_data_release (*r_dh); return TRACE_ERR (gpg_error_from_errno (saved_errno)); } memcpy (bufcpy, buffer, size); (*r_dh)->data.mem.buffer = bufcpy; } else (*r_dh)->data.mem.orig_buffer = buffer; (*r_dh)->data.mem.size = size; (*r_dh)->data.mem.length = size; return TRACE_SUC1 ("dh=%p", *r_dh); } /* Destroy the data buffer DH and return a pointer to its content. The memory has be to released with gpgme_free() by the user. It's size is returned in R_LEN. */ char * gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len) { char *str = NULL; TRACE_BEG1 (DEBUG_DATA, "gpgme_data_release_and_get_mem", dh, "r_len=%p", r_len); if (!dh || dh->cbs != &mem_cbs) { gpgme_data_release (dh); TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE)); return NULL; } str = dh->data.mem.buffer; if (!str && dh->data.mem.orig_buffer) { str = malloc (dh->data.mem.length); if (!str) { int saved_errno = errno; gpgme_data_release (dh); TRACE_ERR (gpg_error_from_errno (saved_errno)); return NULL; } memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length); } else /* Prevent mem_release from releasing the buffer memory. We must not fail from this point. */ dh->data.mem.buffer = NULL; if (r_len) *r_len = dh->data.mem.length; gpgme_data_release (dh); - TRACE_SUC2 ("buffer=%p, len=%u", str, *r_len); + if (r_len) + { + TRACE_SUC2 ("buffer=%p, len=%u", str, *r_len); + } + else + { + TRACE_SUC1 ("buffer=%p", str); + } return str; } /* Release the memory returned by gpgme_data_release_and_get_mem(). */ void gpgme_free (void *buffer) { TRACE (DEBUG_DATA, "gpgme_free", buffer); if (buffer) free (buffer); } diff --git a/gpgme/verify.c b/gpgme/verify.c index 71221bb7..ef1ccd6c 100644 --- a/gpgme/verify.c +++ b/gpgme/verify.c @@ -1,1003 +1,1003 @@ /* verify.c - Signature verification. Copyright (C) 2000 Werner Koch (dd9jn) Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH This file is part of GPGME. GPGME is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. GPGME is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include "gpgme.h" #include "util.h" #include "context.h" #include "ops.h" typedef struct { struct _gpgme_op_verify_result result; gpgme_signature_t current_sig; int did_prepare_new_sig; int only_newsig_seen; int plaintext_seen; } *op_data_t; static void release_op_data (void *hook) { op_data_t opd = (op_data_t) hook; gpgme_signature_t sig = opd->result.signatures; while (sig) { gpgme_signature_t next = sig->next; gpgme_sig_notation_t notation = sig->notations; while (notation) { gpgme_sig_notation_t next_nota = notation->next; _gpgme_sig_notation_free (notation); notation = next_nota; } if (sig->fpr) free (sig->fpr); if (sig->pka_address) free (sig->pka_address); free (sig); sig = next; } if (opd->result.file_name) free (opd->result.file_name); } gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx) { void *hook; op_data_t opd; gpgme_error_t err; err = _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, -1, NULL); opd = hook; if (err || !opd) return NULL; return &opd->result; } /* Build a summary vector from RESULT. */ static void calc_sig_summary (gpgme_signature_t sig) { unsigned long sum = 0; /* Calculate the red/green flag. */ if (sig->validity == GPGME_VALIDITY_FULL || sig->validity == GPGME_VALIDITY_ULTIMATE) { if (gpg_err_code (sig->status) == GPG_ERR_NO_ERROR || gpg_err_code (sig->status) == GPG_ERR_SIG_EXPIRED || gpg_err_code (sig->status) == GPG_ERR_KEY_EXPIRED) sum |= GPGME_SIGSUM_GREEN; } else if (sig->validity == GPGME_VALIDITY_NEVER) { if (gpg_err_code (sig->status) == GPG_ERR_NO_ERROR || gpg_err_code (sig->status) == GPG_ERR_SIG_EXPIRED || gpg_err_code (sig->status) == GPG_ERR_KEY_EXPIRED) sum |= GPGME_SIGSUM_RED; } else if (gpg_err_code (sig->status) == GPG_ERR_BAD_SIGNATURE) sum |= GPGME_SIGSUM_RED; /* FIXME: handle the case when key and message are expired. */ switch (gpg_err_code (sig->status)) { case GPG_ERR_SIG_EXPIRED: sum |= GPGME_SIGSUM_SIG_EXPIRED; break; case GPG_ERR_KEY_EXPIRED: sum |= GPGME_SIGSUM_KEY_EXPIRED; break; case GPG_ERR_NO_PUBKEY: sum |= GPGME_SIGSUM_KEY_MISSING; break; case GPG_ERR_BAD_SIGNATURE: case GPG_ERR_NO_ERROR: break; default: sum |= GPGME_SIGSUM_SYS_ERROR; break; } /* Now look at the certain reason codes. */ switch (gpg_err_code (sig->validity_reason)) { case GPG_ERR_CRL_TOO_OLD: if (sig->validity == GPGME_VALIDITY_UNKNOWN) sum |= GPGME_SIGSUM_CRL_TOO_OLD; break; case GPG_ERR_CERT_REVOKED: sum |= GPGME_SIGSUM_KEY_REVOKED; break; default: break; } /* Check other flags. */ if (sig->wrong_key_usage) sum |= GPGME_SIGSUM_BAD_POLICY; /* Set the valid flag when the signature is unquestionable valid. */ if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN)) sum |= GPGME_SIGSUM_VALID; sig->summary = sum; } static gpgme_error_t prepare_new_sig (op_data_t opd) { gpgme_signature_t sig; if (opd->only_newsig_seen && opd->current_sig) { /* We have only seen the NEWSIG status and nothing else - we better skip this signature therefore and reuse it for the next possible signature. */ sig = opd->current_sig; memset (sig, 0, sizeof *sig); assert (opd->result.signatures == sig); } else { sig = calloc (1, sizeof (*sig)); if (!sig) return gpg_error_from_errno (errno); if (!opd->result.signatures) opd->result.signatures = sig; if (opd->current_sig) opd->current_sig->next = sig; opd->current_sig = sig; } opd->did_prepare_new_sig = 1; opd->only_newsig_seen = 0; return 0; } static gpgme_error_t parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) { gpgme_signature_t sig; char *end = strchr (args, ' '); char *tail; if (end) { *end = '\0'; end++; } if (!opd->did_prepare_new_sig) { gpg_error_t err; err = prepare_new_sig (opd); if (err) return err; } assert (opd->did_prepare_new_sig); opd->did_prepare_new_sig = 0; assert (opd->current_sig); sig = opd->current_sig; /* FIXME: We should set the source of the state. */ switch (code) { case GPGME_STATUS_GOODSIG: sig->status = gpg_error (GPG_ERR_NO_ERROR); break; case GPGME_STATUS_EXPSIG: sig->status = gpg_error (GPG_ERR_SIG_EXPIRED); break; case GPGME_STATUS_EXPKEYSIG: sig->status = gpg_error (GPG_ERR_KEY_EXPIRED); break; case GPGME_STATUS_BADSIG: sig->status = gpg_error (GPG_ERR_BAD_SIGNATURE); break; case GPGME_STATUS_REVKEYSIG: sig->status = gpg_error (GPG_ERR_CERT_REVOKED); break; case GPGME_STATUS_ERRSIG: /* Parse the pubkey algo. */ if (!end) goto parse_err_sig_fail; errno = 0; sig->pubkey_algo = strtol (end, &tail, 0); if (errno || end == tail || *tail != ' ') goto parse_err_sig_fail; end = tail; while (*end == ' ') end++; /* Parse the hash algo. */ if (!*end) goto parse_err_sig_fail; errno = 0; sig->hash_algo = strtol (end, &tail, 0); if (errno || end == tail || *tail != ' ') goto parse_err_sig_fail; end = tail; while (*end == ' ') end++; /* Skip the sig class. */ end = strchr (end, ' '); if (!end) goto parse_err_sig_fail; while (*end == ' ') end++; /* Parse the timestamp. */ sig->timestamp = _gpgme_parse_timestamp (end, &tail); if (sig->timestamp == -1 || end == tail || (*tail && *tail != ' ')) return gpg_error (GPG_ERR_INV_ENGINE); end = tail; while (*end == ' ') end++; /* Parse the return code. */ if (end[0] && (!end[1] || end[1] == ' ')) { switch (end[0]) { case '4': sig->status = gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM); break; case '9': sig->status = gpg_error (GPG_ERR_NO_PUBKEY); break; default: sig->status = gpg_error (GPG_ERR_GENERAL); } } else goto parse_err_sig_fail; goto parse_err_sig_ok; parse_err_sig_fail: sig->status = gpg_error (GPG_ERR_GENERAL); parse_err_sig_ok: break; default: return gpg_error (GPG_ERR_GENERAL); } if (*args) { sig->fpr = strdup (args); if (!sig->fpr) return gpg_error_from_errno (errno); } return 0; } static gpgme_error_t parse_valid_sig (gpgme_signature_t sig, char *args) { char *end = strchr (args, ' '); if (end) { *end = '\0'; end++; } if (!*args) /* We require at least the fingerprint. */ return gpg_error (GPG_ERR_GENERAL); if (sig->fpr) free (sig->fpr); sig->fpr = strdup (args); if (!sig->fpr) return gpg_error_from_errno (errno); /* Skip the creation date. */ end = strchr (end, ' '); if (end) { char *tail; sig->timestamp = _gpgme_parse_timestamp (end, &tail); if (sig->timestamp == -1 || end == tail || (*tail && *tail != ' ')) return gpg_error (GPG_ERR_INV_ENGINE); end = tail; sig->exp_timestamp = _gpgme_parse_timestamp (end, &tail); if (sig->exp_timestamp == -1 || end == tail || (*tail && *tail != ' ')) return gpg_error (GPG_ERR_INV_ENGINE); end = tail; while (*end == ' ') end++; /* Skip the signature version. */ end = strchr (end, ' '); if (end) { while (*end == ' ') end++; /* Skip the reserved field. */ end = strchr (end, ' '); if (end) { /* Parse the pubkey algo. */ errno = 0; sig->pubkey_algo = strtol (end, &tail, 0); if (errno || end == tail || *tail != ' ') return gpg_error (GPG_ERR_INV_ENGINE); end = tail; while (*end == ' ') end++; if (*end) { /* Parse the hash algo. */ errno = 0; sig->hash_algo = strtol (end, &tail, 0); if (errno || end == tail || *tail != ' ') return gpg_error (GPG_ERR_INV_ENGINE); end = tail; } } } } return 0; } static gpgme_error_t parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args) { gpgme_error_t err; gpgme_sig_notation_t *lastp = &sig->notations; gpgme_sig_notation_t notation = sig->notations; char *end = strchr (args, ' '); if (end) *end = '\0'; if (code == GPGME_STATUS_NOTATION_NAME || code == GPGME_STATUS_POLICY_URL) { /* FIXME: We could keep a pointer to the last notation in the list. */ while (notation && notation->value) { lastp = ¬ation->next; notation = notation->next; } if (notation) /* There is another notation name without data for the previous one. The crypto backend misbehaves. */ return gpg_error (GPG_ERR_INV_ENGINE); err = _gpgme_sig_notation_create (¬ation, NULL, 0, NULL, 0, 0); if (err) return err; if (code == GPGME_STATUS_NOTATION_NAME) { err = _gpgme_decode_percent_string (args, ¬ation->name, 0, 0); if (err) { _gpgme_sig_notation_free (notation); return err; } notation->name_len = strlen (notation->name); /* FIXME: For now we fake the human-readable flag. The critical flag can not be reported as it is not provided. */ notation->flags = GPGME_SIG_NOTATION_HUMAN_READABLE; notation->human_readable = 1; } else { /* This is a policy URL. */ err = _gpgme_decode_percent_string (args, ¬ation->value, 0, 0); if (err) { _gpgme_sig_notation_free (notation); return err; } notation->value_len = strlen (notation->value); } *lastp = notation; } else if (code == GPGME_STATUS_NOTATION_DATA) { int len = strlen (args) + 1; char *dest; /* FIXME: We could keep a pointer to the last notation in the list. */ while (notation && notation->next) { lastp = ¬ation->next; notation = notation->next; } if (!notation || !notation->name) /* There is notation data without a previous notation name. The crypto backend misbehaves. */ return gpg_error (GPG_ERR_INV_ENGINE); if (!notation->value) { dest = notation->value = malloc (len); if (!dest) return gpg_error_from_errno (errno); } else { int cur_len = strlen (notation->value); dest = realloc (notation->value, len + strlen (notation->value)); if (!dest) return gpg_error_from_errno (errno); notation->value = dest; dest += cur_len; } err = _gpgme_decode_percent_string (args, &dest, len, 0); if (err) return err; notation->value_len += strlen (dest); } else return gpg_error (GPG_ERR_INV_ENGINE); return 0; } static gpgme_error_t parse_trust (gpgme_signature_t sig, gpgme_status_code_t code, char *args) { char *end = strchr (args, ' '); if (end) *end = '\0'; switch (code) { case GPGME_STATUS_TRUST_UNDEFINED: default: sig->validity = GPGME_VALIDITY_UNKNOWN; break; case GPGME_STATUS_TRUST_NEVER: sig->validity = GPGME_VALIDITY_NEVER; break; case GPGME_STATUS_TRUST_MARGINAL: sig->validity = GPGME_VALIDITY_MARGINAL; break; case GPGME_STATUS_TRUST_FULLY: case GPGME_STATUS_TRUST_ULTIMATE: sig->validity = GPGME_VALIDITY_FULL; break; } sig->validity_reason = 0; sig->chain_model = 0; if (*args) { sig->validity_reason = _gpgme_map_gnupg_error (args); while (*args && *args != ' ') args++; if (*args) { while (*args == ' ') args++; - if (!strncmp (args, "cm", 2) && (args[2] == ' ' || !args[2])) + if (!strncmp (args, "chain", 2) && (args[2] == ' ' || !args[2])) sig->chain_model = 1; } } return 0; } /* Parse an error status line and if SET_STATUS is true update the result status as appropriate. With SET_STATUS being false, only check for an error. */ static gpgme_error_t parse_error (gpgme_signature_t sig, char *args, int set_status) { gpgme_error_t err; char *where = strchr (args, ' '); char *which; if (where) { *where = '\0'; which = where + 1; where = strchr (which, ' '); if (where) *where = '\0'; where = args; } else return gpg_error (GPG_ERR_INV_ENGINE); err = _gpgme_map_gnupg_error (which); if (!strcmp (where, "proc_pkt.plaintext") && gpg_err_code (err) == GPG_ERR_BAD_DATA) { /* This indicates a double plaintext. The only solid way to handle this is by failing the oepration. */ return gpg_error (GPG_ERR_BAD_DATA); } else if (!set_status) ; else if (!strcmp (where, "verify.findkey")) sig->status = err; else if (!strcmp (where, "verify.keyusage") && gpg_err_code (err) == GPG_ERR_WRONG_KEY_USAGE) sig->wrong_key_usage = 1; return 0; } gpgme_error_t _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args) { gpgme_ctx_t ctx = (gpgme_ctx_t) priv; gpgme_error_t err; void *hook; op_data_t opd; gpgme_signature_t sig; char *end; err = _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, -1, NULL); opd = hook; if (err) return err; sig = opd->current_sig; switch (code) { case GPGME_STATUS_NEWSIG: if (sig) calc_sig_summary (sig); err = prepare_new_sig (opd); opd->only_newsig_seen = 1; return err; case GPGME_STATUS_GOODSIG: case GPGME_STATUS_EXPSIG: case GPGME_STATUS_EXPKEYSIG: case GPGME_STATUS_BADSIG: case GPGME_STATUS_ERRSIG: case GPGME_STATUS_REVKEYSIG: if (sig && !opd->did_prepare_new_sig) calc_sig_summary (sig); opd->only_newsig_seen = 0; return parse_new_sig (opd, code, args); case GPGME_STATUS_VALIDSIG: opd->only_newsig_seen = 0; return sig ? parse_valid_sig (sig, args) : gpg_error (GPG_ERR_INV_ENGINE); case GPGME_STATUS_NODATA: opd->only_newsig_seen = 0; if (!sig) return gpg_error (GPG_ERR_NO_DATA); sig->status = gpg_error (GPG_ERR_NO_DATA); break; case GPGME_STATUS_UNEXPECTED: opd->only_newsig_seen = 0; if (!sig) return gpg_error (GPG_ERR_GENERAL); sig->status = gpg_error (GPG_ERR_NO_DATA); break; case GPGME_STATUS_NOTATION_NAME: case GPGME_STATUS_NOTATION_DATA: case GPGME_STATUS_POLICY_URL: opd->only_newsig_seen = 0; return sig ? parse_notation (sig, code, args) : gpg_error (GPG_ERR_INV_ENGINE); case GPGME_STATUS_TRUST_UNDEFINED: case GPGME_STATUS_TRUST_NEVER: case GPGME_STATUS_TRUST_MARGINAL: case GPGME_STATUS_TRUST_FULLY: case GPGME_STATUS_TRUST_ULTIMATE: opd->only_newsig_seen = 0; return sig ? parse_trust (sig, code, args) : gpg_error (GPG_ERR_INV_ENGINE); case GPGME_STATUS_PKA_TRUST_BAD: case GPGME_STATUS_PKA_TRUST_GOOD: opd->only_newsig_seen = 0; /* Check that we only get one of these status codes per signature; if not the crypto backend misbehaves. */ if (!sig || sig->pka_trust || sig->pka_address) return gpg_error (GPG_ERR_INV_ENGINE); sig->pka_trust = code == GPGME_STATUS_PKA_TRUST_GOOD? 2 : 1; end = strchr (args, ' '); if (end) *end = 0; sig->pka_address = strdup (args); break; case GPGME_STATUS_ERROR: opd->only_newsig_seen = 0; /* Some error stati are informational, so we don't return an error code if we are not ready to process this status. */ return parse_error (sig, args, !!sig ); case GPGME_STATUS_EOF: if (sig && !opd->did_prepare_new_sig) calc_sig_summary (sig); if (opd->only_newsig_seen && sig) { gpgme_signature_t sig2; /* The last signature has no valid information - remove it from the list. */ assert (!sig->next); if (sig == opd->result.signatures) opd->result.signatures = NULL; else { for (sig2 = opd->result.signatures; sig2; sig2 = sig2->next) if (sig2->next == sig) { sig2->next = NULL; break; } } /* Note that there is no need to release the members of SIG because we won't be here if they have been set. */ free (sig); opd->current_sig = NULL; } opd->only_newsig_seen = 0; break; case GPGME_STATUS_PLAINTEXT: if (++opd->plaintext_seen > 1) return gpg_error (GPG_ERR_BAD_DATA); err = _gpgme_parse_plaintext (args, &opd->result.file_name); if (err) return err; default: break; } return 0; } static gpgme_error_t verify_status_handler (void *priv, gpgme_status_code_t code, char *args) { gpgme_error_t err; err = _gpgme_progress_status_handler (priv, code, args); if (!err) err = _gpgme_verify_status_handler (priv, code, args); return err; } gpgme_error_t _gpgme_op_verify_init_result (gpgme_ctx_t ctx) { void *hook; op_data_t opd; return _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, sizeof (*opd), release_op_data); } static gpgme_error_t verify_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext) { gpgme_error_t err; err = _gpgme_op_reset (ctx, synchronous); if (err) return err; err = _gpgme_op_verify_init_result (ctx); if (err) return err; _gpgme_engine_set_status_handler (ctx->engine, verify_status_handler, ctx); if (!sig) return gpg_error (GPG_ERR_NO_DATA); if (!signed_text && !plaintext) return gpg_error (GPG_ERR_INV_VALUE); return _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext); } /* Decrypt ciphertext CIPHER and make a signature verification within CTX and store the resulting plaintext in PLAIN. */ gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext) { return verify_start (ctx, 0, sig, signed_text, plaintext); } /* Decrypt ciphertext CIPHER and make a signature verification within CTX and store the resulting plaintext in PLAIN. */ gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, gpgme_data_t plaintext) { gpgme_error_t err; err = verify_start (ctx, 1, sig, signed_text, plaintext); if (!err) err = _gpgme_wait_one (ctx); return err; } /* Compatibility interfaces. */ /* Get the key used to create signature IDX in CTX and return it in R_KEY. */ gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key) { gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) { sig = sig->next; idx--; } if (!sig || idx) return gpg_error (GPG_ERR_EOF); return gpgme_get_key (ctx, sig->fpr, r_key, 0); } /* Retrieve the signature status of signature IDX in CTX after a successful verify operation in R_STAT (if non-null). The creation time stamp of the signature is returned in R_CREATED (if non-null). The function returns a string containing the fingerprint. */ const char * gpgme_get_sig_status (gpgme_ctx_t ctx, int idx, _gpgme_sig_stat_t *r_stat, time_t *r_created) { gpgme_verify_result_t result; gpgme_signature_t sig; 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 (gpg_err_code (sig->status)) { case GPG_ERR_NO_ERROR: *r_stat = GPGME_SIG_STAT_GOOD; break; case GPG_ERR_BAD_SIGNATURE: *r_stat = GPGME_SIG_STAT_BAD; break; case GPG_ERR_NO_PUBKEY: *r_stat = GPGME_SIG_STAT_NOKEY; break; case GPG_ERR_NO_DATA: *r_stat = GPGME_SIG_STAT_NOSIG; break; case GPG_ERR_SIG_EXPIRED: *r_stat = GPGME_SIG_STAT_GOOD_EXP; break; case GPG_ERR_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; } /* Retrieve certain attributes of a signature. IDX is the index number of the signature after a successful verify operation. WHAT is an attribute where GPGME_ATTR_EXPIRE is probably the most useful one. WHATIDX is to be passed as 0 for most attributes . */ unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t ctx, int idx, _gpgme_attr_t what, int whatidx) { gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) { sig = sig->next; idx--; } if (!sig || idx) return 0; 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 (gpg_err_code (sig->status)) { case GPG_ERR_NO_ERROR: return GPGME_SIG_STAT_GOOD; case GPG_ERR_BAD_SIGNATURE: return GPGME_SIG_STAT_BAD; case GPG_ERR_NO_PUBKEY: return GPGME_SIG_STAT_NOKEY; case GPG_ERR_NO_DATA: return GPGME_SIG_STAT_NOSIG; case GPG_ERR_SIG_EXPIRED: return GPGME_SIG_STAT_GOOD_EXP; case GPG_ERR_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; } const char * gpgme_get_sig_string_attr (gpgme_ctx_t ctx, int idx, _gpgme_attr_t what, int whatidx) { gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) { sig = sig->next; idx--; } if (!sig || idx) return NULL; 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; } return NULL; }