2000-10-27 14:55:24 +00:00
|
|
|
/* gpgme.h - GnuPG Made Easy
|
|
|
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
2002-01-29 22:59:15 +00:00
|
|
|
* Copyright (C) 2001, 2002 g10 Code GmbH
|
2000-10-27 14:55:24 +00:00
|
|
|
*
|
|
|
|
* This file is part of GPGME.
|
|
|
|
*
|
|
|
|
* GPGME is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GPGME_H
|
|
|
|
#define GPGME_H
|
2000-12-29 10:34:34 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
#include <stdio.h> /* For FILE *. */
|
2000-12-29 10:34:34 +00:00
|
|
|
#ifdef _MSC_VER
|
2001-01-30 11:01:41 +00:00
|
|
|
typedef long off_t;
|
2000-12-29 10:34:34 +00:00
|
|
|
#else
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
2000-10-27 14:55:24 +00:00
|
|
|
#ifdef __cplusplus
|
2002-02-27 20:59:20 +00:00
|
|
|
extern "C" {
|
2000-10-27 17:26:12 +00:00
|
|
|
#if 0 /* just to make Emacs auto-indent happy */
|
|
|
|
}
|
|
|
|
#endif
|
2000-10-27 14:55:24 +00:00
|
|
|
#endif
|
|
|
|
|
2000-12-29 10:34:34 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The version of this header should match the one of the library. Do
|
|
|
|
not use this symbol in your application, use gpgme_check_version
|
|
|
|
instead. The purpose of this macro is to let autoconf (using the
|
|
|
|
AM_PATH_GPGME macro) check that this header matches the installed
|
|
|
|
library. Warning: Do not edit the next line. configure will do
|
|
|
|
that for you! */
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* 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-10 14:13:55 +00:00
|
|
|
#define GPGME_VERSION "0.3.8-cvs"
|
2000-11-17 21:20:53 +00:00
|
|
|
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The opaque data types used by GPGME. */
|
2000-11-17 21:20:53 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The context holds some global state and configration options as
|
|
|
|
well as the results of a crypto operation. */
|
2000-10-27 17:26:12 +00:00
|
|
|
struct gpgme_context_s;
|
2000-11-07 13:32:38 +00:00
|
|
|
typedef struct gpgme_context_s *GpgmeCtx;
|
2000-10-27 17:26:12 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The data object used by GPGME to exchange arbitrary data. */
|
2000-11-07 13:32:38 +00:00
|
|
|
struct gpgme_data_s;
|
|
|
|
typedef struct gpgme_data_s *GpgmeData;
|
2000-10-27 17:26:12 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* A list of recipients to be used in an encryption operation. */
|
2000-11-13 13:25:22 +00:00
|
|
|
struct gpgme_recipients_s;
|
|
|
|
typedef struct gpgme_recipients_s *GpgmeRecipients;
|
2000-11-07 13:32:38 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* A key from the keyring. */
|
2000-11-10 20:56:02 +00:00
|
|
|
struct gpgme_key_s;
|
|
|
|
typedef struct gpgme_key_s *GpgmeKey;
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* A trust item. */
|
2001-01-08 20:40:25 +00:00
|
|
|
struct gpgme_trust_item_s;
|
|
|
|
typedef struct gpgme_trust_item_s *GpgmeTrustItem;
|
|
|
|
|
2000-11-07 13:32:38 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The error numbers used by GPGME. */
|
|
|
|
typedef enum
|
|
|
|
{
|
2002-02-26 23:39:58 +00:00
|
|
|
GPGME_EOF = -1,
|
|
|
|
GPGME_No_Error = 0,
|
|
|
|
GPGME_General_Error = 1,
|
|
|
|
GPGME_Out_Of_Core = 2,
|
|
|
|
GPGME_Invalid_Value = 3,
|
|
|
|
GPGME_Busy = 4,
|
|
|
|
GPGME_No_Request = 5,
|
|
|
|
GPGME_Exec_Error = 6,
|
|
|
|
GPGME_Too_Many_Procs = 7,
|
|
|
|
GPGME_Pipe_Error = 8,
|
|
|
|
GPGME_No_Recipients = 9,
|
|
|
|
GPGME_No_Data = 10,
|
|
|
|
GPGME_Conflict = 11,
|
|
|
|
GPGME_Not_Implemented = 12,
|
|
|
|
GPGME_Read_Error = 13,
|
|
|
|
GPGME_Write_Error = 14,
|
|
|
|
GPGME_Invalid_Type = 15,
|
|
|
|
GPGME_Invalid_Mode = 16,
|
|
|
|
GPGME_File_Error = 17, /* errno is set in this case. */
|
|
|
|
GPGME_Decryption_Failed = 18,
|
|
|
|
GPGME_No_Passphrase = 19,
|
|
|
|
GPGME_Canceled = 20,
|
|
|
|
GPGME_Invalid_Key = 21,
|
|
|
|
GPGME_Invalid_Engine = 22,
|
|
|
|
GPGME_Invalid_Recipients = 23
|
2002-01-30 01:17:30 +00:00
|
|
|
}
|
|
|
|
GpgmeError;
|
|
|
|
|
|
|
|
/* The possible types of GpgmeData objects. */
|
|
|
|
typedef enum
|
|
|
|
{
|
2000-11-07 13:32:38 +00:00
|
|
|
GPGME_DATA_TYPE_NONE = 0,
|
|
|
|
GPGME_DATA_TYPE_MEM = 1,
|
|
|
|
GPGME_DATA_TYPE_FD = 2,
|
2000-12-06 12:17:10 +00:00
|
|
|
GPGME_DATA_TYPE_FILE = 3,
|
|
|
|
GPGME_DATA_TYPE_CB = 4
|
2002-01-30 01:17:30 +00:00
|
|
|
}
|
|
|
|
GpgmeDataType;
|
|
|
|
|
2002-04-27 12:16:48 +00:00
|
|
|
/* The possible encoding mode of GpgmeData objects. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GPGME_DATA_ENCODING_NONE = 0, /* i.e. not specified */
|
|
|
|
GPGME_DATA_ENCODING_BINARY = 1,
|
|
|
|
GPGME_DATA_ENCODING_BASE64 = 2,
|
|
|
|
GPGME_DATA_ENCODING_ARMOR = 3 /* Either PEM or OpenPGP Armor */
|
|
|
|
}
|
|
|
|
GpgmeDataEncoding;
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The possible signature stati. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GPGME_SIG_STAT_NONE = 0,
|
|
|
|
GPGME_SIG_STAT_GOOD = 1,
|
|
|
|
GPGME_SIG_STAT_BAD = 2,
|
2000-11-15 21:36:48 +00:00
|
|
|
GPGME_SIG_STAT_NOKEY = 3,
|
|
|
|
GPGME_SIG_STAT_NOSIG = 4,
|
2001-02-12 15:23:29 +00:00
|
|
|
GPGME_SIG_STAT_ERROR = 5,
|
2002-05-03 14:06:56 +00:00
|
|
|
GPGME_SIG_STAT_DIFF = 6,
|
|
|
|
GPGME_SIG_STAT_GOOD_EXP = 7,
|
|
|
|
GPGME_SIG_STAT_GOOD_EXPKEY = 8
|
2002-01-30 01:17:30 +00:00
|
|
|
}
|
|
|
|
GpgmeSigStat;
|
2000-11-15 21:36:48 +00:00
|
|
|
|
2002-06-11 15:33:08 +00:00
|
|
|
/* Flags used with the GPGME_ATTR_SIG_SUMMARY. */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid */
|
|
|
|
GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */
|
|
|
|
GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */
|
|
|
|
GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */
|
|
|
|
GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */
|
|
|
|
GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */
|
|
|
|
GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */
|
|
|
|
GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */
|
|
|
|
GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */
|
|
|
|
GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */
|
|
|
|
GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* The available signature modes. */
|
|
|
|
typedef enum
|
|
|
|
{
|
2000-12-12 13:31:25 +00:00
|
|
|
GPGME_SIG_MODE_NORMAL = 0,
|
|
|
|
GPGME_SIG_MODE_DETACH = 1,
|
2002-01-30 01:17:30 +00:00
|
|
|
GPGME_SIG_MODE_CLEAR = 2
|
|
|
|
}
|
|
|
|
GpgmeSigMode;
|
|
|
|
|
2002-05-03 14:06:56 +00:00
|
|
|
/* The available key and signature attributes. */
|
2002-01-30 01:17:30 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GPGME_ATTR_KEYID = 1,
|
|
|
|
GPGME_ATTR_FPR = 2,
|
|
|
|
GPGME_ATTR_ALGO = 3,
|
|
|
|
GPGME_ATTR_LEN = 4,
|
|
|
|
GPGME_ATTR_CREATED = 5,
|
|
|
|
GPGME_ATTR_EXPIRE = 6,
|
|
|
|
GPGME_ATTR_OTRUST = 7,
|
|
|
|
GPGME_ATTR_USERID = 8,
|
|
|
|
GPGME_ATTR_NAME = 9,
|
|
|
|
GPGME_ATTR_EMAIL = 10,
|
|
|
|
GPGME_ATTR_COMMENT = 11,
|
|
|
|
GPGME_ATTR_VALIDITY = 12,
|
|
|
|
GPGME_ATTR_LEVEL = 13,
|
|
|
|
GPGME_ATTR_TYPE = 14,
|
|
|
|
GPGME_ATTR_IS_SECRET = 15,
|
|
|
|
GPGME_ATTR_KEY_REVOKED = 16,
|
|
|
|
GPGME_ATTR_KEY_INVALID = 17,
|
|
|
|
GPGME_ATTR_UID_REVOKED = 18,
|
|
|
|
GPGME_ATTR_UID_INVALID = 19,
|
|
|
|
GPGME_ATTR_KEY_CAPS = 20,
|
|
|
|
GPGME_ATTR_CAN_ENCRYPT = 21,
|
|
|
|
GPGME_ATTR_CAN_SIGN = 22,
|
|
|
|
GPGME_ATTR_CAN_CERTIFY = 23,
|
|
|
|
GPGME_ATTR_KEY_EXPIRED = 24,
|
2002-03-28 17:43:02 +00:00
|
|
|
GPGME_ATTR_KEY_DISABLED = 25,
|
|
|
|
GPGME_ATTR_SERIAL = 26,
|
|
|
|
GPGME_ATTR_ISSUER = 27,
|
2002-05-03 14:06:56 +00:00
|
|
|
GPGME_ATTR_CHAINID = 28,
|
2002-06-11 15:33:08 +00:00
|
|
|
GPGME_ATTR_SIG_STATUS = 29,
|
|
|
|
GPGME_ATTR_ERRTOK = 30,
|
|
|
|
GPGME_ATTR_SIG_SUMMARY = 31
|
2002-01-30 01:17:30 +00:00
|
|
|
}
|
|
|
|
GpgmeAttr;
|
|
|
|
|
|
|
|
/* The available validities for a trust item or key. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GPGME_VALIDITY_UNKNOWN = 0,
|
2001-01-11 11:56:34 +00:00
|
|
|
GPGME_VALIDITY_UNDEFINED = 1,
|
2002-01-30 01:17:30 +00:00
|
|
|
GPGME_VALIDITY_NEVER = 2,
|
|
|
|
GPGME_VALIDITY_MARGINAL = 3,
|
|
|
|
GPGME_VALIDITY_FULL = 4,
|
|
|
|
GPGME_VALIDITY_ULTIMATE = 5
|
|
|
|
}
|
|
|
|
GpgmeValidity;
|
|
|
|
|
|
|
|
/* The available protocols. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */
|
|
|
|
GPGME_PROTOCOL_CMS = 1,
|
|
|
|
GPGME_PROTOCOL_AUTO = 2
|
|
|
|
}
|
|
|
|
GpgmeProtocol;
|
|
|
|
|
|
|
|
|
2002-02-06 00:08:47 +00:00
|
|
|
/* The available keylist mode flags. */
|
|
|
|
#define GPGME_KEYLIST_MODE_LOCAL 1
|
|
|
|
#define GPGME_KEYLIST_MODE_EXTERN 2
|
|
|
|
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Types for callback functions. */
|
|
|
|
|
|
|
|
/* Request a passphrase from the user. */
|
|
|
|
typedef const char *(*GpgmePassphraseCb) (void *hook, const char *desc,
|
|
|
|
void **r_hd);
|
|
|
|
|
|
|
|
/* Inform the user about progress made. */
|
|
|
|
typedef void (*GpgmeProgressCb) (void *opaque, const char *what,
|
|
|
|
int type, int current, int total);
|
|
|
|
|
|
|
|
|
|
|
|
/* Context management functions. */
|
|
|
|
|
|
|
|
/* Create a new context and return it in CTX. */
|
|
|
|
GpgmeError gpgme_new (GpgmeCtx *ctx);
|
|
|
|
|
|
|
|
/* Release the context CTX. */
|
|
|
|
void gpgme_release (GpgmeCtx ctx);
|
|
|
|
|
|
|
|
/* Retrieve more info about performed signature check. */
|
|
|
|
char *gpgme_get_notation (GpgmeCtx ctx);
|
|
|
|
|
|
|
|
/* Set the protocol to be used by CTX to PROTO. */
|
|
|
|
GpgmeError gpgme_set_protocol (GpgmeCtx ctx, GpgmeProtocol proto);
|
|
|
|
|
2002-05-03 18:20:06 +00:00
|
|
|
/* Get the protocol used with CTX */
|
|
|
|
GpgmeProtocol gpgme_get_protocol (GpgmeCtx ctx);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */
|
|
|
|
void gpgme_set_armor (GpgmeCtx ctx, int yes);
|
|
|
|
|
|
|
|
/* Return non-zero if armor mode is set in CTX. */
|
|
|
|
int gpgme_get_armor (GpgmeCtx ctx);
|
|
|
|
|
|
|
|
/* If YES is non-zero, enable text mode in CTX, disable it otherwise. */
|
|
|
|
void gpgme_set_textmode (GpgmeCtx ctx, int yes);
|
|
|
|
|
|
|
|
/* Return non-zero if text mode is set in CTX. */
|
|
|
|
int gpgme_get_textmode (GpgmeCtx ctx);
|
|
|
|
|
2002-02-25 18:31:07 +00:00
|
|
|
/* Include up to NR_OF_CERTS certificates in an S/MIME message. */
|
|
|
|
void gpgme_set_include_certs (GpgmeCtx ctx, int nr_of_certs);
|
|
|
|
|
|
|
|
/* Return the number of certs to include in an S/MIME message. */
|
|
|
|
int gpgme_get_include_certs (GpgmeCtx ctx);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Set keylist mode in CTX to MODE. */
|
2002-02-06 00:08:47 +00:00
|
|
|
GpgmeError gpgme_set_keylist_mode (GpgmeCtx ctx, int mode);
|
|
|
|
|
|
|
|
/* Get keylist mode in CTX. */
|
|
|
|
int gpgme_get_keylist_mode (GpgmeCtx ctx);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Set the passphrase callback function in CTX to CB. HOOK_VALUE is
|
|
|
|
passed as first argument to the passphrase callback function. */
|
|
|
|
void gpgme_set_passphrase_cb (GpgmeCtx ctx,
|
|
|
|
GpgmePassphraseCb cb, void *hook_value);
|
|
|
|
|
2002-04-22 21:58:26 +00:00
|
|
|
/* Get the current passphrase callback function in *CB and the current
|
|
|
|
hook value in *HOOK_VALUE. */
|
|
|
|
void gpgme_get_passphrase_cb (GpgmeCtx ctx, GpgmePassphraseCb *cb,
|
|
|
|
void **hook_value);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Set the progress callback function in CTX to CB. HOOK_VALUE is
|
|
|
|
passed as first argument to the progress callback function. */
|
|
|
|
void gpgme_set_progress_cb (GpgmeCtx c, GpgmeProgressCb cb, void *hook_value);
|
|
|
|
|
2002-04-22 21:58:26 +00:00
|
|
|
/* Get the current progress callback function in *CB and the current
|
|
|
|
hook value in *HOOK_VALUE. */
|
|
|
|
void gpgme_get_progress_cb (GpgmeCtx ctx, GpgmeProgressCb *cb,
|
|
|
|
void **hook_value);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Delete all signers from CTX. */
|
|
|
|
void gpgme_signers_clear (GpgmeCtx ctx);
|
|
|
|
|
|
|
|
/* Add KEY to list of signers in CTX. */
|
|
|
|
GpgmeError gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key);
|
|
|
|
|
|
|
|
/* Return the SEQth signer's key in CTX. */
|
|
|
|
GpgmeKey gpgme_signers_enum (const GpgmeCtx ctx, int seq);
|
|
|
|
|
|
|
|
/* 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 (GpgmeCtx ctx, int idx,
|
|
|
|
GpgmeSigStat *r_stat, time_t *r_created);
|
|
|
|
|
2002-05-03 14:06:56 +00:00
|
|
|
/* 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. RESERVED must be passed as 0. */
|
|
|
|
unsigned long gpgme_get_sig_ulong_attr (GpgmeCtx c, int idx,
|
|
|
|
GpgmeAttr what, int reserved);
|
|
|
|
const char *gpgme_get_sig_string_attr (GpgmeCtx c, int idx,
|
|
|
|
GpgmeAttr what, int reserved);
|
|
|
|
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Get the key used to create signature IDX in CTX and return it in
|
|
|
|
R_KEY. */
|
|
|
|
GpgmeError gpgme_get_sig_key (GpgmeCtx ctx, int idx, GpgmeKey *r_key);
|
|
|
|
|
|
|
|
/* Return a string with more info about the last crypto operating in CTX.
|
|
|
|
RESERVED should be zero. The user has to free the string. */
|
|
|
|
char *gpgme_get_op_info (GpgmeCtx ctx, int reserved);
|
|
|
|
|
|
|
|
|
|
|
|
/* Run control. */
|
|
|
|
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* 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-10 14:13:55 +00:00
|
|
|
/* The type of an I/O callback function. */
|
|
|
|
typedef void (*GpgmeIOCb) (void *data, int fd);
|
|
|
|
|
|
|
|
/* The type of a function that can register FNC as the I/O callback
|
|
|
|
function for the file descriptor FD with direction dir (0: inbound,
|
|
|
|
1: outbound). FNC_DATA should be passed as DATA to FNC. The
|
|
|
|
function should return a TAG suitable for the corresponding
|
|
|
|
GpgmeRemoveIOCb. */
|
|
|
|
typedef void *(*GpgmeRegisterIOCb) (void *data, int fd, int dir,
|
|
|
|
GpgmeIOCb fnc, void *fnc_data);
|
|
|
|
|
|
|
|
/* The type of a function that can remove a previously registered I/O
|
|
|
|
callback function given TAG as returned by the register
|
|
|
|
function. */
|
|
|
|
typedef void (*GpgmeRemoveIOCb) (void *tag);
|
|
|
|
|
|
|
|
typedef enum { GPGME_EVENT_DONE,
|
|
|
|
GPGME_EVENT_NEXT_KEY,
|
|
|
|
GPGME_EVENT_NEXT_TRUSTITEM } GpgmeEventIO;
|
|
|
|
|
|
|
|
/* The type of a function that is called when a context finished an
|
|
|
|
operation. */
|
|
|
|
typedef void (*GpgmeEventIOCb) (void *data, GpgmeEventIO type,
|
|
|
|
void *type_data);
|
|
|
|
|
|
|
|
struct GpgmeIOCbs
|
|
|
|
{
|
|
|
|
GpgmeRegisterIOCb add;
|
|
|
|
void *add_priv;
|
|
|
|
GpgmeRemoveIOCb remove;
|
|
|
|
GpgmeEventIOCb event;
|
|
|
|
void *event_priv;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Set the I/O callback functions in CTX to IO_CBS. */
|
|
|
|
void gpgme_set_op_io_cbs (GpgmeCtx ctx, struct GpgmeIOCbs *io_cbs);
|
|
|
|
|
|
|
|
/* Get the current I/O callback functions. */
|
|
|
|
void gpgme_get_op_io_cbs (GpgmeCtx ctx, struct GpgmeIOCbs *io_cbs);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Cancel a pending operation in CTX. */
|
|
|
|
void gpgme_cancel (GpgmeCtx ctx);
|
|
|
|
|
|
|
|
/* Process the pending operation and, if HANG is non-zero, wait for
|
|
|
|
the pending operation to finish. */
|
2002-02-06 01:20:49 +00:00
|
|
|
GpgmeCtx gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Functions to handle recipients. */
|
|
|
|
|
|
|
|
/* Create a new recipients set and return it in R_RSET. */
|
|
|
|
GpgmeError gpgme_recipients_new (GpgmeRecipients *r_rset);
|
|
|
|
|
|
|
|
/* Release the recipients set RSET. */
|
|
|
|
void gpgme_recipients_release (GpgmeRecipients rset);
|
|
|
|
|
|
|
|
/* Add NAME to the recipients set RSET. */
|
|
|
|
GpgmeError gpgme_recipients_add_name (GpgmeRecipients rset, const char *name);
|
|
|
|
|
|
|
|
/* Add NAME with validity AL to the recipients set RSET. */
|
|
|
|
GpgmeError gpgme_recipients_add_name_with_validity (GpgmeRecipients rset,
|
|
|
|
const char *name,
|
|
|
|
GpgmeValidity val);
|
|
|
|
|
|
|
|
/* Return the number of recipients in RSET. */
|
|
|
|
unsigned int gpgme_recipients_count (const GpgmeRecipients rset);
|
|
|
|
|
|
|
|
/* Create a new enumeration handle for the recipients set RSET and
|
|
|
|
return it in ITER. */
|
|
|
|
GpgmeError gpgme_recipients_enum_open (const GpgmeRecipients rset,
|
|
|
|
void **iter);
|
|
|
|
|
|
|
|
/* Return the next recipient from the recipient set RSET in the
|
|
|
|
enumerator ITER. */
|
|
|
|
const char *gpgme_recipients_enum_read (const GpgmeRecipients rset,
|
|
|
|
void **iter);
|
|
|
|
|
|
|
|
/* Destroy the enumerator ITER for the recipient set RSET. */
|
|
|
|
GpgmeError gpgme_recipients_enum_close (const GpgmeRecipients rset,
|
|
|
|
void **iter);
|
|
|
|
|
|
|
|
|
|
|
|
/* Functions to handle data objects. */
|
|
|
|
|
|
|
|
/* Create a new data buffer and return it in R_DH. */
|
|
|
|
GpgmeError gpgme_data_new (GpgmeData *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. */
|
|
|
|
GpgmeError gpgme_data_new_from_mem (GpgmeData *r_dh,
|
|
|
|
const char *buffer, size_t size,
|
|
|
|
int copy);
|
|
|
|
|
|
|
|
/* Create a new data buffer which retrieves the data from the callback
|
|
|
|
function READ_CB. */
|
|
|
|
GpgmeError gpgme_data_new_with_read_cb (GpgmeData *r_dh,
|
|
|
|
int (*read_cb) (void*,char *,size_t,size_t*),
|
|
|
|
void *read_cb_value);
|
|
|
|
|
|
|
|
/* Create a new data buffer filled with the content of file FNAME.
|
|
|
|
COPY must be non-zero (delayed reads are not supported yet). */
|
|
|
|
GpgmeError gpgme_data_new_from_file (GpgmeData *r_dh,
|
|
|
|
const char *fname,
|
|
|
|
int copy);
|
|
|
|
|
|
|
|
/* Create a new data buffer filled with LENGTH bytes starting from
|
|
|
|
OFFSET within the file FNAME or stream FP (exactly one must be
|
|
|
|
non-zero). */
|
2002-01-22 15:21:42 +00:00
|
|
|
GpgmeError gpgme_data_new_from_filepart (GpgmeData *r_dh,
|
|
|
|
const char *fname, FILE *fp,
|
|
|
|
off_t offset, size_t length);
|
2000-12-29 10:34:34 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Destroy the data buffer DH. */
|
|
|
|
void gpgme_data_release (GpgmeData dh);
|
|
|
|
|
|
|
|
/* Destroy the data buffer DH and return a pointer to its content.
|
|
|
|
The memory has be to released with free by the user. It's size is
|
|
|
|
returned in R_LEN. */
|
|
|
|
char *gpgme_data_release_and_get_mem (GpgmeData dh, size_t *r_len);
|
|
|
|
|
|
|
|
/* Return the type of the data buffer DH. */
|
|
|
|
GpgmeDataType gpgme_data_get_type (GpgmeData dh);
|
|
|
|
|
2002-04-27 12:16:48 +00:00
|
|
|
/* Return the encoding attribute of the data buffer DH */
|
|
|
|
GpgmeDataEncoding gpgme_data_get_encoding (GpgmeData dh);
|
|
|
|
|
|
|
|
/* Set the encoding attribute of data buffer DH to ENC */
|
|
|
|
GpgmeError gpgme_data_set_encoding (GpgmeData dh, GpgmeDataEncoding enc);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Reset the read pointer in DH. */
|
|
|
|
GpgmeError gpgme_data_rewind (GpgmeData dh);
|
|
|
|
|
|
|
|
/* Read LENGTH bytes from the data object DH and store them in the
|
|
|
|
memory starting at BUFFER. The number of bytes actually read is
|
|
|
|
returned in NREAD. */
|
2002-05-03 18:20:06 +00:00
|
|
|
GpgmeError gpgme_data_read (GpgmeData dh, void *buffer,
|
2002-01-30 01:17:30 +00:00
|
|
|
size_t length, size_t *nread);
|
|
|
|
|
|
|
|
/* Write LENGTH bytes starting from BUFFER into the data object DH. */
|
2002-05-03 18:20:06 +00:00
|
|
|
GpgmeError gpgme_data_write (GpgmeData dh, const void *buffer, size_t length);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Key and trust functions. */
|
2000-11-09 16:35:35 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Acquire a reference to KEY. */
|
2001-01-22 20:22:41 +00:00
|
|
|
void gpgme_key_ref (GpgmeKey key);
|
2000-12-14 14:45:35 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Release a reference to KEY. If this was the last one the key is
|
|
|
|
destroyed. */
|
|
|
|
void gpgme_key_unref (GpgmeKey key);
|
|
|
|
void gpgme_key_release (GpgmeKey key);
|
|
|
|
|
|
|
|
/* Get the data from key KEY in a XML string, which has to be released
|
|
|
|
with free by the user. */
|
|
|
|
char *gpgme_key_get_as_xml (GpgmeKey key);
|
|
|
|
|
|
|
|
/* Return the value of the attribute WHAT of KEY, which has to be
|
|
|
|
representable by a string. IDX specifies a running index if the
|
|
|
|
attribute appears more than once in the key. */
|
|
|
|
const char *gpgme_key_get_string_attr (GpgmeKey key, GpgmeAttr what,
|
|
|
|
const void *reserved, int idx);
|
|
|
|
|
|
|
|
/* Return the value of the attribute WHAT of KEY, which has to be
|
|
|
|
representable by an unsigned integer. IDX specifies a running
|
|
|
|
index if the attribute appears more than once in the key. */
|
|
|
|
unsigned long gpgme_key_get_ulong_attr (GpgmeKey key, GpgmeAttr what,
|
|
|
|
const void *reserved, int idx);
|
|
|
|
|
|
|
|
/* Release the trust item ITEM. */
|
|
|
|
void gpgme_trust_item_release (GpgmeTrustItem item);
|
|
|
|
|
|
|
|
/* Return the value of the attribute WHAT of ITEM, which has to be
|
|
|
|
representable by a string. IDX specifies a running index if the
|
|
|
|
attribute appears more than once in the key. */
|
|
|
|
const char *gpgme_trust_item_get_string_attr (GpgmeTrustItem item,
|
|
|
|
GpgmeAttr what,
|
|
|
|
const void *reserved, int idx);
|
|
|
|
|
|
|
|
/* Return the value of the attribute WHAT of KEY, which has to be
|
|
|
|
representable by an integer. IDX specifies a running index if the
|
|
|
|
attribute appears more than once in the key. */
|
|
|
|
int gpgme_trust_item_get_int_attr (GpgmeTrustItem item, GpgmeAttr what,
|
|
|
|
const void *reserved, int idx);
|
|
|
|
|
|
|
|
|
|
|
|
/* Crypto operation function. */
|
|
|
|
|
|
|
|
/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
|
|
|
|
store the resulting ciphertext in CIPHER. */
|
|
|
|
GpgmeError gpgme_op_encrypt_start (GpgmeCtx ctx,
|
|
|
|
GpgmeRecipients recp,
|
|
|
|
GpgmeData plain, GpgmeData cipher);
|
|
|
|
GpgmeError gpgme_op_encrypt (GpgmeCtx ctx,
|
|
|
|
GpgmeRecipients recp,
|
|
|
|
GpgmeData plain, GpgmeData cipher);
|
|
|
|
|
2002-02-26 00:08:09 +00:00
|
|
|
/* Encrypt plaintext PLAIN within CTX for the recipients RECP and
|
|
|
|
store the resulting ciphertext in CIPHER. Also sign the ciphertext
|
|
|
|
with the signers in CTX. */
|
|
|
|
GpgmeError gpgme_op_encrypt_sign_start (GpgmeCtx ctx,
|
|
|
|
GpgmeRecipients recp,
|
|
|
|
GpgmeData plain, GpgmeData cipher);
|
|
|
|
GpgmeError gpgme_op_encrypt_sign (GpgmeCtx ctx,
|
|
|
|
GpgmeRecipients recp,
|
|
|
|
GpgmeData plain, GpgmeData cipher);
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Decrypt ciphertext CIPHER within CTX and store the resulting
|
|
|
|
plaintext in PLAIN. */
|
|
|
|
GpgmeError gpgme_op_decrypt_start (GpgmeCtx ctx,
|
|
|
|
GpgmeData cipher, GpgmeData plain);
|
|
|
|
GpgmeError gpgme_op_decrypt (GpgmeCtx ctx,
|
|
|
|
GpgmeData cipher, GpgmeData plain);
|
|
|
|
|
|
|
|
/* Decrypt ciphertext CIPHER and make a signature verification within
|
|
|
|
CTX and store the resulting plaintext in PLAIN. */
|
|
|
|
GpgmeError gpgme_op_decrypt_verify_start (GpgmeCtx ctx,
|
|
|
|
GpgmeData cipher, GpgmeData plain);
|
|
|
|
GpgmeError gpgme_op_decrypt_verify (GpgmeCtx ctx,
|
|
|
|
GpgmeData cipher, GpgmeData plain,
|
|
|
|
GpgmeSigStat *r_status);
|
2000-12-14 14:45:35 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Sign the plaintext PLAIN and store the signature in SIG. Only
|
|
|
|
detached signatures are supported for now. */
|
|
|
|
GpgmeError gpgme_op_sign_start (GpgmeCtx ctx,
|
|
|
|
GpgmeData plain, GpgmeData sig,
|
|
|
|
GpgmeSigMode mode);
|
|
|
|
GpgmeError gpgme_op_sign (GpgmeCtx ctx,
|
|
|
|
GpgmeData plain, GpgmeData sig,
|
|
|
|
GpgmeSigMode mode);
|
|
|
|
|
|
|
|
/* Verify within CTX that SIG is a valid signature for TEXT. */
|
|
|
|
GpgmeError gpgme_op_verify_start (GpgmeCtx ctx,
|
|
|
|
GpgmeData sig, GpgmeData text);
|
|
|
|
GpgmeError gpgme_op_verify (GpgmeCtx ctx,
|
|
|
|
GpgmeData sig, GpgmeData text,
|
|
|
|
GpgmeSigStat *r_status);
|
|
|
|
|
|
|
|
/* Import the key in KEYDATA into the keyring. */
|
|
|
|
GpgmeError gpgme_op_import_start (GpgmeCtx ctx, GpgmeData keydata);
|
|
|
|
GpgmeError gpgme_op_import (GpgmeCtx ctx, GpgmeData keydata);
|
|
|
|
|
|
|
|
/* Export the keys listed in RECP into KEYDATA. */
|
|
|
|
GpgmeError gpgme_op_export_start (GpgmeCtx ctx, GpgmeRecipients recp,
|
|
|
|
GpgmeData keydata);
|
|
|
|
GpgmeError gpgme_op_export (GpgmeCtx ctx, GpgmeRecipients recp,
|
|
|
|
GpgmeData keydata);
|
|
|
|
|
|
|
|
/* Generate a new keypair and add it to the keyring. PUBKEY and
|
|
|
|
SECKEY should be null for now. PARMS specifies what keys should be
|
|
|
|
generated. */
|
|
|
|
GpgmeError gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms,
|
|
|
|
GpgmeData pubkey, GpgmeData seckey);
|
|
|
|
GpgmeError gpgme_op_genkey (GpgmeCtx ctx, const char *parms,
|
|
|
|
GpgmeData pubkey, GpgmeData seckey);
|
|
|
|
|
|
|
|
/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
|
|
|
|
keys are also deleted. */
|
|
|
|
GpgmeError gpgme_op_delete_start (GpgmeCtx ctx, const GpgmeKey key,
|
|
|
|
int allow_secret);
|
|
|
|
GpgmeError gpgme_op_delete (GpgmeCtx ctx, const GpgmeKey key,
|
|
|
|
int allow_secret);
|
2000-11-07 13:32:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Key management functions */
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Start a keylist operation within CTX, searching for keys which
|
|
|
|
match PATTERN. If SECRET_ONLY is true, only secret keys are
|
|
|
|
returned. */
|
2001-12-18 22:54:49 +00:00
|
|
|
GpgmeError gpgme_op_keylist_start (GpgmeCtx ctx,
|
|
|
|
const char *pattern, int secret_only);
|
2002-03-07 19:49:40 +00:00
|
|
|
GpgmeError gpgme_op_keylist_ext_start (GpgmeCtx ctx, const char *pattern[],
|
|
|
|
int secret_only, int reserved);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Return the next key from the keylist in R_KEY. */
|
2001-12-18 22:54:49 +00:00
|
|
|
GpgmeError gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Terminate a pending keylist operation within CTX. */
|
2001-12-18 22:54:49 +00:00
|
|
|
GpgmeError gpgme_op_keylist_end (GpgmeCtx ctx);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Start a trustlist operation within CTX, searching for trust items
|
|
|
|
which match PATTERN. */
|
2001-12-18 22:54:49 +00:00
|
|
|
GpgmeError gpgme_op_trustlist_start (GpgmeCtx ctx,
|
|
|
|
const char *pattern, int max_level);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Return the next trust item from the trustlist in R_ITEM. */
|
2001-12-18 22:54:49 +00:00
|
|
|
GpgmeError gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item);
|
2001-01-08 20:40:25 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Terminate a pending trustlist operation within CTX. */
|
|
|
|
GpgmeError gpgme_op_trustlist_end (GpgmeCtx ctx);
|
2000-11-07 13:32:38 +00:00
|
|
|
|
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Various functions. */
|
|
|
|
|
|
|
|
/* Check that the library fulfills the version requirement. */
|
2001-01-22 20:22:41 +00:00
|
|
|
const char *gpgme_check_version (const char *req_version);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Check that the backend engine is available. DEPRECATED. */
|
2001-01-22 20:22:41 +00:00
|
|
|
GpgmeError gpgme_check_engine (void);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Retrieve information about the backend engines. */
|
2001-01-22 20:22:41 +00:00
|
|
|
const char *gpgme_get_engine_info (void);
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Return a string describing ERR. */
|
2000-11-07 13:32:38 +00:00
|
|
|
const char *gpgme_strerror (GpgmeError err);
|
2002-01-29 22:58:25 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
/* Register an idle function. */
|
2002-01-29 22:58:25 +00:00
|
|
|
typedef void (*GpgmeIdleFunc)(void);
|
|
|
|
GpgmeIdleFunc gpgme_register_idle (GpgmeIdleFunc idle);
|
2000-10-27 14:55:24 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
|
2001-12-18 22:54:49 +00:00
|
|
|
/* Engine support functions. */
|
2002-01-30 01:17:30 +00:00
|
|
|
|
|
|
|
/* Verify that the engine implementing PROTO is installed and
|
|
|
|
available. */
|
2001-12-18 22:54:49 +00:00
|
|
|
GpgmeError gpgme_engine_check_version (GpgmeProtocol proto);
|
2000-10-27 14:55:24 +00:00
|
|
|
|
2002-01-30 01:17:30 +00:00
|
|
|
|
2000-10-27 14:55:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* GPGME_H */
|