diff --git a/gpg/VERSION b/gpg/VERSION new file mode 100644 index 0000000..8dec56b --- /dev/null +++ b/gpg/VERSION @@ -0,0 +1,2 @@ +gnupg +2.2.11 diff --git a/gpg/bin/dirmngr.exe b/gpg/bin/dirmngr.exe new file mode 100644 index 0000000..7904571 Binary files /dev/null and b/gpg/bin/dirmngr.exe differ diff --git a/gpg/bin/gpg-agent.exe b/gpg/bin/gpg-agent.exe new file mode 100644 index 0000000..3e5931b Binary files /dev/null and b/gpg/bin/gpg-agent.exe differ diff --git a/gpg/bin/gpg-connect-agent.exe b/gpg/bin/gpg-connect-agent.exe new file mode 100644 index 0000000..6d58fbe Binary files /dev/null and b/gpg/bin/gpg-connect-agent.exe differ diff --git a/gpg/bin/gpg-preset-passphrase.exe b/gpg/bin/gpg-preset-passphrase.exe new file mode 100644 index 0000000..d0f1f82 Binary files /dev/null and b/gpg/bin/gpg-preset-passphrase.exe differ diff --git a/gpg/bin/gpg-wks-client.exe b/gpg/bin/gpg-wks-client.exe new file mode 100644 index 0000000..f3229ef Binary files /dev/null and b/gpg/bin/gpg-wks-client.exe differ diff --git a/gpg/bin/gpg.exe b/gpg/bin/gpg.exe new file mode 100644 index 0000000..dae1025 Binary files /dev/null and b/gpg/bin/gpg.exe differ diff --git a/gpg/bin/gpgconf.ctl b/gpg/bin/gpgconf.ctl new file mode 100644 index 0000000..09e8dee --- /dev/null +++ b/gpg/bin/gpgconf.ctl @@ -0,0 +1,4 @@ +# The presence of this file switches GnuPG into portable mode. +# +# Install type is: vanilla +# (created by mkportable version 1.0) diff --git a/gpg/bin/gpgconf.exe b/gpg/bin/gpgconf.exe new file mode 100644 index 0000000..2482c6b Binary files /dev/null and b/gpg/bin/gpgconf.exe differ diff --git a/gpg/bin/gpgme-w32spawn.exe b/gpg/bin/gpgme-w32spawn.exe new file mode 100644 index 0000000..e929422 Binary files /dev/null and b/gpg/bin/gpgme-w32spawn.exe differ diff --git a/gpg/bin/gpgsm.exe b/gpg/bin/gpgsm.exe new file mode 100644 index 0000000..d2f0534 Binary files /dev/null and b/gpg/bin/gpgsm.exe differ diff --git a/gpg/bin/gpgtar.exe b/gpg/bin/gpgtar.exe new file mode 100644 index 0000000..9516feb Binary files /dev/null and b/gpg/bin/gpgtar.exe differ diff --git a/gpg/bin/gpgv.exe b/gpg/bin/gpgv.exe new file mode 100644 index 0000000..99946d8 Binary files /dev/null and b/gpg/bin/gpgv.exe differ diff --git a/gpg/bin/libassuan-0.dll b/gpg/bin/libassuan-0.dll new file mode 100644 index 0000000..227ded1 Binary files /dev/null and b/gpg/bin/libassuan-0.dll differ diff --git a/gpg/bin/libgcrypt-20.dll b/gpg/bin/libgcrypt-20.dll new file mode 100644 index 0000000..a83671f Binary files /dev/null and b/gpg/bin/libgcrypt-20.dll differ diff --git a/gpg/bin/libgpg-error-0.dll b/gpg/bin/libgpg-error-0.dll new file mode 100644 index 0000000..2dae9d3 Binary files /dev/null and b/gpg/bin/libgpg-error-0.dll differ diff --git a/gpg/bin/libgpgme-11.dll b/gpg/bin/libgpgme-11.dll new file mode 100644 index 0000000..454cf8b Binary files /dev/null and b/gpg/bin/libgpgme-11.dll differ diff --git a/gpg/bin/libksba-8.dll b/gpg/bin/libksba-8.dll new file mode 100644 index 0000000..02367da Binary files /dev/null and b/gpg/bin/libksba-8.dll differ diff --git a/gpg/bin/libnpth-0.dll b/gpg/bin/libnpth-0.dll new file mode 100644 index 0000000..5a130de Binary files /dev/null and b/gpg/bin/libnpth-0.dll differ diff --git a/gpg/bin/libsqlite3-0.dll b/gpg/bin/libsqlite3-0.dll new file mode 100644 index 0000000..6e18653 Binary files /dev/null and b/gpg/bin/libsqlite3-0.dll differ diff --git a/gpg/bin/pinentry-basic.exe b/gpg/bin/pinentry-basic.exe new file mode 100644 index 0000000..9baef4d Binary files /dev/null and b/gpg/bin/pinentry-basic.exe differ diff --git a/gpg/bin/scdaemon.exe b/gpg/bin/scdaemon.exe new file mode 100644 index 0000000..c69dd9a Binary files /dev/null and b/gpg/bin/scdaemon.exe differ diff --git a/gpg/bin/zlib1.dll b/gpg/bin/zlib1.dll new file mode 100644 index 0000000..daf1670 Binary files /dev/null and b/gpg/bin/zlib1.dll differ diff --git a/gpg/include/assuan.h b/gpg/include/assuan.h new file mode 100644 index 0000000..c6427fe --- /dev/null +++ b/gpg/include/assuan.h @@ -0,0 +1,676 @@ +/* assuan.h - Definitions for the Assuan IPC library -*- c -*- + * Copyright (C) 2001-2013 Free Software Foundation, Inc. + * Copyright (C) 2001-2017 g10 Code GmbH + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, see . + * SPDX-License-Identifier: LGPL-2.1+ + * + * Do not edit. Generated from assuan.h.in by mkheader for mingw32. + */ + +#ifndef ASSUAN_H +#define ASSUAN_H + +#include +#include +#include +#include + +#ifndef _ASSUAN_NO_SOCKET_WRAPPER +#include +#include +#endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/ + +typedef void *assuan_msghdr_t; + +#ifdef _MSC_VER + typedef long ssize_t; + typedef int pid_t; +#endif + + +#include + +/* Compile time configuration: + + #define _ASSUAN_NO_SOCKET_WRAPPER + + Do not include the definitions for the socket wrapper feature. */ + + +#ifdef __cplusplus +extern "C" +{ +#if 0 +} +#endif +#endif + +/* The version of this header should match the one of the library. Do + not use this symbol in your application; use assuan_check_version + instead. */ +#define ASSUAN_VERSION "2.5.1" + +/* The version number of this header. It may be used to handle minor + API incompatibilities. */ +#define ASSUAN_VERSION_NUMBER 0x020501 + + +/* Check for compiler features. */ +#if __GNUC__ +#define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if _ASSUAN_GCC_VERSION > 30100 +#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__)) +#endif +#endif +#ifndef _ASSUAN_DEPRECATED +#define _ASSUAN_DEPRECATED +#endif + + +#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */ + +struct assuan_context_s; +typedef struct assuan_context_s *assuan_context_t; + +/* Because we use system handles and not libc low level file + descriptors on W32, we need to declare them as HANDLE (which + actually is a plain pointer). This is required to eventually + support 64 bit Windows systems. */ +typedef void *assuan_fd_t; +#define ASSUAN_INVALID_FD ((void*)(-1)) +#define ASSUAN_INVALID_PID ((pid_t) -1) +static GPG_ERR_INLINE assuan_fd_t +assuan_fd_from_posix_fd (int fd) +{ + if (fd < 0) + return ASSUAN_INVALID_FD; + else + return (assuan_fd_t) _get_osfhandle (fd); +} + + +assuan_fd_t assuan_fdopen (int fd); + + +/* Assuan features an emulation of Unix domain sockets based on local + TCP connections. To implement access permissions based on file + permissions a nonce is used which is expected by the server as the + first bytes received. This structure is used by the server to save + the nonce created initially by bind. */ +struct assuan_sock_nonce_s +{ + size_t length; + char nonce[16]; +}; +typedef struct assuan_sock_nonce_s assuan_sock_nonce_t; + +/* Define the Unix domain socket structure for Windows. */ +#ifndef _ASSUAN_NO_SOCKET_WRAPPER +# ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +# endif +# ifndef EADDRINUSE +# define EADDRINUSE WSAEADDRINUSE +# endif +struct sockaddr_un +{ + short sun_family; + unsigned short sun_port; + struct in_addr sun_addr; + char sun_path[108-2-4]; +}; +#endif + + + +/* Global interface. */ + +struct assuan_malloc_hooks +{ + void *(*malloc) (size_t cnt); + void *(*realloc) (void *ptr, size_t cnt); + void (*free) (void *ptr); +}; +typedef struct assuan_malloc_hooks *assuan_malloc_hooks_t; + +/* Categories for log messages. */ +#define ASSUAN_LOG_INIT 1 +#define ASSUAN_LOG_CTX 2 +#define ASSUAN_LOG_ENGINE 3 +#define ASSUAN_LOG_DATA 4 +#define ASSUAN_LOG_SYSIO 5 +#define ASSUAN_LOG_CONTROL 8 + +/* If MSG is NULL, return true/false depending on if this category is + logged. This is used to probe before expensive log message + generation (buffer dumps). */ +typedef int (*assuan_log_cb_t) (assuan_context_t ctx, void *hook, + unsigned int cat, const char *msg); + +/* Return or check the version number. */ +const char *assuan_check_version (const char *req_version); + +/* Set the default gpg error source. */ +void assuan_set_gpg_err_source (gpg_err_source_t errsource); + +/* Get the default gpg error source. */ +gpg_err_source_t assuan_get_gpg_err_source (void); + + +/* Set the default malloc hooks. */ +void assuan_set_malloc_hooks (assuan_malloc_hooks_t malloc_hooks); + +/* Get the default malloc hooks. */ +assuan_malloc_hooks_t assuan_get_malloc_hooks (void); + + +/* Set the default log callback handler. */ +void assuan_set_log_cb (assuan_log_cb_t log_cb, void *log_cb_data); + +/* Get the default log callback handler. */ +void assuan_get_log_cb (assuan_log_cb_t *log_cb, void **log_cb_data); + + +/* Create a new Assuan context. The initial parameters are all needed + in the creation of the context. */ +gpg_error_t assuan_new_ext (assuan_context_t *ctx, gpg_err_source_t errsource, + assuan_malloc_hooks_t malloc_hooks, + assuan_log_cb_t log_cb, void *log_cb_data); + +/* Create a new context with default arguments. */ +gpg_error_t assuan_new (assuan_context_t *ctx); + +/* Release all resources associated with the given context. */ +void assuan_release (assuan_context_t ctx); + +/* Release the memory at PTR using the allocation handler of the + context CTX. This is a convenience function. */ +void assuan_free (assuan_context_t ctx, void *ptr); + + +/* Set user-data in a context. */ +void assuan_set_pointer (assuan_context_t ctx, void *pointer); + +/* Get user-data in a context. */ +void *assuan_get_pointer (assuan_context_t ctx); + + +/* Definitions of flags for assuan_set_flag(). */ +typedef unsigned int assuan_flag_t; + +/* When using a pipe server, by default Assuan will wait for the + forked process to die in assuan_release. In certain cases this + is not desirable. By setting this flag, the waitpid will be + skipped and the caller is responsible to cleanup a forked + process. */ +#define ASSUAN_NO_WAITPID 1 +/* This flag indicates whether Assuan logging is in confidential mode. + You can use assuan_{begin,end}_condidential to change the mode. */ +#define ASSUAN_CONFIDENTIAL 2 +/* This flag suppresses fix up of signal handlers for pipes. */ +#define ASSUAN_NO_FIXSIGNALS 3 +/* This flag changes assuan_transact to return comment lines via the + status callback. The default is to skip comment lines. */ +#define ASSUAN_CONVEY_COMMENTS 4 +/* This flag disables logging for one context. */ +#define ASSUAN_NO_LOGGING 5 +/* This flag forces a connection close. */ +#define ASSUAN_FORCE_CLOSE 6 + +/* For context CTX, set the flag FLAG to VALUE. Values for flags + are usually 1 or 0 but certain flags might allow for other values; + see the description of the type assuan_flag_t for details. */ +void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value); + +/* Return the VALUE of FLAG in context CTX. */ +int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); + + +/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 1). */ +void assuan_begin_confidential (assuan_context_t ctx); + +/* Same as assuan_set_flag (ctx, ASSUAN_CONFIDENTIAL, 0). */ +void assuan_end_confidential (assuan_context_t ctx); + + +/* Direction values for assuan_set_io_monitor. */ +#define ASSUAN_IO_FROM_PEER 0 +#define ASSUAN_IO_TO_PEER 1 + +/* Return flags of I/O monitor. */ +#define ASSUAN_IO_MONITOR_NOLOG 1 +#define ASSUAN_IO_MONITOR_IGNORE 2 + +/* The IO monitor gets to see all I/O on the context, and can return + ASSUAN_IO_MONITOR_* bits to control actions on it. */ +typedef unsigned int (*assuan_io_monitor_t) (assuan_context_t ctx, void *hook, + int inout, const char *line, + size_t linelen); + +/* Set the IO monitor function. */ +void assuan_set_io_monitor (assuan_context_t ctx, + assuan_io_monitor_t io_monitor, void *hook_data); + + +#define ASSUAN_SYSTEM_HOOKS_VERSION 2 +#define ASSUAN_SPAWN_DETACHED 128 +struct assuan_system_hooks +{ + /* Always set to ASSUAN_SYTEM_HOOKS_VERSION. */ + int version; + + /* Sleep for the given number of microseconds. */ + void (*usleep) (assuan_context_t ctx, unsigned int usec); + + /* Create a pipe with an inheritable end. */ + int (*pipe) (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx); + + /* Close the given file descriptor, created with _assuan_pipe or one + of the socket functions. */ + int (*close) (assuan_context_t ctx, assuan_fd_t fd); + + + ssize_t (*read) (assuan_context_t ctx, assuan_fd_t fd, void *buffer, + size_t size); + ssize_t (*write) (assuan_context_t ctx, assuan_fd_t fd, + const void *buffer, size_t size); + + int (*recvmsg) (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, + int flags); + int (*sendmsg) (assuan_context_t ctx, assuan_fd_t fd, + const assuan_msghdr_t msg, int flags); + + /* If NAME is NULL, don't exec, just fork. FD_CHILD_LIST is + modified to reflect the value of the FD in the peer process (on + Windows). */ + int (*spawn) (assuan_context_t ctx, pid_t *r_pid, const char *name, + const char **argv, + assuan_fd_t fd_in, assuan_fd_t fd_out, + assuan_fd_t *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue, unsigned int flags); + + /* If action is 0, like waitpid. If action is 1, just release the PID? */ + pid_t (*waitpid) (assuan_context_t ctx, pid_t pid, + int action, int *status, int options); + int (*socketpair) (assuan_context_t ctx, int _namespace, int style, + int protocol, assuan_fd_t filedes[2]); + int (*socket) (assuan_context_t ctx, int _namespace, int style, int protocol); + int (*connect) (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length); +}; +typedef struct assuan_system_hooks *assuan_system_hooks_t; + + +/* Configuration of the default log handler. */ + +/* Set the prefix to be used at the start of a line emitted by assuan + on the log stream. The default is the empty string. Note, that + this function is not thread-safe and should in general be used + right at startup. */ +void assuan_set_assuan_log_prefix (const char *text); + +/* Return a prefix to be used at the start of a line emitted by assuan + on the log stream. The default implementation returns the empty + string, i.e. "" */ +const char *assuan_get_assuan_log_prefix (void); + +/* Global default log stream. */ +void assuan_set_assuan_log_stream (FILE *fp); + +/* Set the per context log stream for the default log handler. */ +void assuan_set_log_stream (assuan_context_t ctx, FILE *fp); + + +typedef gpg_error_t (*assuan_handler_t) (assuan_context_t, char *); + +/*-- assuan-handler.c --*/ +gpg_error_t assuan_register_command (assuan_context_t ctx, + const char *cmd_string, + assuan_handler_t handler, + const char *help_string); +gpg_error_t assuan_register_pre_cmd_notify (assuan_context_t ctx, + gpg_error_t (*fnc)(assuan_context_t, const char *cmd)); +gpg_error_t assuan_register_post_cmd_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, + gpg_error_t)); +gpg_error_t assuan_register_bye_notify (assuan_context_t ctx, + assuan_handler_t handler); +gpg_error_t assuan_register_reset_notify (assuan_context_t ctx, + assuan_handler_t handler); +gpg_error_t assuan_register_cancel_notify (assuan_context_t ctx, + assuan_handler_t handler); +gpg_error_t assuan_register_input_notify (assuan_context_t ctx, + assuan_handler_t handler); +gpg_error_t assuan_register_output_notify (assuan_context_t ctx, + assuan_handler_t handler); + +gpg_error_t assuan_register_option_handler (assuan_context_t ctx, + gpg_error_t (*fnc)(assuan_context_t, + const char*, + const char*)); + +gpg_error_t assuan_process (assuan_context_t ctx); +gpg_error_t assuan_process_next (assuan_context_t ctx, int *done); +gpg_error_t assuan_process_done (assuan_context_t ctx, gpg_error_t rc); +int assuan_get_active_fds (assuan_context_t ctx, int what, + assuan_fd_t *fdarray, int fdarraysize); + +const char *assuan_get_command_name (assuan_context_t ctx); + +FILE *assuan_get_data_fp (assuan_context_t ctx); +gpg_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line); +gpg_error_t assuan_write_status (assuan_context_t ctx, + const char *keyword, const char *text); + +/* Negotiate a file descriptor. If LINE contains "FD=N", returns N + assuming a local file descriptor. If LINE contains "FD" reads a + file descriptor via CTX and stores it in *RDF (the CTX must be + capable of passing file descriptors). Under W32 the returned FD is + a libc-type one. */ +gpg_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line, + assuan_fd_t *rfd); + + +/*-- assuan-listen.c --*/ +gpg_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line); +gpg_error_t assuan_accept (assuan_context_t ctx); +assuan_fd_t assuan_get_input_fd (assuan_context_t ctx); +assuan_fd_t assuan_get_output_fd (assuan_context_t ctx); +gpg_error_t assuan_close_input_fd (assuan_context_t ctx); +gpg_error_t assuan_close_output_fd (assuan_context_t ctx); + + +/*-- assuan-pipe-server.c --*/ +gpg_error_t assuan_init_pipe_server (assuan_context_t ctx, + assuan_fd_t filedes[2]); + +/*-- assuan-socket-server.c --*/ +#define ASSUAN_SOCKET_SERVER_FDPASSING 1 +#define ASSUAN_SOCKET_SERVER_ACCEPTED 2 +gpg_error_t assuan_init_socket_server (assuan_context_t ctx, + assuan_fd_t listen_fd, + unsigned int flags); +void assuan_set_sock_nonce (assuan_context_t ctx, assuan_sock_nonce_t *nonce); + +/*-- assuan-pipe-connect.c --*/ +#define ASSUAN_PIPE_CONNECT_FDPASSING 1 +#define ASSUAN_PIPE_CONNECT_DETACHED 128 +gpg_error_t assuan_pipe_connect (assuan_context_t ctx, + const char *name, + const char *argv[], + assuan_fd_t *fd_child_list, + void (*atfork) (void *, int), + void *atforkvalue, + unsigned int flags); + +/*-- assuan-socket-connect.c --*/ +#define ASSUAN_SOCKET_CONNECT_FDPASSING 1 +gpg_error_t assuan_socket_connect (assuan_context_t ctx, const char *name, + pid_t server_pid, unsigned int flags); + +/*-- assuan-socket-connect.c --*/ +gpg_error_t assuan_socket_connect_fd (assuan_context_t ctx, int fd, + unsigned int flags); + +/*-- context.c --*/ +pid_t assuan_get_pid (assuan_context_t ctx); +struct _assuan_peercred +{ +#ifdef _WIN32 + /* Empty struct not allowed on some compilers. */ + unsigned int _dummy; +#else + pid_t pid; + uid_t uid; + gid_t gid; +#endif +}; +typedef struct _assuan_peercred *assuan_peercred_t; + +gpg_error_t assuan_get_peercred (assuan_context_t ctx, + assuan_peercred_t *peercred); + + + +/* Client interface. */ +#define ASSUAN_RESPONSE_ERROR 0 +#define ASSUAN_RESPONSE_OK 1 +#define ASSUAN_RESPONSE_DATA 2 +#define ASSUAN_RESPONSE_INQUIRE 3 +#define ASSUAN_RESPONSE_STATUS 4 +#define ASSUAN_RESPONSE_END 5 +#define ASSUAN_RESPONSE_COMMENT 6 +typedef int assuan_response_t; + +/* This already de-escapes data lines. */ +gpg_error_t assuan_client_read_response (assuan_context_t ctx, + char **line, int *linelen); + +gpg_error_t assuan_client_parse_response (assuan_context_t ctx, + char *line, int linelen, + assuan_response_t *response, + int *off); + +/*-- assuan-client.c --*/ +gpg_error_t +assuan_transact (assuan_context_t ctx, + const char *command, + gpg_error_t (*data_cb)(void *, const void *, size_t), + void *data_cb_arg, + gpg_error_t (*inquire_cb)(void*, const char *), + void *inquire_cb_arg, + gpg_error_t (*status_cb)(void*, const char *), + void *status_cb_arg); + + +/*-- assuan-inquire.c --*/ +gpg_error_t assuan_inquire (assuan_context_t ctx, const char *keyword, + unsigned char **r_buffer, size_t *r_length, + size_t maxlen); +gpg_error_t assuan_inquire_ext (assuan_context_t ctx, const char *keyword, + size_t maxlen, + gpg_error_t (*cb) (void *cb_data, + gpg_error_t rc, + unsigned char *buf, + size_t buf_len), + void *cb_data); +/*-- assuan-buffer.c --*/ +gpg_error_t assuan_read_line (assuan_context_t ctx, + char **line, size_t *linelen); +int assuan_pending_line (assuan_context_t ctx); +gpg_error_t assuan_write_line (assuan_context_t ctx, const char *line); +gpg_error_t assuan_send_data (assuan_context_t ctx, + const void *buffer, size_t length); + +/* The file descriptor must be pending before assuan_receivefd is + called. This means that assuan_sendfd should be called *before* the + trigger is sent (normally via assuan_write_line ("INPUT FD")). */ +gpg_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd); +gpg_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd); + + +/*-- assuan-util.c --*/ +gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err, + const char *text); + + + +/*-- assuan-socket.c --*/ + +/* This flag is used with assuan_sock_connect_byname to + connect via SOCKS. */ +#define ASSUAN_SOCK_SOCKS 1 +/* This flag is used with assuan_sock_connect_byname to force a + connection via Tor even if the socket subsystem has not been + swicthed into Tor mode. This flags overrides ASSUAN_SOCK_SOCKS. */ +#define ASSUAN_SOCK_TOR 2 + +/* These are socket wrapper functions to support an emulation of Unix + domain sockets on Windows W32. */ +gpg_error_t assuan_sock_init (void); +void assuan_sock_deinit (void); +int assuan_sock_close (assuan_fd_t fd); +assuan_fd_t assuan_sock_new (int domain, int type, int proto); +int assuan_sock_set_flag (assuan_fd_t sockfd, const char *name, int value); +int assuan_sock_get_flag (assuan_fd_t sockfd, const char *name, int *r_value); +int assuan_sock_connect (assuan_fd_t sockfd, + struct sockaddr *addr, int addrlen); +assuan_fd_t assuan_sock_connect_byname (const char *host, unsigned short port, + int reserved, + const char *credentials, + unsigned int flags); +int assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen); +int assuan_sock_set_sockaddr_un (const char *fname, struct sockaddr *addr, + int *r_redirected); +int assuan_sock_get_nonce (struct sockaddr *addr, int addrlen, + assuan_sock_nonce_t *nonce); +int assuan_sock_check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce); +void assuan_sock_set_system_hooks (assuan_system_hooks_t system_hooks); + + +/* Set the default system callbacks. This is irreversible. */ +void assuan_set_system_hooks (assuan_system_hooks_t system_hooks); + +/* Set the per context system callbacks. This is irreversible. */ +void assuan_ctx_set_system_hooks (assuan_context_t ctx, + assuan_system_hooks_t system_hooks); + +/* Change the system hooks for the socket interface. + * This is not thread-safe. */ +void assuan_sock_set_system_hooks (assuan_system_hooks_t system_hooks); + +void __assuan_usleep (assuan_context_t ctx, unsigned int usec); +int __assuan_pipe (assuan_context_t ctx, assuan_fd_t fd[2], int inherit_idx); +int __assuan_close (assuan_context_t ctx, assuan_fd_t fd); +int __assuan_spawn (assuan_context_t ctx, pid_t *r_pid, const char *name, + const char **argv, assuan_fd_t fd_in, assuan_fd_t fd_out, + assuan_fd_t *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue, unsigned int flags); +int __assuan_socketpair (assuan_context_t ctx, int _namespace, int style, + int protocol, assuan_fd_t filedes[2]); +int __assuan_socket (assuan_context_t ctx, int _namespace, int style, int protocol); +int __assuan_connect (assuan_context_t ctx, int sock, struct sockaddr *addr, socklen_t length); +ssize_t __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size); +ssize_t __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size); +int __assuan_recvmsg (assuan_context_t ctx, assuan_fd_t fd, assuan_msghdr_t msg, int flags); +int __assuan_sendmsg (assuan_context_t ctx, assuan_fd_t fd, const assuan_msghdr_t msg, int flags); +pid_t __assuan_waitpid (assuan_context_t ctx, pid_t pid, int nowait, int *status, int options); + + +#define ASSUAN_SYSTEM_PTH_IMPL \ + static void _assuan_pth_usleep (assuan_context_t ctx, unsigned int usec) \ + { (void) ctx; pth_usleep (usec); } \ + static ssize_t _assuan_pth_read (assuan_context_t ctx, assuan_fd_t fd, \ + void *buffer, size_t size) \ + { (void) ctx; return pth_read (fd, buffer, size); } \ + static ssize_t _assuan_pth_write (assuan_context_t ctx, assuan_fd_t fd, \ + const void *buffer, size_t size) \ + { (void) ctx; return pth_write (fd, buffer, size); } \ + static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \ + assuan_msghdr_t msg, int flags) \ + { \ + (void) ctx; \ + gpg_err_set_errno (ENOSYS); \ + return -1; \ + } \ + static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \ + const assuan_msghdr_t msg, int flags) \ + { \ + (void) ctx; \ + gpg_err_set_errno (ENOSYS); \ + return -1; \ + } \ + static pid_t _assuan_pth_waitpid (assuan_context_t ctx, pid_t pid, \ + int nowait, int *status, int options) \ + { (void) ctx; \ + if (!nowait) return pth_waitpid (pid, status, options); \ + else return 0; } \ + \ + struct assuan_system_hooks _assuan_system_pth = \ + { ASSUAN_SYSTEM_HOOKS_VERSION, _assuan_pth_usleep, __assuan_pipe, \ + __assuan_close, _assuan_pth_read, _assuan_pth_write, \ + _assuan_pth_recvmsg, _assuan_pth_sendmsg, \ + __assuan_spawn, _assuan_pth_waitpid, __assuan_socketpair, \ + __assuan_socket, __assuan_connect } + +extern struct assuan_system_hooks _assuan_system_pth; +#define ASSUAN_SYSTEM_PTH &_assuan_system_pth + +#define ASSUAN_SYSTEM_NPTH_IMPL \ + static void _assuan_npth_usleep (assuan_context_t ctx, unsigned int usec) \ + { npth_unprotect(); \ + __assuan_usleep (ctx, usec); \ + npth_protect(); } \ + static ssize_t _assuan_npth_read (assuan_context_t ctx, assuan_fd_t fd, \ + void *buffer, size_t size) \ + { ssize_t res; (void) ctx; npth_unprotect(); \ + res = __assuan_read (ctx, fd, buffer, size); \ + npth_protect(); return res; } \ + static ssize_t _assuan_npth_write (assuan_context_t ctx, assuan_fd_t fd, \ + const void *buffer, size_t size) \ + { ssize_t res; (void) ctx; npth_unprotect(); \ + res = __assuan_write (ctx, fd, buffer, size); \ + npth_protect(); return res; } \ + static int _assuan_npth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \ + assuan_msghdr_t msg, int flags) \ + { int res; (void) ctx; npth_unprotect(); \ + res = __assuan_recvmsg (ctx, fd, msg, flags); \ + npth_protect(); return res; } \ + static int _assuan_npth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \ + const assuan_msghdr_t msg, int flags) \ + { int res; (void) ctx; npth_unprotect(); \ + res = __assuan_sendmsg (ctx, fd, msg, flags); \ + npth_protect(); return res; } \ + static pid_t _assuan_npth_waitpid (assuan_context_t ctx, pid_t pid, \ + int nowait, int *status, int options) \ + { pid_t res; (void) ctx; npth_unprotect(); \ + res = __assuan_waitpid (ctx, pid, nowait, status, options); \ + npth_protect(); return res; } \ + static int _assuan_npth_connect (assuan_context_t ctx, int sock, \ + struct sockaddr *addr, socklen_t len)\ + { int res; npth_unprotect(); \ + res = __assuan_connect (ctx, sock, addr, len); \ + npth_protect(); return res; } \ + static int _assuan_npth_close (assuan_context_t ctx, assuan_fd_t fd) \ + { int res; npth_unprotect(); \ + res = __assuan_close (ctx, fd); \ + npth_protect(); return res; } \ + \ + struct assuan_system_hooks _assuan_system_npth = \ + { ASSUAN_SYSTEM_HOOKS_VERSION, _assuan_npth_usleep, __assuan_pipe, \ + _assuan_npth_close, _assuan_npth_read, _assuan_npth_write, \ + _assuan_npth_recvmsg, _assuan_npth_sendmsg, \ + __assuan_spawn, _assuan_npth_waitpid, __assuan_socketpair, \ + __assuan_socket, _assuan_npth_connect } + +extern struct assuan_system_hooks _assuan_system_npth; +#define ASSUAN_SYSTEM_NPTH &_assuan_system_npth + + +#ifdef __cplusplus +} +#endif +#endif /* ASSUAN_H */ +/* +Local Variables: +buffer-read-only: t +End: +*/ diff --git a/gpg/include/gcrypt.h b/gpg/include/gcrypt.h new file mode 100644 index 0000000..83c4b84 --- /dev/null +++ b/gpg/include/gcrypt.h @@ -0,0 +1,1798 @@ +/* gcrypt.h - GNU Cryptographic Library Interface -*- c -*- + * Copyright (C) 1998-2017 Free Software Foundation, Inc. + * Copyright (C) 2012-2017 g10 Code GmbH + * + * This file is part of Libgcrypt. + * + * Libgcrypt 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. + * + * Libgcrypt 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, see . + * + * File: src/gcrypt.h. Generated from gcrypt.h.in by configure. + */ + +#ifndef _GCRYPT_H +#define _GCRYPT_H + +#include +#include +#include + +#include + +#include + +#if defined _WIN32 || defined __WIN32__ +# include +# include +# include +# ifndef __GNUC__ + typedef long ssize_t; + typedef int pid_t; +# endif /*!__GNUC__*/ +#else +# include +# include +# +#endif /*!_WIN32*/ + +typedef int gcry_socklen_t; + +/* This is required for error code compatibility. */ +#define _GCRY_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GCRYPT + +#ifdef __cplusplus +extern "C" { +#if 0 /* (Keep Emacsens' auto-indent happy.) */ +} +#endif +#endif + +/* The version of this header should match the one of the library. It + should not be used by a program because gcry_check_version() should + return the same version. The purpose of this macro is to let + autoconf (using the AM_PATH_GCRYPT macro) check that this header + matches the installed library. */ +#define GCRYPT_VERSION "1.8.4" + +/* The version number of this header. It may be used to handle minor + API incompatibilities. */ +#define GCRYPT_VERSION_NUMBER 0x010804 + + +/* Internal: We can't use the convenience macros for the multi + precision integer functions when building this library. */ +#ifdef _GCRYPT_IN_LIBGCRYPT +#ifndef GCRYPT_NO_MPI_MACROS +#define GCRYPT_NO_MPI_MACROS 1 +#endif +#endif + +/* We want to use gcc attributes when possible. Warning: Don't use + these macros in your programs: As indicated by the leading + underscore they are subject to change without notice. */ +#ifdef __GNUC__ + +#define _GCRY_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if _GCRY_GCC_VERSION >= 30100 +#define _GCRY_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#if _GCRY_GCC_VERSION >= 29600 +#define _GCRY_GCC_ATTR_PURE __attribute__ ((__pure__)) +#endif + +#if _GCRY_GCC_VERSION >= 30200 +#define _GCRY_GCC_ATTR_MALLOC __attribute__ ((__malloc__)) +#endif + +#define _GCRY_GCC_ATTR_PRINTF(f,a) __attribute__ ((format (printf,f,a))) + +#if _GCRY_GCC_VERSION >= 40000 +#define _GCRY_GCC_ATTR_SENTINEL(a) __attribute__ ((sentinel(a))) +#endif + +#endif /*__GNUC__*/ + +#ifndef _GCRY_GCC_ATTR_DEPRECATED +#define _GCRY_GCC_ATTR_DEPRECATED +#endif +#ifndef _GCRY_GCC_ATTR_PURE +#define _GCRY_GCC_ATTR_PURE +#endif +#ifndef _GCRY_GCC_ATTR_MALLOC +#define _GCRY_GCC_ATTR_MALLOC +#endif +#ifndef _GCRY_GCC_ATTR_PRINTF +#define _GCRY_GCC_ATTR_PRINTF(f,a) +#endif +#ifndef _GCRY_GCC_ATTR_SENTINEL +#define _GCRY_GCC_ATTR_SENTINEL(a) +#endif + +/* Make up an attribute to mark functions and types as deprecated but + allow internal use by Libgcrypt. */ +#ifdef _GCRYPT_IN_LIBGCRYPT +#define _GCRY_ATTR_INTERNAL +#else +#define _GCRY_ATTR_INTERNAL _GCRY_GCC_ATTR_DEPRECATED +#endif + +/* Wrappers for the libgpg-error library. */ + +typedef gpg_error_t gcry_error_t; +typedef gpg_err_code_t gcry_err_code_t; +typedef gpg_err_source_t gcry_err_source_t; + +static GPG_ERR_INLINE gcry_error_t +gcry_err_make (gcry_err_source_t source, gcry_err_code_t code) +{ + return gpg_err_make (source, code); +} + +/* The user can define GPG_ERR_SOURCE_DEFAULT before including this + file to specify a default source for gpg_error. */ +#ifndef GCRY_ERR_SOURCE_DEFAULT +#define GCRY_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1 +#endif + +static GPG_ERR_INLINE gcry_error_t +gcry_error (gcry_err_code_t code) +{ + return gcry_err_make (GCRY_ERR_SOURCE_DEFAULT, code); +} + +static GPG_ERR_INLINE gcry_err_code_t +gcry_err_code (gcry_error_t err) +{ + return gpg_err_code (err); +} + + +static GPG_ERR_INLINE gcry_err_source_t +gcry_err_source (gcry_error_t err) +{ + return gpg_err_source (err); +} + +/* Return a pointer to a string containing a description of the error + code in the error value ERR. */ +const char *gcry_strerror (gcry_error_t err); + +/* Return a pointer to a string containing a description of the error + source in the error value ERR. */ +const char *gcry_strsource (gcry_error_t err); + +/* Retrieve the error code for the system error ERR. This returns + GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report + this). */ +gcry_err_code_t gcry_err_code_from_errno (int err); + +/* Retrieve the system error for the error code CODE. This returns 0 + if CODE is not a system error code. */ +int gcry_err_code_to_errno (gcry_err_code_t code); + +/* Return an error value with the error source SOURCE and the system + error ERR. */ +gcry_error_t gcry_err_make_from_errno (gcry_err_source_t source, int err); + +/* Return an error value with the system error ERR. */ +gcry_error_t gcry_error_from_errno (int err); + + +/* NOTE: Since Libgcrypt 1.6 the thread callbacks are not anymore + used. However we keep it to allow for some source code + compatibility if used in the standard way. */ + +/* Constants defining the thread model to use. Used with the OPTION + field of the struct gcry_thread_cbs. */ +#define GCRY_THREAD_OPTION_DEFAULT 0 +#define GCRY_THREAD_OPTION_USER 1 +#define GCRY_THREAD_OPTION_PTH 2 +#define GCRY_THREAD_OPTION_PTHREAD 3 + +/* The version number encoded in the OPTION field of the struct + gcry_thread_cbs. */ +#define GCRY_THREAD_OPTION_VERSION 1 + +/* Wrapper for struct ath_ops. */ +struct gcry_thread_cbs +{ + /* The OPTION field encodes the thread model and the version number + of this structure. + Bits 7 - 0 are used for the thread model + Bits 15 - 8 are used for the version number. */ + unsigned int option; +} _GCRY_ATTR_INTERNAL; + +#define GCRY_THREAD_OPTION_PTH_IMPL \ + static struct gcry_thread_cbs gcry_threads_pth = { \ + (GCRY_THREAD_OPTION_PTH | (GCRY_THREAD_OPTION_VERSION << 8))} + +#define GCRY_THREAD_OPTION_PTHREAD_IMPL \ + static struct gcry_thread_cbs gcry_threads_pthread = { \ + (GCRY_THREAD_OPTION_PTHREAD | (GCRY_THREAD_OPTION_VERSION << 8))} + + + +/* A generic context object as used by some functions. */ +struct gcry_context; +typedef struct gcry_context *gcry_ctx_t; + +/* The data objects used to hold multi precision integers. */ +struct gcry_mpi; +typedef struct gcry_mpi *gcry_mpi_t; +struct gcry_mpi_point; +typedef struct gcry_mpi_point *gcry_mpi_point_t; + +#ifndef GCRYPT_NO_DEPRECATED +typedef struct gcry_mpi *GCRY_MPI _GCRY_GCC_ATTR_DEPRECATED; +typedef struct gcry_mpi *GcryMPI _GCRY_GCC_ATTR_DEPRECATED; +#endif + +/* A structure used for scatter gather hashing. */ +typedef struct +{ + size_t size; /* The allocated size of the buffer or 0. */ + size_t off; /* Offset into the buffer. */ + size_t len; /* The used length of the buffer. */ + void *data; /* The buffer. */ +} gcry_buffer_t; + + + + +/* Check that the library fulfills the version requirement. */ +const char *gcry_check_version (const char *req_version); + +/* Codes for function dispatchers. */ + +/* Codes used with the gcry_control function. */ +enum gcry_ctl_cmds + { + /* Note: 1 .. 2 are not anymore used. */ + GCRYCTL_CFB_SYNC = 3, + GCRYCTL_RESET = 4, /* e.g. for MDs */ + GCRYCTL_FINALIZE = 5, + GCRYCTL_GET_KEYLEN = 6, + GCRYCTL_GET_BLKLEN = 7, + GCRYCTL_TEST_ALGO = 8, + GCRYCTL_IS_SECURE = 9, + GCRYCTL_GET_ASNOID = 10, + GCRYCTL_ENABLE_ALGO = 11, + GCRYCTL_DISABLE_ALGO = 12, + GCRYCTL_DUMP_RANDOM_STATS = 13, + GCRYCTL_DUMP_SECMEM_STATS = 14, + GCRYCTL_GET_ALGO_NPKEY = 15, + GCRYCTL_GET_ALGO_NSKEY = 16, + GCRYCTL_GET_ALGO_NSIGN = 17, + GCRYCTL_GET_ALGO_NENCR = 18, + GCRYCTL_SET_VERBOSITY = 19, + GCRYCTL_SET_DEBUG_FLAGS = 20, + GCRYCTL_CLEAR_DEBUG_FLAGS = 21, + GCRYCTL_USE_SECURE_RNDPOOL= 22, + GCRYCTL_DUMP_MEMORY_STATS = 23, + GCRYCTL_INIT_SECMEM = 24, + GCRYCTL_TERM_SECMEM = 25, + GCRYCTL_DISABLE_SECMEM_WARN = 27, + GCRYCTL_SUSPEND_SECMEM_WARN = 28, + GCRYCTL_RESUME_SECMEM_WARN = 29, + GCRYCTL_DROP_PRIVS = 30, + GCRYCTL_ENABLE_M_GUARD = 31, + GCRYCTL_START_DUMP = 32, + GCRYCTL_STOP_DUMP = 33, + GCRYCTL_GET_ALGO_USAGE = 34, + GCRYCTL_IS_ALGO_ENABLED = 35, + GCRYCTL_DISABLE_INTERNAL_LOCKING = 36, + GCRYCTL_DISABLE_SECMEM = 37, + GCRYCTL_INITIALIZATION_FINISHED = 38, + GCRYCTL_INITIALIZATION_FINISHED_P = 39, + GCRYCTL_ANY_INITIALIZATION_P = 40, + GCRYCTL_SET_CBC_CTS = 41, + GCRYCTL_SET_CBC_MAC = 42, + /* Note: 43 is not anymore used. */ + GCRYCTL_ENABLE_QUICK_RANDOM = 44, + GCRYCTL_SET_RANDOM_SEED_FILE = 45, + GCRYCTL_UPDATE_RANDOM_SEED_FILE = 46, + GCRYCTL_SET_THREAD_CBS = 47, + GCRYCTL_FAST_POLL = 48, + GCRYCTL_SET_RANDOM_DAEMON_SOCKET = 49, + GCRYCTL_USE_RANDOM_DAEMON = 50, + GCRYCTL_FAKED_RANDOM_P = 51, + GCRYCTL_SET_RNDEGD_SOCKET = 52, + GCRYCTL_PRINT_CONFIG = 53, + GCRYCTL_OPERATIONAL_P = 54, + GCRYCTL_FIPS_MODE_P = 55, + GCRYCTL_FORCE_FIPS_MODE = 56, + GCRYCTL_SELFTEST = 57, + /* Note: 58 .. 62 are used internally. */ + GCRYCTL_DISABLE_HWF = 63, + GCRYCTL_SET_ENFORCED_FIPS_FLAG = 64, + GCRYCTL_SET_PREFERRED_RNG_TYPE = 65, + GCRYCTL_GET_CURRENT_RNG_TYPE = 66, + GCRYCTL_DISABLE_LOCKED_SECMEM = 67, + GCRYCTL_DISABLE_PRIV_DROP = 68, + GCRYCTL_SET_CCM_LENGTHS = 69, + GCRYCTL_CLOSE_RANDOM_DEVICE = 70, + GCRYCTL_INACTIVATE_FIPS_FLAG = 71, + GCRYCTL_REACTIVATE_FIPS_FLAG = 72, + GCRYCTL_SET_SBOX = 73, + GCRYCTL_DRBG_REINIT = 74, + GCRYCTL_SET_TAGLEN = 75, + GCRYCTL_GET_TAGLEN = 76, + GCRYCTL_REINIT_SYSCALL_CLAMP = 77 + }; + +/* Perform various operations defined by CMD. */ +gcry_error_t gcry_control (enum gcry_ctl_cmds CMD, ...); + + +/* S-expression management. */ + +/* The object to represent an S-expression as used with the public key + functions. */ +struct gcry_sexp; +typedef struct gcry_sexp *gcry_sexp_t; + +#ifndef GCRYPT_NO_DEPRECATED +typedef struct gcry_sexp *GCRY_SEXP _GCRY_GCC_ATTR_DEPRECATED; +typedef struct gcry_sexp *GcrySexp _GCRY_GCC_ATTR_DEPRECATED; +#endif + +/* The possible values for the S-expression format. */ +enum gcry_sexp_format + { + GCRYSEXP_FMT_DEFAULT = 0, + GCRYSEXP_FMT_CANON = 1, + GCRYSEXP_FMT_BASE64 = 2, + GCRYSEXP_FMT_ADVANCED = 3 + }; + +/* Create an new S-expression object from BUFFER of size LENGTH and + return it in RETSEXP. With AUTODETECT set to 0 the data in BUFFER + is expected to be in canonized format. */ +gcry_error_t gcry_sexp_new (gcry_sexp_t *retsexp, + const void *buffer, size_t length, + int autodetect); + + /* Same as gcry_sexp_new but allows to pass a FREEFNC which has the + effect to transfer ownership of BUFFER to the created object. */ +gcry_error_t gcry_sexp_create (gcry_sexp_t *retsexp, + void *buffer, size_t length, + int autodetect, void (*freefnc) (void *)); + +/* Scan BUFFER and return a new S-expression object in RETSEXP. This + function expects a printf like string in BUFFER. */ +gcry_error_t gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, + const char *buffer, size_t length); + +/* Same as gcry_sexp_sscan but expects a string in FORMAT and can thus + only be used for certain encodings. */ +gcry_error_t gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, + const char *format, ...); + +/* Like gcry_sexp_build, but uses an array instead of variable + function arguments. */ +gcry_error_t gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff, + const char *format, void **arg_list); + +/* Release the S-expression object SEXP */ +void gcry_sexp_release (gcry_sexp_t sexp); + +/* Calculate the length of an canonized S-expression in BUFFER and + check for a valid encoding. */ +size_t gcry_sexp_canon_len (const unsigned char *buffer, size_t length, + size_t *erroff, gcry_error_t *errcode); + +/* Copies the S-expression object SEXP into BUFFER using the format + specified in MODE. */ +size_t gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, + size_t maxlength); + +/* Dumps the S-expression object A in a format suitable for debugging + to Libgcrypt's logging stream. */ +void gcry_sexp_dump (const gcry_sexp_t a); + +gcry_sexp_t gcry_sexp_cons (const gcry_sexp_t a, const gcry_sexp_t b); +gcry_sexp_t gcry_sexp_alist (const gcry_sexp_t *array); +gcry_sexp_t gcry_sexp_vlist (const gcry_sexp_t a, ...); +gcry_sexp_t gcry_sexp_append (const gcry_sexp_t a, const gcry_sexp_t n); +gcry_sexp_t gcry_sexp_prepend (const gcry_sexp_t a, const gcry_sexp_t n); + +/* Scan the S-expression for a sublist with a type (the car of the + list) matching the string TOKEN. If TOKLEN is not 0, the token is + assumed to be raw memory of this length. The function returns a + newly allocated S-expression consisting of the found sublist or + `NULL' when not found. */ +gcry_sexp_t gcry_sexp_find_token (gcry_sexp_t list, + const char *tok, size_t toklen); +/* Return the length of the LIST. For a valid S-expression this + should be at least 1. */ +int gcry_sexp_length (const gcry_sexp_t list); + +/* Create and return a new S-expression from the element with index + NUMBER in LIST. Note that the first element has the index 0. If + there is no such element, `NULL' is returned. */ +gcry_sexp_t gcry_sexp_nth (const gcry_sexp_t list, int number); + +/* Create and return a new S-expression from the first element in + LIST; this called the "type" and should always exist and be a + string. `NULL' is returned in case of a problem. */ +gcry_sexp_t gcry_sexp_car (const gcry_sexp_t list); + +/* Create and return a new list form all elements except for the first + one. Note, that this function may return an invalid S-expression + because it is not guaranteed, that the type exists and is a string. + However, for parsing a complex S-expression it might be useful for + intermediate lists. Returns `NULL' on error. */ +gcry_sexp_t gcry_sexp_cdr (const gcry_sexp_t list); + +gcry_sexp_t gcry_sexp_cadr (const gcry_sexp_t list); + + +/* This function is used to get data from a LIST. A pointer to the + actual data with index NUMBER is returned and the length of this + data will be stored to DATALEN. If there is no data at the given + index or the index represents another list, `NULL' is returned. + *Note:* The returned pointer is valid as long as LIST is not + modified or released. */ +const char *gcry_sexp_nth_data (const gcry_sexp_t list, int number, + size_t *datalen); + +/* This function is used to get data from a LIST. A malloced buffer to the + data with index NUMBER is returned and the length of this + data will be stored to RLENGTH. If there is no data at the given + index or the index represents another list, `NULL' is returned. */ +void *gcry_sexp_nth_buffer (const gcry_sexp_t list, int number, + size_t *rlength); + +/* This function is used to get and convert data from a LIST. The + data is assumed to be a Nul terminated string. The caller must + release the returned value using `gcry_free'. If there is no data + at the given index, the index represents a list or the value can't + be converted to a string, `NULL' is returned. */ +char *gcry_sexp_nth_string (gcry_sexp_t list, int number); + +/* This function is used to get and convert data from a LIST. This + data is assumed to be an MPI stored in the format described by + MPIFMT and returned as a standard Libgcrypt MPI. The caller must + release this returned value using `gcry_mpi_release'. If there is + no data at the given index, the index represents a list or the + value can't be converted to an MPI, `NULL' is returned. */ +gcry_mpi_t gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt); + +/* Extract MPIs from an s-expression using a list of parameters. The + * names of these parameters are given by the string LIST. Some + * special characters may be given to control the conversion: + * + * + :: Switch to unsigned integer format (default). + * - :: Switch to standard signed format. + * / :: Switch to opaque format. + * & :: Switch to buffer descriptor mode - see below. + * ? :: The previous parameter is optional. + * + * In general parameter names are single letters. To use a string for + * a parameter name, enclose the name in single quotes. + * + * Unless in gcry_buffer_t mode for each parameter name a pointer to + * an MPI variable is expected that must be set to NULL prior to + * invoking this function, and finally a NULL is expected. Example: + * + * _gcry_sexp_extract_param (key, NULL, "n/x+ed", + * &mpi_n, &mpi_x, &mpi_e, NULL) + * + * This stores the parameter "N" from KEY as an unsigned MPI into + * MPI_N, the parameter "X" as an opaque MPI into MPI_X, and the + * parameter "E" again as an unsigned MPI into MPI_E. + * + * If in buffer descriptor mode a pointer to gcry_buffer_t descriptor + * is expected instead of a pointer to an MPI. The caller may use two + * different operation modes: If the DATA field of the provided buffer + * descriptor is NULL, the function allocates a new buffer and stores + * it at DATA; the other fields are set accordingly with OFF being 0. + * If DATA is not NULL, the function assumes that DATA, SIZE, and OFF + * describe a buffer where to but the data; on return the LEN field + * receives the number of bytes copied to that buffer; if the buffer + * is too small, the function immediately returns with an error code + * (and LEN set to 0). + * + * PATH is an optional string used to locate a token. The exclamation + * mark separated tokens are used to via gcry_sexp_find_token to find + * a start point inside SEXP. + * + * The function returns 0 on success. On error an error code is + * returned, all passed MPIs that might have been allocated up to this + * point are deallocated and set to NULL, and all passed buffers are + * either truncated if the caller supplied the buffer, or deallocated + * if the function allocated the buffer. + */ +gpg_error_t gcry_sexp_extract_param (gcry_sexp_t sexp, + const char *path, + const char *list, + ...) _GCRY_GCC_ATTR_SENTINEL(0); + + +/******************************************* + * * + * Multi Precision Integer Functions * + * * + *******************************************/ + +/* Different formats of external big integer representation. */ +enum gcry_mpi_format + { + GCRYMPI_FMT_NONE= 0, + GCRYMPI_FMT_STD = 1, /* Twos complement stored without length. */ + GCRYMPI_FMT_PGP = 2, /* As used by OpenPGP (unsigned only). */ + GCRYMPI_FMT_SSH = 3, /* As used by SSH (like STD but with length). */ + GCRYMPI_FMT_HEX = 4, /* Hex format. */ + GCRYMPI_FMT_USG = 5, /* Like STD but unsigned. */ + GCRYMPI_FMT_OPAQUE = 8 /* Opaque format (some functions only). */ + }; + +/* Flags used for creating big integers. */ +enum gcry_mpi_flag + { + GCRYMPI_FLAG_SECURE = 1, /* Allocate the number in "secure" memory. */ + GCRYMPI_FLAG_OPAQUE = 2, /* The number is not a real one but just + a way to store some bytes. This is + useful for encrypted big integers. */ + GCRYMPI_FLAG_IMMUTABLE = 4, /* Mark the MPI as immutable. */ + GCRYMPI_FLAG_CONST = 8, /* Mark the MPI as a constant. */ + GCRYMPI_FLAG_USER1 = 0x0100,/* User flag 1. */ + GCRYMPI_FLAG_USER2 = 0x0200,/* User flag 2. */ + GCRYMPI_FLAG_USER3 = 0x0400,/* User flag 3. */ + GCRYMPI_FLAG_USER4 = 0x0800 /* User flag 4. */ + }; + + +/* Macros to return pre-defined MPI constants. */ +#define GCRYMPI_CONST_ONE (_gcry_mpi_get_const (1)) +#define GCRYMPI_CONST_TWO (_gcry_mpi_get_const (2)) +#define GCRYMPI_CONST_THREE (_gcry_mpi_get_const (3)) +#define GCRYMPI_CONST_FOUR (_gcry_mpi_get_const (4)) +#define GCRYMPI_CONST_EIGHT (_gcry_mpi_get_const (8)) + +/* Allocate a new big integer object, initialize it with 0 and + initially allocate memory for a number of at least NBITS. */ +gcry_mpi_t gcry_mpi_new (unsigned int nbits); + +/* Same as gcry_mpi_new() but allocate in "secure" memory. */ +gcry_mpi_t gcry_mpi_snew (unsigned int nbits); + +/* Release the number A and free all associated resources. */ +void gcry_mpi_release (gcry_mpi_t a); + +/* Create a new number with the same value as A. */ +gcry_mpi_t gcry_mpi_copy (const gcry_mpi_t a); + +/* Store the big integer value U in W and release U. */ +void gcry_mpi_snatch (gcry_mpi_t w, gcry_mpi_t u); + +/* Store the big integer value U in W. */ +gcry_mpi_t gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u); + +/* Store the unsigned integer value U in W. */ +gcry_mpi_t gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u); + +/* Swap the values of A and B. */ +void gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b); + +/* Return 1 if A is negative; 0 if zero or positive. */ +int gcry_mpi_is_neg (gcry_mpi_t a); + +/* W = - U */ +void gcry_mpi_neg (gcry_mpi_t w, gcry_mpi_t u); + +/* W = [W] */ +void gcry_mpi_abs (gcry_mpi_t w); + +/* Compare the big integer number U and V returning 0 for equality, a + positive value for U > V and a negative for U < V. */ +int gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v); + +/* Compare the big integer number U with the unsigned integer V + returning 0 for equality, a positive value for U > V and a negative + for U < V. */ +int gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v); + +/* Convert the external representation of an integer stored in BUFFER + with a length of BUFLEN into a newly create MPI returned in + RET_MPI. If NSCANNED is not NULL, it will receive the number of + bytes actually scanned after a successful operation. */ +gcry_error_t gcry_mpi_scan (gcry_mpi_t *ret_mpi, enum gcry_mpi_format format, + const void *buffer, size_t buflen, + size_t *nscanned); + +/* Convert the big integer A into the external representation + described by FORMAT and store it in the provided BUFFER which has + been allocated by the user with a size of BUFLEN bytes. NWRITTEN + receives the actual length of the external representation unless it + has been passed as NULL. */ +gcry_error_t gcry_mpi_print (enum gcry_mpi_format format, + unsigned char *buffer, size_t buflen, + size_t *nwritten, + const gcry_mpi_t a); + +/* Convert the big integer A into the external representation described + by FORMAT and store it in a newly allocated buffer which address + will be put into BUFFER. NWRITTEN receives the actual lengths of the + external representation. */ +gcry_error_t gcry_mpi_aprint (enum gcry_mpi_format format, + unsigned char **buffer, size_t *nwritten, + const gcry_mpi_t a); + +/* Dump the value of A in a format suitable for debugging to + Libgcrypt's logging stream. Note that one leading space but no + trailing space or linefeed will be printed. It is okay to pass + NULL for A. */ +void gcry_mpi_dump (const gcry_mpi_t a); + + +/* W = U + V. */ +void gcry_mpi_add (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v); + +/* W = U + V. V is an unsigned integer. */ +void gcry_mpi_add_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v); + +/* W = U + V mod M. */ +void gcry_mpi_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m); + +/* W = U - V. */ +void gcry_mpi_sub (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v); + +/* W = U - V. V is an unsigned integer. */ +void gcry_mpi_sub_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v ); + +/* W = U - V mod M */ +void gcry_mpi_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m); + +/* W = U * V. */ +void gcry_mpi_mul (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v); + +/* W = U * V. V is an unsigned integer. */ +void gcry_mpi_mul_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v ); + +/* W = U * V mod M. */ +void gcry_mpi_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m); + +/* W = U * (2 ^ CNT). */ +void gcry_mpi_mul_2exp (gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt); + +/* Q = DIVIDEND / DIVISOR, R = DIVIDEND % DIVISOR, + Q or R may be passed as NULL. ROUND should be negative or 0. */ +void gcry_mpi_div (gcry_mpi_t q, gcry_mpi_t r, + gcry_mpi_t dividend, gcry_mpi_t divisor, int round); + +/* R = DIVIDEND % DIVISOR */ +void gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor); + +/* W = B ^ E mod M. */ +void gcry_mpi_powm (gcry_mpi_t w, + const gcry_mpi_t b, const gcry_mpi_t e, + const gcry_mpi_t m); + +/* Set G to the greatest common divisor of A and B. + Return true if the G is 1. */ +int gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b); + +/* Set X to the multiplicative inverse of A mod M. + Return true if the value exists. */ +int gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m); + +/* Create a new point object. NBITS is usually 0. */ +gcry_mpi_point_t gcry_mpi_point_new (unsigned int nbits); + +/* Release the object POINT. POINT may be NULL. */ +void gcry_mpi_point_release (gcry_mpi_point_t point); + +/* Return a copy of POINT. */ +gcry_mpi_point_t gcry_mpi_point_copy (gcry_mpi_point_t point); + +/* Store the projective coordinates from POINT into X, Y, and Z. */ +void gcry_mpi_point_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z, + gcry_mpi_point_t point); + +/* Store the projective coordinates from POINT into X, Y, and Z and + release POINT. */ +void gcry_mpi_point_snatch_get (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z, + gcry_mpi_point_t point); + +/* Store the projective coordinates X, Y, and Z into POINT. */ +gcry_mpi_point_t gcry_mpi_point_set (gcry_mpi_point_t point, + gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_t z); + +/* Store the projective coordinates X, Y, and Z into POINT and release + X, Y, and Z. */ +gcry_mpi_point_t gcry_mpi_point_snatch_set (gcry_mpi_point_t point, + gcry_mpi_t x, gcry_mpi_t y, + gcry_mpi_t z); + +/* Allocate a new context for elliptic curve operations based on the + parameters given by KEYPARAM or using CURVENAME. */ +gpg_error_t gcry_mpi_ec_new (gcry_ctx_t *r_ctx, + gcry_sexp_t keyparam, const char *curvename); + +/* Get a named MPI from an elliptic curve context. */ +gcry_mpi_t gcry_mpi_ec_get_mpi (const char *name, gcry_ctx_t ctx, int copy); + +/* Get a named point from an elliptic curve context. */ +gcry_mpi_point_t gcry_mpi_ec_get_point (const char *name, + gcry_ctx_t ctx, int copy); + +/* Store a named MPI into an elliptic curve context. */ +gpg_error_t gcry_mpi_ec_set_mpi (const char *name, gcry_mpi_t newvalue, + gcry_ctx_t ctx); + +/* Store a named point into an elliptic curve context. */ +gpg_error_t gcry_mpi_ec_set_point (const char *name, gcry_mpi_point_t newvalue, + gcry_ctx_t ctx); + +/* Decode and store VALUE into RESULT. */ +gpg_error_t gcry_mpi_ec_decode_point (gcry_mpi_point_t result, + gcry_mpi_t value, gcry_ctx_t ctx); + +/* Store the affine coordinates of POINT into X and Y. */ +int gcry_mpi_ec_get_affine (gcry_mpi_t x, gcry_mpi_t y, gcry_mpi_point_t point, + gcry_ctx_t ctx); + +/* W = 2 * U. */ +void gcry_mpi_ec_dup (gcry_mpi_point_t w, gcry_mpi_point_t u, gcry_ctx_t ctx); + +/* W = U + V. */ +void gcry_mpi_ec_add (gcry_mpi_point_t w, + gcry_mpi_point_t u, gcry_mpi_point_t v, gcry_ctx_t ctx); + +/* W = U - V. */ +void gcry_mpi_ec_sub (gcry_mpi_point_t w, + gcry_mpi_point_t u, gcry_mpi_point_t v, gcry_ctx_t ctx); + +/* W = N * U. */ +void gcry_mpi_ec_mul (gcry_mpi_point_t w, gcry_mpi_t n, gcry_mpi_point_t u, + gcry_ctx_t ctx); + +/* Return true if POINT is on the curve described by CTX. */ +int gcry_mpi_ec_curve_point (gcry_mpi_point_t w, gcry_ctx_t ctx); + +/* Return the number of bits required to represent A. */ +unsigned int gcry_mpi_get_nbits (gcry_mpi_t a); + +/* Return true when bit number N (counting from 0) is set in A. */ +int gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n); + +/* Set bit number N in A. */ +void gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n); + +/* Clear bit number N in A. */ +void gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n); + +/* Set bit number N in A and clear all bits greater than N. */ +void gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n); + +/* Clear bit number N in A and all bits greater than N. */ +void gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n); + +/* Shift the value of A by N bits to the right and store the result in X. */ +void gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n); + +/* Shift the value of A by N bits to the left and store the result in X. */ +void gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n); + +/* Store NBITS of the value P points to in A and mark A as an opaque + value. On success A received the the ownership of the value P. + WARNING: Never use an opaque MPI for anything thing else than + gcry_mpi_release, gcry_mpi_get_opaque. */ +gcry_mpi_t gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits); + +/* Store NBITS of the value P points to in A and mark A as an opaque + value. The function takes a copy of the provided value P. + WARNING: Never use an opaque MPI for anything thing else than + gcry_mpi_release, gcry_mpi_get_opaque. */ +gcry_mpi_t gcry_mpi_set_opaque_copy (gcry_mpi_t a, + const void *p, unsigned int nbits); + +/* Return a pointer to an opaque value stored in A and return its size + in NBITS. Note that the returned pointer is still owned by A and + that the function should never be used for an non-opaque MPI. */ +void *gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits); + +/* Set the FLAG for the big integer A. Currently only the flag + GCRYMPI_FLAG_SECURE is allowed to convert A into an big intger + stored in "secure" memory. */ +void gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag); + +/* Clear FLAG for the big integer A. Note that this function is + currently useless as no flags are allowed. */ +void gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag); + +/* Return true if the FLAG is set for A. */ +int gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag); + +/* Private function - do not use. */ +gcry_mpi_t _gcry_mpi_get_const (int no); + +/* Unless the GCRYPT_NO_MPI_MACROS is used, provide a couple of + convenience macros for the big integer functions. */ +#ifndef GCRYPT_NO_MPI_MACROS +#define mpi_new(n) gcry_mpi_new( (n) ) +#define mpi_secure_new( n ) gcry_mpi_snew( (n) ) +#define mpi_release(a) \ + do \ + { \ + gcry_mpi_release ((a)); \ + (a) = NULL; \ + } \ + while (0) + +#define mpi_copy( a ) gcry_mpi_copy( (a) ) +#define mpi_snatch( w, u) gcry_mpi_snatch( (w), (u) ) +#define mpi_set( w, u) gcry_mpi_set( (w), (u) ) +#define mpi_set_ui( w, u) gcry_mpi_set_ui( (w), (u) ) +#define mpi_abs( w ) gcry_mpi_abs( (w) ) +#define mpi_neg( w, u) gcry_mpi_neg( (w), (u) ) +#define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) ) +#define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) ) +#define mpi_is_neg( a ) gcry_mpi_is_neg ((a)) + +#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v)) +#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v)) +#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m)) +#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v)) +#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v)) +#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m)) +#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v)) +#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v)) +#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v)) +#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m)) +#define mpi_powm(w,b,e,m) gcry_mpi_powm ( (w), (b), (e), (m) ) +#define mpi_tdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), 0) +#define mpi_fdiv(q,r,a,m) gcry_mpi_div ( (q), (r), (a), (m), -1) +#define mpi_mod(r,a,m) gcry_mpi_mod ((r), (a), (m)) +#define mpi_gcd(g,a,b) gcry_mpi_gcd ( (g), (a), (b) ) +#define mpi_invm(g,a,b) gcry_mpi_invm ( (g), (a), (b) ) + +#define mpi_point_new(n) gcry_mpi_point_new((n)) +#define mpi_point_release(p) \ + do \ + { \ + gcry_mpi_point_release ((p)); \ + (p) = NULL; \ + } \ + while (0) +#define mpi_point_copy(p) gcry_mpi_point_copy((p)) +#define mpi_point_get(x,y,z,p) gcry_mpi_point_get((x),(y),(z),(p)) +#define mpi_point_snatch_get(x,y,z,p) gcry_mpi_point_snatch_get((x),(y),(z),(p)) +#define mpi_point_set(p,x,y,z) gcry_mpi_point_set((p),(x),(y),(z)) +#define mpi_point_snatch_set(p,x,y,z) gcry_mpi_point_snatch_set((p),(x),(y),(z)) + +#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a)) +#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b)) +#define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b)) +#define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b)) +#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b)) +#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b)) +#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c)) +#define mpi_lshift(a,b,c) gcry_mpi_lshift ((a),(b),(c)) + +#define mpi_set_opaque(a,b,c) gcry_mpi_set_opaque( (a), (b), (c) ) +#define mpi_get_opaque(a,b) gcry_mpi_get_opaque( (a), (b) ) +#endif /* GCRYPT_NO_MPI_MACROS */ + + + +/************************************ + * * + * Symmetric Cipher Functions * + * * + ************************************/ + +/* The data object used to hold a handle to an encryption object. */ +struct gcry_cipher_handle; +typedef struct gcry_cipher_handle *gcry_cipher_hd_t; + +#ifndef GCRYPT_NO_DEPRECATED +typedef struct gcry_cipher_handle *GCRY_CIPHER_HD _GCRY_GCC_ATTR_DEPRECATED; +typedef struct gcry_cipher_handle *GcryCipherHd _GCRY_GCC_ATTR_DEPRECATED; +#endif + +/* All symmetric encryption algorithms are identified by their IDs. + More IDs may be registered at runtime. */ +enum gcry_cipher_algos + { + GCRY_CIPHER_NONE = 0, + GCRY_CIPHER_IDEA = 1, + GCRY_CIPHER_3DES = 2, + GCRY_CIPHER_CAST5 = 3, + GCRY_CIPHER_BLOWFISH = 4, + GCRY_CIPHER_SAFER_SK128 = 5, + GCRY_CIPHER_DES_SK = 6, + GCRY_CIPHER_AES = 7, + GCRY_CIPHER_AES192 = 8, + GCRY_CIPHER_AES256 = 9, + GCRY_CIPHER_TWOFISH = 10, + + /* Other cipher numbers are above 300 for OpenPGP reasons. */ + GCRY_CIPHER_ARCFOUR = 301, /* Fully compatible with RSA's RC4 (tm). */ + GCRY_CIPHER_DES = 302, /* Yes, this is single key 56 bit DES. */ + GCRY_CIPHER_TWOFISH128 = 303, + GCRY_CIPHER_SERPENT128 = 304, + GCRY_CIPHER_SERPENT192 = 305, + GCRY_CIPHER_SERPENT256 = 306, + GCRY_CIPHER_RFC2268_40 = 307, /* Ron's Cipher 2 (40 bit). */ + GCRY_CIPHER_RFC2268_128 = 308, /* Ron's Cipher 2 (128 bit). */ + GCRY_CIPHER_SEED = 309, /* 128 bit cipher described in RFC4269. */ + GCRY_CIPHER_CAMELLIA128 = 310, + GCRY_CIPHER_CAMELLIA192 = 311, + GCRY_CIPHER_CAMELLIA256 = 312, + GCRY_CIPHER_SALSA20 = 313, + GCRY_CIPHER_SALSA20R12 = 314, + GCRY_CIPHER_GOST28147 = 315, + GCRY_CIPHER_CHACHA20 = 316 + }; + +/* The Rijndael algorithm is basically AES, so provide some macros. */ +#define GCRY_CIPHER_AES128 GCRY_CIPHER_AES +#define GCRY_CIPHER_RIJNDAEL GCRY_CIPHER_AES +#define GCRY_CIPHER_RIJNDAEL128 GCRY_CIPHER_AES128 +#define GCRY_CIPHER_RIJNDAEL192 GCRY_CIPHER_AES192 +#define GCRY_CIPHER_RIJNDAEL256 GCRY_CIPHER_AES256 + +/* The supported encryption modes. Note that not all of them are + supported for each algorithm. */ +enum gcry_cipher_modes + { + GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */ + GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */ + GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */ + GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */ + GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */ + GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */ + GCRY_CIPHER_MODE_CTR = 6, /* Counter. */ + GCRY_CIPHER_MODE_AESWRAP = 7, /* AES-WRAP algorithm. */ + GCRY_CIPHER_MODE_CCM = 8, /* Counter with CBC-MAC. */ + GCRY_CIPHER_MODE_GCM = 9, /* Galois Counter Mode. */ + GCRY_CIPHER_MODE_POLY1305 = 10, /* Poly1305 based AEAD mode. */ + GCRY_CIPHER_MODE_OCB = 11, /* OCB3 mode. */ + GCRY_CIPHER_MODE_CFB8 = 12, /* Cipher feedback (8 bit mode). */ + GCRY_CIPHER_MODE_XTS = 13 /* XTS mode. */ + }; + +/* Flags used with the open function. */ +enum gcry_cipher_flags + { + GCRY_CIPHER_SECURE = 1, /* Allocate in secure memory. */ + GCRY_CIPHER_ENABLE_SYNC = 2, /* Enable CFB sync mode. */ + GCRY_CIPHER_CBC_CTS = 4, /* Enable CBC cipher text stealing (CTS). */ + GCRY_CIPHER_CBC_MAC = 8 /* Enable CBC message auth. code (MAC). */ + }; + +/* GCM works only with blocks of 128 bits */ +#define GCRY_GCM_BLOCK_LEN (128 / 8) + +/* CCM works only with blocks of 128 bits. */ +#define GCRY_CCM_BLOCK_LEN (128 / 8) + +/* OCB works only with blocks of 128 bits. */ +#define GCRY_OCB_BLOCK_LEN (128 / 8) + +/* XTS works only with blocks of 128 bits. */ +#define GCRY_XTS_BLOCK_LEN (128 / 8) + +/* Create a handle for algorithm ALGO to be used in MODE. FLAGS may + be given as an bitwise OR of the gcry_cipher_flags values. */ +gcry_error_t gcry_cipher_open (gcry_cipher_hd_t *handle, + int algo, int mode, unsigned int flags); + +/* Close the cipher handle H and release all resource. */ +void gcry_cipher_close (gcry_cipher_hd_t h); + +/* Perform various operations on the cipher object H. */ +gcry_error_t gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, + size_t buflen); + +/* Retrieve various information about the cipher object H. */ +gcry_error_t gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer, + size_t *nbytes); + +/* Retrieve various information about the cipher algorithm ALGO. */ +gcry_error_t gcry_cipher_algo_info (int algo, int what, void *buffer, + size_t *nbytes); + +/* Map the cipher algorithm whose ID is contained in ALGORITHM to a + string representation of the algorithm name. For unknown algorithm + IDs this function returns "?". */ +const char *gcry_cipher_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE; + +/* Map the algorithm name NAME to an cipher algorithm ID. Return 0 if + the algorithm name is not known. */ +int gcry_cipher_map_name (const char *name) _GCRY_GCC_ATTR_PURE; + +/* Given an ASN.1 object identifier in standard IETF dotted decimal + format in STRING, return the encryption mode associated with that + OID or 0 if not known or applicable. */ +int gcry_cipher_mode_from_oid (const char *string) _GCRY_GCC_ATTR_PURE; + +/* Encrypt the plaintext of size INLEN in IN using the cipher handle H + into the buffer OUT which has an allocated length of OUTSIZE. For + most algorithms it is possible to pass NULL for in and 0 for INLEN + and do a in-place decryption of the data provided in OUT. */ +gcry_error_t gcry_cipher_encrypt (gcry_cipher_hd_t h, + void *out, size_t outsize, + const void *in, size_t inlen); + +/* The counterpart to gcry_cipher_encrypt. */ +gcry_error_t gcry_cipher_decrypt (gcry_cipher_hd_t h, + void *out, size_t outsize, + const void *in, size_t inlen); + +/* Set KEY of length KEYLEN bytes for the cipher handle HD. */ +gcry_error_t gcry_cipher_setkey (gcry_cipher_hd_t hd, + const void *key, size_t keylen); + + +/* Set initialization vector IV of length IVLEN for the cipher handle HD. */ +gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t hd, + const void *iv, size_t ivlen); + +/* Provide additional authentication data for AEAD modes/ciphers. */ +gcry_error_t gcry_cipher_authenticate (gcry_cipher_hd_t hd, const void *abuf, + size_t abuflen); + +/* Get authentication tag for AEAD modes/ciphers. */ +gcry_error_t gcry_cipher_gettag (gcry_cipher_hd_t hd, void *outtag, + size_t taglen); + +/* Check authentication tag for AEAD modes/ciphers. */ +gcry_error_t gcry_cipher_checktag (gcry_cipher_hd_t hd, const void *intag, + size_t taglen); + +/* Reset the handle to the state after open. */ +#define gcry_cipher_reset(h) gcry_cipher_ctl ((h), GCRYCTL_RESET, NULL, 0) + +/* Perform the OpenPGP sync operation if this is enabled for the + cipher handle H. */ +#define gcry_cipher_sync(h) gcry_cipher_ctl( (h), GCRYCTL_CFB_SYNC, NULL, 0) + +/* Enable or disable CTS in future calls to gcry_encrypt(). CBC mode only. */ +#define gcry_cipher_cts(h,on) gcry_cipher_ctl( (h), GCRYCTL_SET_CBC_CTS, \ + NULL, on ) + +#define gcry_cipher_set_sbox(h,oid) gcry_cipher_ctl( (h), GCRYCTL_SET_SBOX, \ + (void *) oid, 0); + +/* Indicate to the encrypt and decrypt functions that the next call + provides the final data. Only used with some modes. */ +#define gcry_cipher_final(a) \ + gcry_cipher_ctl ((a), GCRYCTL_FINALIZE, NULL, 0) + +/* Set counter for CTR mode. (CTR,CTRLEN) must denote a buffer of + block size length, or (NULL,0) to set the CTR to the all-zero block. */ +gpg_error_t gcry_cipher_setctr (gcry_cipher_hd_t hd, + const void *ctr, size_t ctrlen); + +/* Retrieve the key length in bytes used with algorithm A. */ +size_t gcry_cipher_get_algo_keylen (int algo); + +/* Retrieve the block length in bytes used with algorithm A. */ +size_t gcry_cipher_get_algo_blklen (int algo); + +/* Return 0 if the algorithm A is available for use. */ +#define gcry_cipher_test_algo(a) \ + gcry_cipher_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL ) + + +/************************************ + * * + * Asymmetric Cipher Functions * + * * + ************************************/ + +/* The algorithms and their IDs we support. */ +enum gcry_pk_algos + { + GCRY_PK_RSA = 1, /* RSA */ + GCRY_PK_RSA_E = 2, /* (deprecated: use 1). */ + GCRY_PK_RSA_S = 3, /* (deprecated: use 1). */ + GCRY_PK_ELG_E = 16, /* (deprecated: use 20). */ + GCRY_PK_DSA = 17, /* Digital Signature Algorithm. */ + GCRY_PK_ECC = 18, /* Generic ECC. */ + GCRY_PK_ELG = 20, /* Elgamal */ + GCRY_PK_ECDSA = 301, /* (only for external use). */ + GCRY_PK_ECDH = 302, /* (only for external use). */ + GCRY_PK_EDDSA = 303 /* (only for external use). */ + }; + +/* Flags describing usage capabilities of a PK algorithm. */ +#define GCRY_PK_USAGE_SIGN 1 /* Good for signatures. */ +#define GCRY_PK_USAGE_ENCR 2 /* Good for encryption. */ +#define GCRY_PK_USAGE_CERT 4 /* Good to certify other keys. */ +#define GCRY_PK_USAGE_AUTH 8 /* Good for authentication. */ +#define GCRY_PK_USAGE_UNKN 128 /* Unknown usage flag. */ + +/* Modes used with gcry_pubkey_get_sexp. */ +#define GCRY_PK_GET_PUBKEY 1 +#define GCRY_PK_GET_SECKEY 2 + +/* Encrypt the DATA using the public key PKEY and store the result as + a newly created S-expression at RESULT. */ +gcry_error_t gcry_pk_encrypt (gcry_sexp_t *result, + gcry_sexp_t data, gcry_sexp_t pkey); + +/* Decrypt the DATA using the private key SKEY and store the result as + a newly created S-expression at RESULT. */ +gcry_error_t gcry_pk_decrypt (gcry_sexp_t *result, + gcry_sexp_t data, gcry_sexp_t skey); + +/* Sign the DATA using the private key SKEY and store the result as + a newly created S-expression at RESULT. */ +gcry_error_t gcry_pk_sign (gcry_sexp_t *result, + gcry_sexp_t data, gcry_sexp_t skey); + +/* Check the signature SIGVAL on DATA using the public key PKEY. */ +gcry_error_t gcry_pk_verify (gcry_sexp_t sigval, + gcry_sexp_t data, gcry_sexp_t pkey); + +/* Check that private KEY is sane. */ +gcry_error_t gcry_pk_testkey (gcry_sexp_t key); + +/* Generate a new key pair according to the parameters given in + S_PARMS. The new key pair is returned in as an S-expression in + R_KEY. */ +gcry_error_t gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms); + +/* Catch all function for miscellaneous operations. */ +gcry_error_t gcry_pk_ctl (int cmd, void *buffer, size_t buflen); + +/* Retrieve information about the public key algorithm ALGO. */ +gcry_error_t gcry_pk_algo_info (int algo, int what, + void *buffer, size_t *nbytes); + +/* Map the public key algorithm whose ID is contained in ALGORITHM to + a string representation of the algorithm name. For unknown + algorithm IDs this functions returns "?". */ +const char *gcry_pk_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE; + +/* Map the algorithm NAME to a public key algorithm Id. Return 0 if + the algorithm name is not known. */ +int gcry_pk_map_name (const char* name) _GCRY_GCC_ATTR_PURE; + +/* Return what is commonly referred as the key length for the given + public or private KEY. */ +unsigned int gcry_pk_get_nbits (gcry_sexp_t key) _GCRY_GCC_ATTR_PURE; + +/* Return the so called KEYGRIP which is the SHA-1 hash of the public + key parameters expressed in a way depending on the algorithm. */ +unsigned char *gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array); + +/* Return the name of the curve matching KEY. */ +const char *gcry_pk_get_curve (gcry_sexp_t key, int iterator, + unsigned int *r_nbits); + +/* Return an S-expression with the parameters of the named ECC curve + NAME. ALGO must be set to an ECC algorithm. */ +gcry_sexp_t gcry_pk_get_param (int algo, const char *name); + +/* Return 0 if the public key algorithm A is available for use. */ +#define gcry_pk_test_algo(a) \ + gcry_pk_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL ) + +/* Return an S-expression representing the context CTX. */ +gcry_error_t gcry_pubkey_get_sexp (gcry_sexp_t *r_sexp, + int mode, gcry_ctx_t ctx); + + + +/************************************ + * * + * Cryptograhic Hash Functions * + * * + ************************************/ + +/* Algorithm IDs for the hash functions we know about. Not all of them + are implemented. */ +enum gcry_md_algos + { + GCRY_MD_NONE = 0, + GCRY_MD_MD5 = 1, + GCRY_MD_SHA1 = 2, + GCRY_MD_RMD160 = 3, + GCRY_MD_MD2 = 5, + GCRY_MD_TIGER = 6, /* TIGER/192 as used by gpg <= 1.3.2. */ + GCRY_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */ + GCRY_MD_SHA256 = 8, + GCRY_MD_SHA384 = 9, + GCRY_MD_SHA512 = 10, + GCRY_MD_SHA224 = 11, + + GCRY_MD_MD4 = 301, + GCRY_MD_CRC32 = 302, + GCRY_MD_CRC32_RFC1510 = 303, + GCRY_MD_CRC24_RFC2440 = 304, + GCRY_MD_WHIRLPOOL = 305, + GCRY_MD_TIGER1 = 306, /* TIGER fixed. */ + GCRY_MD_TIGER2 = 307, /* TIGER2 variant. */ + GCRY_MD_GOSTR3411_94 = 308, /* GOST R 34.11-94. */ + GCRY_MD_STRIBOG256 = 309, /* GOST R 34.11-2012, 256 bit. */ + GCRY_MD_STRIBOG512 = 310, /* GOST R 34.11-2012, 512 bit. */ + GCRY_MD_GOSTR3411_CP = 311, /* GOST R 34.11-94 with CryptoPro-A S-Box. */ + GCRY_MD_SHA3_224 = 312, + GCRY_MD_SHA3_256 = 313, + GCRY_MD_SHA3_384 = 314, + GCRY_MD_SHA3_512 = 315, + GCRY_MD_SHAKE128 = 316, + GCRY_MD_SHAKE256 = 317, + GCRY_MD_BLAKE2B_512 = 318, + GCRY_MD_BLAKE2B_384 = 319, + GCRY_MD_BLAKE2B_256 = 320, + GCRY_MD_BLAKE2B_160 = 321, + GCRY_MD_BLAKE2S_256 = 322, + GCRY_MD_BLAKE2S_224 = 323, + GCRY_MD_BLAKE2S_160 = 324, + GCRY_MD_BLAKE2S_128 = 325 + }; + +/* Flags used with the open function. */ +enum gcry_md_flags + { + GCRY_MD_FLAG_SECURE = 1, /* Allocate all buffers in "secure" memory. */ + GCRY_MD_FLAG_HMAC = 2, /* Make an HMAC out of this algorithm. */ + GCRY_MD_FLAG_BUGEMU1 = 0x0100 + }; + +/* (Forward declaration.) */ +struct gcry_md_context; + +/* This object is used to hold a handle to a message digest object. + This structure is private - only to be used by the public gcry_md_* + macros. */ +typedef struct gcry_md_handle +{ + /* Actual context. */ + struct gcry_md_context *ctx; + + /* Buffer management. */ + int bufpos; + int bufsize; + unsigned char buf[1]; +} *gcry_md_hd_t; + +/* Compatibility types, do not use them. */ +#ifndef GCRYPT_NO_DEPRECATED +typedef struct gcry_md_handle *GCRY_MD_HD _GCRY_GCC_ATTR_DEPRECATED; +typedef struct gcry_md_handle *GcryMDHd _GCRY_GCC_ATTR_DEPRECATED; +#endif + +/* Create a message digest object for algorithm ALGO. FLAGS may be + given as an bitwise OR of the gcry_md_flags values. ALGO may be + given as 0 if the algorithms to be used are later set using + gcry_md_enable. */ +gcry_error_t gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags); + +/* Release the message digest object HD. */ +void gcry_md_close (gcry_md_hd_t hd); + +/* Add the message digest algorithm ALGO to the digest object HD. */ +gcry_error_t gcry_md_enable (gcry_md_hd_t hd, int algo); + +/* Create a new digest object as an exact copy of the object HD. */ +gcry_error_t gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd); + +/* Reset the digest object HD to its initial state. */ +void gcry_md_reset (gcry_md_hd_t hd); + +/* Perform various operations on the digest object HD. */ +gcry_error_t gcry_md_ctl (gcry_md_hd_t hd, int cmd, + void *buffer, size_t buflen); + +/* Pass LENGTH bytes of data in BUFFER to the digest object HD so that + it can update the digest values. This is the actual hash + function. */ +void gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length); + +/* Read out the final digest from HD return the digest value for + algorithm ALGO. */ +unsigned char *gcry_md_read (gcry_md_hd_t hd, int algo); + +/* Read more output from algorithm ALGO to BUFFER of size LENGTH from + * digest object HD. Algorithm needs to be 'expendable-output function'. */ +gpg_error_t gcry_md_extract (gcry_md_hd_t hd, int algo, void *buffer, + size_t length); + +/* Convenience function to calculate the hash from the data in BUFFER + of size LENGTH using the algorithm ALGO avoiding the creation of a + hash object. The hash is returned in the caller provided buffer + DIGEST which must be large enough to hold the digest of the given + algorithm. */ +void gcry_md_hash_buffer (int algo, void *digest, + const void *buffer, size_t length); + +/* Convenience function to hash multiple buffers. */ +gpg_error_t gcry_md_hash_buffers (int algo, unsigned int flags, void *digest, + const gcry_buffer_t *iov, int iovcnt); + +/* Retrieve the algorithm used with HD. This does not work reliable + if more than one algorithm is enabled in HD. */ +int gcry_md_get_algo (gcry_md_hd_t hd); + +/* Retrieve the length in bytes of the digest yielded by algorithm + ALGO. */ +unsigned int gcry_md_get_algo_dlen (int algo); + +/* Return true if the the algorithm ALGO is enabled in the digest + object A. */ +int gcry_md_is_enabled (gcry_md_hd_t a, int algo); + +/* Return true if the digest object A is allocated in "secure" memory. */ +int gcry_md_is_secure (gcry_md_hd_t a); + +/* Deprecated: Use gcry_md_is_enabled or gcry_md_is_secure. */ +gcry_error_t gcry_md_info (gcry_md_hd_t h, int what, void *buffer, + size_t *nbytes) _GCRY_ATTR_INTERNAL; + +/* Retrieve various information about the algorithm ALGO. */ +gcry_error_t gcry_md_algo_info (int algo, int what, void *buffer, + size_t *nbytes); + +/* Map the digest algorithm id ALGO to a string representation of the + algorithm name. For unknown algorithms this function returns + "?". */ +const char *gcry_md_algo_name (int algo) _GCRY_GCC_ATTR_PURE; + +/* Map the algorithm NAME to a digest algorithm Id. Return 0 if + the algorithm name is not known. */ +int gcry_md_map_name (const char* name) _GCRY_GCC_ATTR_PURE; + +/* For use with the HMAC feature, the set MAC key to the KEY of + KEYLEN bytes. */ +gcry_error_t gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen); + +/* Start or stop debugging for digest handle HD; i.e. create a file + named dbgmd-. while hashing. If SUFFIX is NULL, + debugging stops and the file will be closed. */ +void gcry_md_debug (gcry_md_hd_t hd, const char *suffix); + + +/* Update the hash(s) of H with the character C. This is a buffered + version of the gcry_md_write function. */ +#define gcry_md_putc(h,c) \ + do { \ + gcry_md_hd_t h__ = (h); \ + if( (h__)->bufpos == (h__)->bufsize ) \ + gcry_md_write( (h__), NULL, 0 ); \ + (h__)->buf[(h__)->bufpos++] = (c) & 0xff; \ + } while(0) + +/* Finalize the digest calculation. This is not really needed because + gcry_md_read() does this implicitly. */ +#define gcry_md_final(a) \ + gcry_md_ctl ((a), GCRYCTL_FINALIZE, NULL, 0) + +/* Return 0 if the algorithm A is available for use. */ +#define gcry_md_test_algo(a) \ + gcry_md_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL ) + +/* Return an DER encoded ASN.1 OID for the algorithm A in buffer B. N + must point to size_t variable with the available size of buffer B. + After return it will receive the actual size of the returned + OID. */ +#define gcry_md_get_asnoid(a,b,n) \ + gcry_md_algo_info((a), GCRYCTL_GET_ASNOID, (b), (n)) + + + +/********************************************** + * * + * Message Authentication Code Functions * + * * + **********************************************/ + +/* The data object used to hold a handle to an encryption object. */ +struct gcry_mac_handle; +typedef struct gcry_mac_handle *gcry_mac_hd_t; + +/* Algorithm IDs for the hash functions we know about. Not all of them + are implemented. */ +enum gcry_mac_algos + { + GCRY_MAC_NONE = 0, + + GCRY_MAC_HMAC_SHA256 = 101, + GCRY_MAC_HMAC_SHA224 = 102, + GCRY_MAC_HMAC_SHA512 = 103, + GCRY_MAC_HMAC_SHA384 = 104, + GCRY_MAC_HMAC_SHA1 = 105, + GCRY_MAC_HMAC_MD5 = 106, + GCRY_MAC_HMAC_MD4 = 107, + GCRY_MAC_HMAC_RMD160 = 108, + GCRY_MAC_HMAC_TIGER1 = 109, /* The fixed TIGER variant */ + GCRY_MAC_HMAC_WHIRLPOOL = 110, + GCRY_MAC_HMAC_GOSTR3411_94 = 111, + GCRY_MAC_HMAC_STRIBOG256 = 112, + GCRY_MAC_HMAC_STRIBOG512 = 113, + GCRY_MAC_HMAC_MD2 = 114, + GCRY_MAC_HMAC_SHA3_224 = 115, + GCRY_MAC_HMAC_SHA3_256 = 116, + GCRY_MAC_HMAC_SHA3_384 = 117, + GCRY_MAC_HMAC_SHA3_512 = 118, + + GCRY_MAC_CMAC_AES = 201, + GCRY_MAC_CMAC_3DES = 202, + GCRY_MAC_CMAC_CAMELLIA = 203, + GCRY_MAC_CMAC_CAST5 = 204, + GCRY_MAC_CMAC_BLOWFISH = 205, + GCRY_MAC_CMAC_TWOFISH = 206, + GCRY_MAC_CMAC_SERPENT = 207, + GCRY_MAC_CMAC_SEED = 208, + GCRY_MAC_CMAC_RFC2268 = 209, + GCRY_MAC_CMAC_IDEA = 210, + GCRY_MAC_CMAC_GOST28147 = 211, + + GCRY_MAC_GMAC_AES = 401, + GCRY_MAC_GMAC_CAMELLIA = 402, + GCRY_MAC_GMAC_TWOFISH = 403, + GCRY_MAC_GMAC_SERPENT = 404, + GCRY_MAC_GMAC_SEED = 405, + + GCRY_MAC_POLY1305 = 501, + GCRY_MAC_POLY1305_AES = 502, + GCRY_MAC_POLY1305_CAMELLIA = 503, + GCRY_MAC_POLY1305_TWOFISH = 504, + GCRY_MAC_POLY1305_SERPENT = 505, + GCRY_MAC_POLY1305_SEED = 506 + }; + +/* Flags used with the open function. */ +enum gcry_mac_flags + { + GCRY_MAC_FLAG_SECURE = 1 /* Allocate all buffers in "secure" memory. */ + }; + +/* Create a MAC handle for algorithm ALGO. FLAGS may be given as an bitwise OR + of the gcry_mac_flags values. CTX maybe NULL or gcry_ctx_t object to be + associated with HANDLE. */ +gcry_error_t gcry_mac_open (gcry_mac_hd_t *handle, int algo, + unsigned int flags, gcry_ctx_t ctx); + +/* Close the MAC handle H and release all resource. */ +void gcry_mac_close (gcry_mac_hd_t h); + +/* Perform various operations on the MAC object H. */ +gcry_error_t gcry_mac_ctl (gcry_mac_hd_t h, int cmd, void *buffer, + size_t buflen); + +/* Retrieve various information about the MAC algorithm ALGO. */ +gcry_error_t gcry_mac_algo_info (int algo, int what, void *buffer, + size_t *nbytes); + +/* Set KEY of length KEYLEN bytes for the MAC handle HD. */ +gcry_error_t gcry_mac_setkey (gcry_mac_hd_t hd, const void *key, + size_t keylen); + +/* Set initialization vector IV of length IVLEN for the MAC handle HD. */ +gcry_error_t gcry_mac_setiv (gcry_mac_hd_t hd, const void *iv, + size_t ivlen); + +/* Pass LENGTH bytes of data in BUFFER to the MAC object HD so that + it can update the MAC values. */ +gcry_error_t gcry_mac_write (gcry_mac_hd_t hd, const void *buffer, + size_t length); + +/* Read out the final authentication code from the MAC object HD to BUFFER. */ +gcry_error_t gcry_mac_read (gcry_mac_hd_t hd, void *buffer, size_t *buflen); + +/* Verify the final authentication code from the MAC object HD with BUFFER. */ +gcry_error_t gcry_mac_verify (gcry_mac_hd_t hd, const void *buffer, + size_t buflen); + +/* Retrieve the algorithm used with MAC. */ +int gcry_mac_get_algo (gcry_mac_hd_t hd); + +/* Retrieve the length in bytes of the MAC yielded by algorithm ALGO. */ +unsigned int gcry_mac_get_algo_maclen (int algo); + +/* Retrieve the default key length in bytes used with algorithm A. */ +unsigned int gcry_mac_get_algo_keylen (int algo); + +/* Map the MAC algorithm whose ID is contained in ALGORITHM to a + string representation of the algorithm name. For unknown algorithm + IDs this function returns "?". */ +const char *gcry_mac_algo_name (int algorithm) _GCRY_GCC_ATTR_PURE; + +/* Map the algorithm name NAME to an MAC algorithm ID. Return 0 if + the algorithm name is not known. */ +int gcry_mac_map_name (const char *name) _GCRY_GCC_ATTR_PURE; + +/* Reset the handle to the state after open/setkey. */ +#define gcry_mac_reset(h) gcry_mac_ctl ((h), GCRYCTL_RESET, NULL, 0) + +/* Return 0 if the algorithm A is available for use. */ +#define gcry_mac_test_algo(a) \ + gcry_mac_algo_info( (a), GCRYCTL_TEST_ALGO, NULL, NULL ) + + +/****************************** + * * + * Key Derivation Functions * + * * + ******************************/ + +/* Algorithm IDs for the KDFs. */ +enum gcry_kdf_algos + { + GCRY_KDF_NONE = 0, + GCRY_KDF_SIMPLE_S2K = 16, + GCRY_KDF_SALTED_S2K = 17, + GCRY_KDF_ITERSALTED_S2K = 19, + GCRY_KDF_PBKDF1 = 33, + GCRY_KDF_PBKDF2 = 34, + GCRY_KDF_SCRYPT = 48 + }; + +/* Derive a key from a passphrase. */ +gpg_error_t gcry_kdf_derive (const void *passphrase, size_t passphraselen, + int algo, int subalgo, + const void *salt, size_t saltlen, + unsigned long iterations, + size_t keysize, void *keybuffer); + + + + +/************************************ + * * + * Random Generating Functions * + * * + ************************************/ + +/* The type of the random number generator. */ +enum gcry_rng_types + { + GCRY_RNG_TYPE_STANDARD = 1, /* The default CSPRNG generator. */ + GCRY_RNG_TYPE_FIPS = 2, /* The FIPS X9.31 AES generator. */ + GCRY_RNG_TYPE_SYSTEM = 3 /* The system's native generator. */ + }; + +/* The possible values for the random quality. The rule of thumb is + to use STRONG for session keys and VERY_STRONG for key material. + WEAK is usually an alias for STRONG and should not be used anymore + (except with gcry_mpi_randomize); use gcry_create_nonce instead. */ +typedef enum gcry_random_level + { + GCRY_WEAK_RANDOM = 0, + GCRY_STRONG_RANDOM = 1, + GCRY_VERY_STRONG_RANDOM = 2 + } +gcry_random_level_t; + +/* Fill BUFFER with LENGTH bytes of random, using random numbers of + quality LEVEL. */ +void gcry_randomize (void *buffer, size_t length, + enum gcry_random_level level); + +/* Add the external random from BUFFER with LENGTH bytes into the + pool. QUALITY should either be -1 for unknown or in the range of 0 + to 100 */ +gcry_error_t gcry_random_add_bytes (const void *buffer, size_t length, + int quality); + +/* If random numbers are used in an application, this macro should be + called from time to time so that new stuff gets added to the + internal pool of the RNG. */ +#define gcry_fast_random_poll() gcry_control (GCRYCTL_FAST_POLL, NULL) + + +/* Return NBYTES of allocated random using a random numbers of quality + LEVEL. */ +void *gcry_random_bytes (size_t nbytes, enum gcry_random_level level) + _GCRY_GCC_ATTR_MALLOC; + +/* Return NBYTES of allocated random using a random numbers of quality + LEVEL. The random numbers are created returned in "secure" + memory. */ +void *gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level) + _GCRY_GCC_ATTR_MALLOC; + + +/* Set the big integer W to a random value of NBITS using a random + generator with quality LEVEL. Note that by using a level of + GCRY_WEAK_RANDOM gcry_create_nonce is used internally. */ +void gcry_mpi_randomize (gcry_mpi_t w, + unsigned int nbits, enum gcry_random_level level); + + +/* Create an unpredicable nonce of LENGTH bytes in BUFFER. */ +void gcry_create_nonce (void *buffer, size_t length); + + + + + +/*******************************/ +/* */ +/* Prime Number Functions */ +/* */ +/*******************************/ + +/* Mode values passed to a gcry_prime_check_func_t. */ +#define GCRY_PRIME_CHECK_AT_FINISH 0 +#define GCRY_PRIME_CHECK_AT_GOT_PRIME 1 +#define GCRY_PRIME_CHECK_AT_MAYBE_PRIME 2 + +/* The function should return 1 if the operation shall continue, 0 to + reject the prime candidate. */ +typedef int (*gcry_prime_check_func_t) (void *arg, int mode, + gcry_mpi_t candidate); + +/* Flags for gcry_prime_generate(): */ + +/* Allocate prime numbers and factors in secure memory. */ +#define GCRY_PRIME_FLAG_SECRET (1 << 0) + +/* Make sure that at least one prime factor is of size + `FACTOR_BITS'. */ +#define GCRY_PRIME_FLAG_SPECIAL_FACTOR (1 << 1) + +/* Generate a new prime number of PRIME_BITS bits and store it in + PRIME. If FACTOR_BITS is non-zero, one of the prime factors of + (prime - 1) / 2 must be FACTOR_BITS bits long. If FACTORS is + non-zero, allocate a new, NULL-terminated array holding the prime + factors and store it in FACTORS. FLAGS might be used to influence + the prime number generation process. */ +gcry_error_t gcry_prime_generate (gcry_mpi_t *prime, + unsigned int prime_bits, + unsigned int factor_bits, + gcry_mpi_t **factors, + gcry_prime_check_func_t cb_func, + void *cb_arg, + gcry_random_level_t random_level, + unsigned int flags); + +/* Find a generator for PRIME where the factorization of (prime-1) is + in the NULL terminated array FACTORS. Return the generator as a + newly allocated MPI in R_G. If START_G is not NULL, use this as + the start for the search. */ +gcry_error_t gcry_prime_group_generator (gcry_mpi_t *r_g, + gcry_mpi_t prime, + gcry_mpi_t *factors, + gcry_mpi_t start_g); + + +/* Convenience function to release the FACTORS array. */ +void gcry_prime_release_factors (gcry_mpi_t *factors); + + +/* Check whether the number X is prime. */ +gcry_error_t gcry_prime_check (gcry_mpi_t x, unsigned int flags); + + + +/************************************ + * * + * Miscellaneous Stuff * + * * + ************************************/ + +/* Release the context object CTX. */ +void gcry_ctx_release (gcry_ctx_t ctx); + +/* Log data using Libgcrypt's own log interface. */ +void gcry_log_debug (const char *fmt, ...) _GCRY_GCC_ATTR_PRINTF(1,2); +void gcry_log_debughex (const char *text, const void *buffer, size_t length); +void gcry_log_debugmpi (const char *text, gcry_mpi_t mpi); +void gcry_log_debugpnt (const char *text, + gcry_mpi_point_t point, gcry_ctx_t ctx); +void gcry_log_debugsxp (const char *text, gcry_sexp_t sexp); + +char *gcry_get_config (int mode, const char *what); + +/* Log levels used by the internal logging facility. */ +enum gcry_log_levels + { + GCRY_LOG_CONT = 0, /* (Continue the last log line.) */ + GCRY_LOG_INFO = 10, + GCRY_LOG_WARN = 20, + GCRY_LOG_ERROR = 30, + GCRY_LOG_FATAL = 40, + GCRY_LOG_BUG = 50, + GCRY_LOG_DEBUG = 100 + }; + +/* Type for progress handlers. */ +typedef void (*gcry_handler_progress_t) (void *, const char *, int, int, int); + +/* Type for memory allocation handlers. */ +typedef void *(*gcry_handler_alloc_t) (size_t n); + +/* Type for secure memory check handlers. */ +typedef int (*gcry_handler_secure_check_t) (const void *); + +/* Type for memory reallocation handlers. */ +typedef void *(*gcry_handler_realloc_t) (void *p, size_t n); + +/* Type for memory free handlers. */ +typedef void (*gcry_handler_free_t) (void *); + +/* Type for out-of-memory handlers. */ +typedef int (*gcry_handler_no_mem_t) (void *, size_t, unsigned int); + +/* Type for fatal error handlers. */ +typedef void (*gcry_handler_error_t) (void *, int, const char *); + +/* Type for logging handlers. */ +typedef void (*gcry_handler_log_t) (void *, int, const char *, va_list); + +/* Certain operations can provide progress information. This function + is used to register a handler for retrieving these information. */ +void gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data); + + +/* Register a custom memory allocation functions. */ +void gcry_set_allocation_handler ( + gcry_handler_alloc_t func_alloc, + gcry_handler_alloc_t func_alloc_secure, + gcry_handler_secure_check_t func_secure_check, + gcry_handler_realloc_t func_realloc, + gcry_handler_free_t func_free); + +/* Register a function used instead of the internal out of memory + handler. */ +void gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque); + +/* Register a function used instead of the internal fatal error + handler. */ +void gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque); + +/* Register a function used instead of the internal logging + facility. */ +void gcry_set_log_handler (gcry_handler_log_t f, void *opaque); + +/* Reserved for future use. */ +void gcry_set_gettext_handler (const char *(*f)(const char*)); + +/* Libgcrypt uses its own memory allocation. It is important to use + gcry_free () to release memory allocated by libgcrypt. */ +void *gcry_malloc (size_t n) _GCRY_GCC_ATTR_MALLOC; +void *gcry_calloc (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC; +void *gcry_malloc_secure (size_t n) _GCRY_GCC_ATTR_MALLOC; +void *gcry_calloc_secure (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC; +void *gcry_realloc (void *a, size_t n); +char *gcry_strdup (const char *string) _GCRY_GCC_ATTR_MALLOC; +void *gcry_xmalloc (size_t n) _GCRY_GCC_ATTR_MALLOC; +void *gcry_xcalloc (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC; +void *gcry_xmalloc_secure (size_t n) _GCRY_GCC_ATTR_MALLOC; +void *gcry_xcalloc_secure (size_t n, size_t m) _GCRY_GCC_ATTR_MALLOC; +void *gcry_xrealloc (void *a, size_t n); +char *gcry_xstrdup (const char * a) _GCRY_GCC_ATTR_MALLOC; +void gcry_free (void *a); + +/* Return true if A is allocated in "secure" memory. */ +int gcry_is_secure (const void *a) _GCRY_GCC_ATTR_PURE; + +/* Return true if Libgcrypt is in FIPS mode. */ +#define gcry_fips_mode_active() !!gcry_control (GCRYCTL_FIPS_MODE_P, 0) + + +#if 0 /* (Keep Emacsens' auto-indent happy.) */ +{ +#endif +#ifdef __cplusplus +} +#endif +#endif /* _GCRYPT_H */ +/* +Local Variables: +buffer-read-only: t +End: +*/ diff --git a/gpg/include/gpg-error.h b/gpg/include/gpg-error.h new file mode 100644 index 0000000..7765576 --- /dev/null +++ b/gpg/include/gpg-error.h @@ -0,0 +1,1942 @@ +/* gpg-error.h or gpgrt.h - Common code for GnuPG and others. -*- c -*- + * Copyright (C) 2001-2018 g10 Code GmbH + * + * This file is part of libgpg-error (aka libgpgrt). + * + * libgpg-error 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. + * + * libgpg-error 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, see . + * SPDX-License-Identifier: LGPL-2.1+ + * + * Do not edit. Generated from gpg-error.h.in for: + i686-w64-mingw32 + */ + +/* The GnuPG project consists of many components. Error codes are + * exchanged between all components. The common error codes and their + * user-presentable descriptions are kept into a shared library to + * allow adding new error codes and components without recompiling any + * of the other components. In addition to error codes this library + * also features several other groups of functions which are common to + * all GnuPG components. They may be used by independet project as + * well. The interfaces will not change in a backward incompatible way. + * + * An error code together with an error source build up an error + * value. As the error value is been passed from one component to + * another, it preserves the information about the source and nature + * of the error. + * + * A component of the GnuPG project can define the following macros to + * tune the behaviour of the library: + * + * GPG_ERR_SOURCE_DEFAULT: Define to an error source of type + * gpg_err_source_t to make that source the default for gpg_error(). + * Otherwise GPG_ERR_SOURCE_UNKNOWN is used as default. + * + * GPG_ERR_ENABLE_GETTEXT_MACROS: Define to provide macros to map the + * internal gettext API to standard names. This has only an effect on + * Windows platforms. + * + * GPGRT_ENABLE_ES_MACROS: Define to provide "es_" macros for the + * estream functions. + * + * GPGRT_ENABLE_LOG_MACROS: Define to provide short versions of the + * log functions. + * + * GPGRT_ENABLE_ARGPARSE_MACROS: Needs to be defined to provide the + * mandatory macros of the argparse interface. + */ + +#ifndef GPG_ERROR_H +#define GPG_ERROR_H 1 +#ifndef GPGRT_H +#define GPGRT_H 1 + +#include +#include +#include + +/* The version string of this header. */ +#define GPG_ERROR_VERSION "1.32" +#define GPGRT_VERSION "1.32" + +/* The version number of this header. */ +#define GPG_ERROR_VERSION_NUMBER 0x012000 +#define GPGRT_VERSION_NUMBER 0x012000 + + +#ifdef __GNUC__ +# define GPG_ERR_INLINE __inline__ +#elif defined(_MSC_VER) && _MSC_VER >= 1300 +# define GPG_ERR_INLINE __inline +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define GPG_ERR_INLINE inline +#else +# ifndef GPG_ERR_INLINE +# define GPG_ERR_INLINE +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#if 0 /* just to make Emacs auto-indent happy */ +} +#endif +#endif /* __cplusplus */ + + + +/* The error source type gpg_err_source_t. + * + * Where as the Poo out of a welle small + * Taketh his firste springing and his sours. + * --Chaucer. + */ + +/* Only use free slots, never change or reorder the existing + * entries. */ +typedef enum + { + GPG_ERR_SOURCE_UNKNOWN = 0, + GPG_ERR_SOURCE_GCRYPT = 1, + GPG_ERR_SOURCE_GPG = 2, + GPG_ERR_SOURCE_GPGSM = 3, + GPG_ERR_SOURCE_GPGAGENT = 4, + GPG_ERR_SOURCE_PINENTRY = 5, + GPG_ERR_SOURCE_SCD = 6, + GPG_ERR_SOURCE_GPGME = 7, + GPG_ERR_SOURCE_KEYBOX = 8, + GPG_ERR_SOURCE_KSBA = 9, + GPG_ERR_SOURCE_DIRMNGR = 10, + GPG_ERR_SOURCE_GSTI = 11, + GPG_ERR_SOURCE_GPA = 12, + GPG_ERR_SOURCE_KLEO = 13, + GPG_ERR_SOURCE_G13 = 14, + GPG_ERR_SOURCE_ASSUAN = 15, + GPG_ERR_SOURCE_TLS = 17, + GPG_ERR_SOURCE_ANY = 31, + GPG_ERR_SOURCE_USER_1 = 32, + GPG_ERR_SOURCE_USER_2 = 33, + GPG_ERR_SOURCE_USER_3 = 34, + GPG_ERR_SOURCE_USER_4 = 35, + + /* This is one more than the largest allowed entry. */ + GPG_ERR_SOURCE_DIM = 128 + } gpg_err_source_t; + + +/* The error code type gpg_err_code_t. */ + +/* Only use free slots, never change or reorder the existing + * entries. */ +typedef enum + { + GPG_ERR_NO_ERROR = 0, + GPG_ERR_GENERAL = 1, + GPG_ERR_UNKNOWN_PACKET = 2, + GPG_ERR_UNKNOWN_VERSION = 3, + GPG_ERR_PUBKEY_ALGO = 4, + GPG_ERR_DIGEST_ALGO = 5, + GPG_ERR_BAD_PUBKEY = 6, + GPG_ERR_BAD_SECKEY = 7, + GPG_ERR_BAD_SIGNATURE = 8, + GPG_ERR_NO_PUBKEY = 9, + GPG_ERR_CHECKSUM = 10, + GPG_ERR_BAD_PASSPHRASE = 11, + GPG_ERR_CIPHER_ALGO = 12, + GPG_ERR_KEYRING_OPEN = 13, + GPG_ERR_INV_PACKET = 14, + GPG_ERR_INV_ARMOR = 15, + GPG_ERR_NO_USER_ID = 16, + GPG_ERR_NO_SECKEY = 17, + GPG_ERR_WRONG_SECKEY = 18, + GPG_ERR_BAD_KEY = 19, + GPG_ERR_COMPR_ALGO = 20, + GPG_ERR_NO_PRIME = 21, + GPG_ERR_NO_ENCODING_METHOD = 22, + GPG_ERR_NO_ENCRYPTION_SCHEME = 23, + GPG_ERR_NO_SIGNATURE_SCHEME = 24, + GPG_ERR_INV_ATTR = 25, + GPG_ERR_NO_VALUE = 26, + GPG_ERR_NOT_FOUND = 27, + GPG_ERR_VALUE_NOT_FOUND = 28, + GPG_ERR_SYNTAX = 29, + GPG_ERR_BAD_MPI = 30, + GPG_ERR_INV_PASSPHRASE = 31, + GPG_ERR_SIG_CLASS = 32, + GPG_ERR_RESOURCE_LIMIT = 33, + GPG_ERR_INV_KEYRING = 34, + GPG_ERR_TRUSTDB = 35, + GPG_ERR_BAD_CERT = 36, + GPG_ERR_INV_USER_ID = 37, + GPG_ERR_UNEXPECTED = 38, + GPG_ERR_TIME_CONFLICT = 39, + GPG_ERR_KEYSERVER = 40, + GPG_ERR_WRONG_PUBKEY_ALGO = 41, + GPG_ERR_TRIBUTE_TO_D_A = 42, + GPG_ERR_WEAK_KEY = 43, + GPG_ERR_INV_KEYLEN = 44, + GPG_ERR_INV_ARG = 45, + GPG_ERR_BAD_URI = 46, + GPG_ERR_INV_URI = 47, + GPG_ERR_NETWORK = 48, + GPG_ERR_UNKNOWN_HOST = 49, + GPG_ERR_SELFTEST_FAILED = 50, + GPG_ERR_NOT_ENCRYPTED = 51, + GPG_ERR_NOT_PROCESSED = 52, + GPG_ERR_UNUSABLE_PUBKEY = 53, + GPG_ERR_UNUSABLE_SECKEY = 54, + GPG_ERR_INV_VALUE = 55, + GPG_ERR_BAD_CERT_CHAIN = 56, + GPG_ERR_MISSING_CERT = 57, + GPG_ERR_NO_DATA = 58, + GPG_ERR_BUG = 59, + GPG_ERR_NOT_SUPPORTED = 60, + GPG_ERR_INV_OP = 61, + GPG_ERR_TIMEOUT = 62, + GPG_ERR_INTERNAL = 63, + GPG_ERR_EOF_GCRYPT = 64, + GPG_ERR_INV_OBJ = 65, + GPG_ERR_TOO_SHORT = 66, + GPG_ERR_TOO_LARGE = 67, + GPG_ERR_NO_OBJ = 68, + GPG_ERR_NOT_IMPLEMENTED = 69, + GPG_ERR_CONFLICT = 70, + GPG_ERR_INV_CIPHER_MODE = 71, + GPG_ERR_INV_FLAG = 72, + GPG_ERR_INV_HANDLE = 73, + GPG_ERR_TRUNCATED = 74, + GPG_ERR_INCOMPLETE_LINE = 75, + GPG_ERR_INV_RESPONSE = 76, + GPG_ERR_NO_AGENT = 77, + GPG_ERR_AGENT = 78, + GPG_ERR_INV_DATA = 79, + GPG_ERR_ASSUAN_SERVER_FAULT = 80, + GPG_ERR_ASSUAN = 81, + GPG_ERR_INV_SESSION_KEY = 82, + GPG_ERR_INV_SEXP = 83, + GPG_ERR_UNSUPPORTED_ALGORITHM = 84, + GPG_ERR_NO_PIN_ENTRY = 85, + GPG_ERR_PIN_ENTRY = 86, + GPG_ERR_BAD_PIN = 87, + GPG_ERR_INV_NAME = 88, + GPG_ERR_BAD_DATA = 89, + GPG_ERR_INV_PARAMETER = 90, + GPG_ERR_WRONG_CARD = 91, + GPG_ERR_NO_DIRMNGR = 92, + GPG_ERR_DIRMNGR = 93, + GPG_ERR_CERT_REVOKED = 94, + GPG_ERR_NO_CRL_KNOWN = 95, + GPG_ERR_CRL_TOO_OLD = 96, + GPG_ERR_LINE_TOO_LONG = 97, + GPG_ERR_NOT_TRUSTED = 98, + GPG_ERR_CANCELED = 99, + GPG_ERR_BAD_CA_CERT = 100, + GPG_ERR_CERT_EXPIRED = 101, + GPG_ERR_CERT_TOO_YOUNG = 102, + GPG_ERR_UNSUPPORTED_CERT = 103, + GPG_ERR_UNKNOWN_SEXP = 104, + GPG_ERR_UNSUPPORTED_PROTECTION = 105, + GPG_ERR_CORRUPTED_PROTECTION = 106, + GPG_ERR_AMBIGUOUS_NAME = 107, + GPG_ERR_CARD = 108, + GPG_ERR_CARD_RESET = 109, + GPG_ERR_CARD_REMOVED = 110, + GPG_ERR_INV_CARD = 111, + GPG_ERR_CARD_NOT_PRESENT = 112, + GPG_ERR_NO_PKCS15_APP = 113, + GPG_ERR_NOT_CONFIRMED = 114, + GPG_ERR_CONFIGURATION = 115, + GPG_ERR_NO_POLICY_MATCH = 116, + GPG_ERR_INV_INDEX = 117, + GPG_ERR_INV_ID = 118, + GPG_ERR_NO_SCDAEMON = 119, + GPG_ERR_SCDAEMON = 120, + GPG_ERR_UNSUPPORTED_PROTOCOL = 121, + GPG_ERR_BAD_PIN_METHOD = 122, + GPG_ERR_CARD_NOT_INITIALIZED = 123, + GPG_ERR_UNSUPPORTED_OPERATION = 124, + GPG_ERR_WRONG_KEY_USAGE = 125, + GPG_ERR_NOTHING_FOUND = 126, + GPG_ERR_WRONG_BLOB_TYPE = 127, + GPG_ERR_MISSING_VALUE = 128, + GPG_ERR_HARDWARE = 129, + GPG_ERR_PIN_BLOCKED = 130, + GPG_ERR_USE_CONDITIONS = 131, + GPG_ERR_PIN_NOT_SYNCED = 132, + GPG_ERR_INV_CRL = 133, + GPG_ERR_BAD_BER = 134, + GPG_ERR_INV_BER = 135, + GPG_ERR_ELEMENT_NOT_FOUND = 136, + GPG_ERR_IDENTIFIER_NOT_FOUND = 137, + GPG_ERR_INV_TAG = 138, + GPG_ERR_INV_LENGTH = 139, + GPG_ERR_INV_KEYINFO = 140, + GPG_ERR_UNEXPECTED_TAG = 141, + GPG_ERR_NOT_DER_ENCODED = 142, + GPG_ERR_NO_CMS_OBJ = 143, + GPG_ERR_INV_CMS_OBJ = 144, + GPG_ERR_UNKNOWN_CMS_OBJ = 145, + GPG_ERR_UNSUPPORTED_CMS_OBJ = 146, + GPG_ERR_UNSUPPORTED_ENCODING = 147, + GPG_ERR_UNSUPPORTED_CMS_VERSION = 148, + GPG_ERR_UNKNOWN_ALGORITHM = 149, + GPG_ERR_INV_ENGINE = 150, + GPG_ERR_PUBKEY_NOT_TRUSTED = 151, + GPG_ERR_DECRYPT_FAILED = 152, + GPG_ERR_KEY_EXPIRED = 153, + GPG_ERR_SIG_EXPIRED = 154, + GPG_ERR_ENCODING_PROBLEM = 155, + GPG_ERR_INV_STATE = 156, + GPG_ERR_DUP_VALUE = 157, + GPG_ERR_MISSING_ACTION = 158, + GPG_ERR_MODULE_NOT_FOUND = 159, + GPG_ERR_INV_OID_STRING = 160, + GPG_ERR_INV_TIME = 161, + GPG_ERR_INV_CRL_OBJ = 162, + GPG_ERR_UNSUPPORTED_CRL_VERSION = 163, + GPG_ERR_INV_CERT_OBJ = 164, + GPG_ERR_UNKNOWN_NAME = 165, + GPG_ERR_LOCALE_PROBLEM = 166, + GPG_ERR_NOT_LOCKED = 167, + GPG_ERR_PROTOCOL_VIOLATION = 168, + GPG_ERR_INV_MAC = 169, + GPG_ERR_INV_REQUEST = 170, + GPG_ERR_UNKNOWN_EXTN = 171, + GPG_ERR_UNKNOWN_CRIT_EXTN = 172, + GPG_ERR_LOCKED = 173, + GPG_ERR_UNKNOWN_OPTION = 174, + GPG_ERR_UNKNOWN_COMMAND = 175, + GPG_ERR_NOT_OPERATIONAL = 176, + GPG_ERR_NO_PASSPHRASE = 177, + GPG_ERR_NO_PIN = 178, + GPG_ERR_NOT_ENABLED = 179, + GPG_ERR_NO_ENGINE = 180, + GPG_ERR_MISSING_KEY = 181, + GPG_ERR_TOO_MANY = 182, + GPG_ERR_LIMIT_REACHED = 183, + GPG_ERR_NOT_INITIALIZED = 184, + GPG_ERR_MISSING_ISSUER_CERT = 185, + GPG_ERR_NO_KEYSERVER = 186, + GPG_ERR_INV_CURVE = 187, + GPG_ERR_UNKNOWN_CURVE = 188, + GPG_ERR_DUP_KEY = 189, + GPG_ERR_AMBIGUOUS = 190, + GPG_ERR_NO_CRYPT_CTX = 191, + GPG_ERR_WRONG_CRYPT_CTX = 192, + GPG_ERR_BAD_CRYPT_CTX = 193, + GPG_ERR_CRYPT_CTX_CONFLICT = 194, + GPG_ERR_BROKEN_PUBKEY = 195, + GPG_ERR_BROKEN_SECKEY = 196, + GPG_ERR_MAC_ALGO = 197, + GPG_ERR_FULLY_CANCELED = 198, + GPG_ERR_UNFINISHED = 199, + GPG_ERR_BUFFER_TOO_SHORT = 200, + GPG_ERR_SEXP_INV_LEN_SPEC = 201, + GPG_ERR_SEXP_STRING_TOO_LONG = 202, + GPG_ERR_SEXP_UNMATCHED_PAREN = 203, + GPG_ERR_SEXP_NOT_CANONICAL = 204, + GPG_ERR_SEXP_BAD_CHARACTER = 205, + GPG_ERR_SEXP_BAD_QUOTATION = 206, + GPG_ERR_SEXP_ZERO_PREFIX = 207, + GPG_ERR_SEXP_NESTED_DH = 208, + GPG_ERR_SEXP_UNMATCHED_DH = 209, + GPG_ERR_SEXP_UNEXPECTED_PUNC = 210, + GPG_ERR_SEXP_BAD_HEX_CHAR = 211, + GPG_ERR_SEXP_ODD_HEX_NUMBERS = 212, + GPG_ERR_SEXP_BAD_OCT_CHAR = 213, + GPG_ERR_SUBKEYS_EXP_OR_REV = 217, + GPG_ERR_DB_CORRUPTED = 218, + GPG_ERR_SERVER_FAILED = 219, + GPG_ERR_NO_NAME = 220, + GPG_ERR_NO_KEY = 221, + GPG_ERR_LEGACY_KEY = 222, + GPG_ERR_REQUEST_TOO_SHORT = 223, + GPG_ERR_REQUEST_TOO_LONG = 224, + GPG_ERR_OBJ_TERM_STATE = 225, + GPG_ERR_NO_CERT_CHAIN = 226, + GPG_ERR_CERT_TOO_LARGE = 227, + GPG_ERR_INV_RECORD = 228, + GPG_ERR_BAD_MAC = 229, + GPG_ERR_UNEXPECTED_MSG = 230, + GPG_ERR_COMPR_FAILED = 231, + GPG_ERR_WOULD_WRAP = 232, + GPG_ERR_FATAL_ALERT = 233, + GPG_ERR_NO_CIPHER = 234, + GPG_ERR_MISSING_CLIENT_CERT = 235, + GPG_ERR_CLOSE_NOTIFY = 236, + GPG_ERR_TICKET_EXPIRED = 237, + GPG_ERR_BAD_TICKET = 238, + GPG_ERR_UNKNOWN_IDENTITY = 239, + GPG_ERR_BAD_HS_CERT = 240, + GPG_ERR_BAD_HS_CERT_REQ = 241, + GPG_ERR_BAD_HS_CERT_VER = 242, + GPG_ERR_BAD_HS_CHANGE_CIPHER = 243, + GPG_ERR_BAD_HS_CLIENT_HELLO = 244, + GPG_ERR_BAD_HS_SERVER_HELLO = 245, + GPG_ERR_BAD_HS_SERVER_HELLO_DONE = 246, + GPG_ERR_BAD_HS_FINISHED = 247, + GPG_ERR_BAD_HS_SERVER_KEX = 248, + GPG_ERR_BAD_HS_CLIENT_KEX = 249, + GPG_ERR_BOGUS_STRING = 250, + GPG_ERR_FORBIDDEN = 251, + GPG_ERR_KEY_DISABLED = 252, + GPG_ERR_KEY_ON_CARD = 253, + GPG_ERR_INV_LOCK_OBJ = 254, + GPG_ERR_TRUE = 255, + GPG_ERR_FALSE = 256, + GPG_ERR_ASS_GENERAL = 257, + GPG_ERR_ASS_ACCEPT_FAILED = 258, + GPG_ERR_ASS_CONNECT_FAILED = 259, + GPG_ERR_ASS_INV_RESPONSE = 260, + GPG_ERR_ASS_INV_VALUE = 261, + GPG_ERR_ASS_INCOMPLETE_LINE = 262, + GPG_ERR_ASS_LINE_TOO_LONG = 263, + GPG_ERR_ASS_NESTED_COMMANDS = 264, + GPG_ERR_ASS_NO_DATA_CB = 265, + GPG_ERR_ASS_NO_INQUIRE_CB = 266, + GPG_ERR_ASS_NOT_A_SERVER = 267, + GPG_ERR_ASS_NOT_A_CLIENT = 268, + GPG_ERR_ASS_SERVER_START = 269, + GPG_ERR_ASS_READ_ERROR = 270, + GPG_ERR_ASS_WRITE_ERROR = 271, + GPG_ERR_ASS_TOO_MUCH_DATA = 273, + GPG_ERR_ASS_UNEXPECTED_CMD = 274, + GPG_ERR_ASS_UNKNOWN_CMD = 275, + GPG_ERR_ASS_SYNTAX = 276, + GPG_ERR_ASS_CANCELED = 277, + GPG_ERR_ASS_NO_INPUT = 278, + GPG_ERR_ASS_NO_OUTPUT = 279, + GPG_ERR_ASS_PARAMETER = 280, + GPG_ERR_ASS_UNKNOWN_INQUIRE = 281, + GPG_ERR_ENGINE_TOO_OLD = 300, + GPG_ERR_WINDOW_TOO_SMALL = 301, + GPG_ERR_WINDOW_TOO_LARGE = 302, + GPG_ERR_MISSING_ENVVAR = 303, + GPG_ERR_USER_ID_EXISTS = 304, + GPG_ERR_NAME_EXISTS = 305, + GPG_ERR_DUP_NAME = 306, + GPG_ERR_TOO_YOUNG = 307, + GPG_ERR_TOO_OLD = 308, + GPG_ERR_UNKNOWN_FLAG = 309, + GPG_ERR_INV_ORDER = 310, + GPG_ERR_ALREADY_FETCHED = 311, + GPG_ERR_TRY_LATER = 312, + GPG_ERR_WRONG_NAME = 313, + GPG_ERR_SYSTEM_BUG = 666, + GPG_ERR_DNS_UNKNOWN = 711, + GPG_ERR_DNS_SECTION = 712, + GPG_ERR_DNS_ADDRESS = 713, + GPG_ERR_DNS_NO_QUERY = 714, + GPG_ERR_DNS_NO_ANSWER = 715, + GPG_ERR_DNS_CLOSED = 716, + GPG_ERR_DNS_VERIFY = 717, + GPG_ERR_DNS_TIMEOUT = 718, + GPG_ERR_LDAP_GENERAL = 721, + GPG_ERR_LDAP_ATTR_GENERAL = 722, + GPG_ERR_LDAP_NAME_GENERAL = 723, + GPG_ERR_LDAP_SECURITY_GENERAL = 724, + GPG_ERR_LDAP_SERVICE_GENERAL = 725, + GPG_ERR_LDAP_UPDATE_GENERAL = 726, + GPG_ERR_LDAP_E_GENERAL = 727, + GPG_ERR_LDAP_X_GENERAL = 728, + GPG_ERR_LDAP_OTHER_GENERAL = 729, + GPG_ERR_LDAP_X_CONNECTING = 750, + GPG_ERR_LDAP_REFERRAL_LIMIT = 751, + GPG_ERR_LDAP_CLIENT_LOOP = 752, + GPG_ERR_LDAP_NO_RESULTS = 754, + GPG_ERR_LDAP_CONTROL_NOT_FOUND = 755, + GPG_ERR_LDAP_NOT_SUPPORTED = 756, + GPG_ERR_LDAP_CONNECT = 757, + GPG_ERR_LDAP_NO_MEMORY = 758, + GPG_ERR_LDAP_PARAM = 759, + GPG_ERR_LDAP_USER_CANCELLED = 760, + GPG_ERR_LDAP_FILTER = 761, + GPG_ERR_LDAP_AUTH_UNKNOWN = 762, + GPG_ERR_LDAP_TIMEOUT = 763, + GPG_ERR_LDAP_DECODING = 764, + GPG_ERR_LDAP_ENCODING = 765, + GPG_ERR_LDAP_LOCAL = 766, + GPG_ERR_LDAP_SERVER_DOWN = 767, + GPG_ERR_LDAP_SUCCESS = 768, + GPG_ERR_LDAP_OPERATIONS = 769, + GPG_ERR_LDAP_PROTOCOL = 770, + GPG_ERR_LDAP_TIMELIMIT = 771, + GPG_ERR_LDAP_SIZELIMIT = 772, + GPG_ERR_LDAP_COMPARE_FALSE = 773, + GPG_ERR_LDAP_COMPARE_TRUE = 774, + GPG_ERR_LDAP_UNSUPPORTED_AUTH = 775, + GPG_ERR_LDAP_STRONG_AUTH_RQRD = 776, + GPG_ERR_LDAP_PARTIAL_RESULTS = 777, + GPG_ERR_LDAP_REFERRAL = 778, + GPG_ERR_LDAP_ADMINLIMIT = 779, + GPG_ERR_LDAP_UNAVAIL_CRIT_EXTN = 780, + GPG_ERR_LDAP_CONFIDENT_RQRD = 781, + GPG_ERR_LDAP_SASL_BIND_INPROG = 782, + GPG_ERR_LDAP_NO_SUCH_ATTRIBUTE = 784, + GPG_ERR_LDAP_UNDEFINED_TYPE = 785, + GPG_ERR_LDAP_BAD_MATCHING = 786, + GPG_ERR_LDAP_CONST_VIOLATION = 787, + GPG_ERR_LDAP_TYPE_VALUE_EXISTS = 788, + GPG_ERR_LDAP_INV_SYNTAX = 789, + GPG_ERR_LDAP_NO_SUCH_OBJ = 800, + GPG_ERR_LDAP_ALIAS_PROBLEM = 801, + GPG_ERR_LDAP_INV_DN_SYNTAX = 802, + GPG_ERR_LDAP_IS_LEAF = 803, + GPG_ERR_LDAP_ALIAS_DEREF = 804, + GPG_ERR_LDAP_X_PROXY_AUTH_FAIL = 815, + GPG_ERR_LDAP_BAD_AUTH = 816, + GPG_ERR_LDAP_INV_CREDENTIALS = 817, + GPG_ERR_LDAP_INSUFFICIENT_ACC = 818, + GPG_ERR_LDAP_BUSY = 819, + GPG_ERR_LDAP_UNAVAILABLE = 820, + GPG_ERR_LDAP_UNWILL_TO_PERFORM = 821, + GPG_ERR_LDAP_LOOP_DETECT = 822, + GPG_ERR_LDAP_NAMING_VIOLATION = 832, + GPG_ERR_LDAP_OBJ_CLS_VIOLATION = 833, + GPG_ERR_LDAP_NOT_ALLOW_NONLEAF = 834, + GPG_ERR_LDAP_NOT_ALLOW_ON_RDN = 835, + GPG_ERR_LDAP_ALREADY_EXISTS = 836, + GPG_ERR_LDAP_NO_OBJ_CLASS_MODS = 837, + GPG_ERR_LDAP_RESULTS_TOO_LARGE = 838, + GPG_ERR_LDAP_AFFECTS_MULT_DSAS = 839, + GPG_ERR_LDAP_VLV = 844, + GPG_ERR_LDAP_OTHER = 848, + GPG_ERR_LDAP_CUP_RESOURCE_LIMIT = 881, + GPG_ERR_LDAP_CUP_SEC_VIOLATION = 882, + GPG_ERR_LDAP_CUP_INV_DATA = 883, + GPG_ERR_LDAP_CUP_UNSUP_SCHEME = 884, + GPG_ERR_LDAP_CUP_RELOAD = 885, + GPG_ERR_LDAP_CANCELLED = 886, + GPG_ERR_LDAP_NO_SUCH_OPERATION = 887, + GPG_ERR_LDAP_TOO_LATE = 888, + GPG_ERR_LDAP_CANNOT_CANCEL = 889, + GPG_ERR_LDAP_ASSERTION_FAILED = 890, + GPG_ERR_LDAP_PROX_AUTH_DENIED = 891, + GPG_ERR_USER_1 = 1024, + GPG_ERR_USER_2 = 1025, + GPG_ERR_USER_3 = 1026, + GPG_ERR_USER_4 = 1027, + GPG_ERR_USER_5 = 1028, + GPG_ERR_USER_6 = 1029, + GPG_ERR_USER_7 = 1030, + GPG_ERR_USER_8 = 1031, + GPG_ERR_USER_9 = 1032, + GPG_ERR_USER_10 = 1033, + GPG_ERR_USER_11 = 1034, + GPG_ERR_USER_12 = 1035, + GPG_ERR_USER_13 = 1036, + GPG_ERR_USER_14 = 1037, + GPG_ERR_USER_15 = 1038, + GPG_ERR_USER_16 = 1039, + GPG_ERR_MISSING_ERRNO = 16381, + GPG_ERR_UNKNOWN_ERRNO = 16382, + GPG_ERR_EOF = 16383, + + /* The following error codes are used to map system errors. */ +#define GPG_ERR_SYSTEM_ERROR (1 << 15) + GPG_ERR_E2BIG = GPG_ERR_SYSTEM_ERROR | 0, + GPG_ERR_EACCES = GPG_ERR_SYSTEM_ERROR | 1, + GPG_ERR_EADDRINUSE = GPG_ERR_SYSTEM_ERROR | 2, + GPG_ERR_EADDRNOTAVAIL = GPG_ERR_SYSTEM_ERROR | 3, + GPG_ERR_EADV = GPG_ERR_SYSTEM_ERROR | 4, + GPG_ERR_EAFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 5, + GPG_ERR_EAGAIN = GPG_ERR_SYSTEM_ERROR | 6, + GPG_ERR_EALREADY = GPG_ERR_SYSTEM_ERROR | 7, + GPG_ERR_EAUTH = GPG_ERR_SYSTEM_ERROR | 8, + GPG_ERR_EBACKGROUND = GPG_ERR_SYSTEM_ERROR | 9, + GPG_ERR_EBADE = GPG_ERR_SYSTEM_ERROR | 10, + GPG_ERR_EBADF = GPG_ERR_SYSTEM_ERROR | 11, + GPG_ERR_EBADFD = GPG_ERR_SYSTEM_ERROR | 12, + GPG_ERR_EBADMSG = GPG_ERR_SYSTEM_ERROR | 13, + GPG_ERR_EBADR = GPG_ERR_SYSTEM_ERROR | 14, + GPG_ERR_EBADRPC = GPG_ERR_SYSTEM_ERROR | 15, + GPG_ERR_EBADRQC = GPG_ERR_SYSTEM_ERROR | 16, + GPG_ERR_EBADSLT = GPG_ERR_SYSTEM_ERROR | 17, + GPG_ERR_EBFONT = GPG_ERR_SYSTEM_ERROR | 18, + GPG_ERR_EBUSY = GPG_ERR_SYSTEM_ERROR | 19, + GPG_ERR_ECANCELED = GPG_ERR_SYSTEM_ERROR | 20, + GPG_ERR_ECHILD = GPG_ERR_SYSTEM_ERROR | 21, + GPG_ERR_ECHRNG = GPG_ERR_SYSTEM_ERROR | 22, + GPG_ERR_ECOMM = GPG_ERR_SYSTEM_ERROR | 23, + GPG_ERR_ECONNABORTED = GPG_ERR_SYSTEM_ERROR | 24, + GPG_ERR_ECONNREFUSED = GPG_ERR_SYSTEM_ERROR | 25, + GPG_ERR_ECONNRESET = GPG_ERR_SYSTEM_ERROR | 26, + GPG_ERR_ED = GPG_ERR_SYSTEM_ERROR | 27, + GPG_ERR_EDEADLK = GPG_ERR_SYSTEM_ERROR | 28, + GPG_ERR_EDEADLOCK = GPG_ERR_SYSTEM_ERROR | 29, + GPG_ERR_EDESTADDRREQ = GPG_ERR_SYSTEM_ERROR | 30, + GPG_ERR_EDIED = GPG_ERR_SYSTEM_ERROR | 31, + GPG_ERR_EDOM = GPG_ERR_SYSTEM_ERROR | 32, + GPG_ERR_EDOTDOT = GPG_ERR_SYSTEM_ERROR | 33, + GPG_ERR_EDQUOT = GPG_ERR_SYSTEM_ERROR | 34, + GPG_ERR_EEXIST = GPG_ERR_SYSTEM_ERROR | 35, + GPG_ERR_EFAULT = GPG_ERR_SYSTEM_ERROR | 36, + GPG_ERR_EFBIG = GPG_ERR_SYSTEM_ERROR | 37, + GPG_ERR_EFTYPE = GPG_ERR_SYSTEM_ERROR | 38, + GPG_ERR_EGRATUITOUS = GPG_ERR_SYSTEM_ERROR | 39, + GPG_ERR_EGREGIOUS = GPG_ERR_SYSTEM_ERROR | 40, + GPG_ERR_EHOSTDOWN = GPG_ERR_SYSTEM_ERROR | 41, + GPG_ERR_EHOSTUNREACH = GPG_ERR_SYSTEM_ERROR | 42, + GPG_ERR_EIDRM = GPG_ERR_SYSTEM_ERROR | 43, + GPG_ERR_EIEIO = GPG_ERR_SYSTEM_ERROR | 44, + GPG_ERR_EILSEQ = GPG_ERR_SYSTEM_ERROR | 45, + GPG_ERR_EINPROGRESS = GPG_ERR_SYSTEM_ERROR | 46, + GPG_ERR_EINTR = GPG_ERR_SYSTEM_ERROR | 47, + GPG_ERR_EINVAL = GPG_ERR_SYSTEM_ERROR | 48, + GPG_ERR_EIO = GPG_ERR_SYSTEM_ERROR | 49, + GPG_ERR_EISCONN = GPG_ERR_SYSTEM_ERROR | 50, + GPG_ERR_EISDIR = GPG_ERR_SYSTEM_ERROR | 51, + GPG_ERR_EISNAM = GPG_ERR_SYSTEM_ERROR | 52, + GPG_ERR_EL2HLT = GPG_ERR_SYSTEM_ERROR | 53, + GPG_ERR_EL2NSYNC = GPG_ERR_SYSTEM_ERROR | 54, + GPG_ERR_EL3HLT = GPG_ERR_SYSTEM_ERROR | 55, + GPG_ERR_EL3RST = GPG_ERR_SYSTEM_ERROR | 56, + GPG_ERR_ELIBACC = GPG_ERR_SYSTEM_ERROR | 57, + GPG_ERR_ELIBBAD = GPG_ERR_SYSTEM_ERROR | 58, + GPG_ERR_ELIBEXEC = GPG_ERR_SYSTEM_ERROR | 59, + GPG_ERR_ELIBMAX = GPG_ERR_SYSTEM_ERROR | 60, + GPG_ERR_ELIBSCN = GPG_ERR_SYSTEM_ERROR | 61, + GPG_ERR_ELNRNG = GPG_ERR_SYSTEM_ERROR | 62, + GPG_ERR_ELOOP = GPG_ERR_SYSTEM_ERROR | 63, + GPG_ERR_EMEDIUMTYPE = GPG_ERR_SYSTEM_ERROR | 64, + GPG_ERR_EMFILE = GPG_ERR_SYSTEM_ERROR | 65, + GPG_ERR_EMLINK = GPG_ERR_SYSTEM_ERROR | 66, + GPG_ERR_EMSGSIZE = GPG_ERR_SYSTEM_ERROR | 67, + GPG_ERR_EMULTIHOP = GPG_ERR_SYSTEM_ERROR | 68, + GPG_ERR_ENAMETOOLONG = GPG_ERR_SYSTEM_ERROR | 69, + GPG_ERR_ENAVAIL = GPG_ERR_SYSTEM_ERROR | 70, + GPG_ERR_ENEEDAUTH = GPG_ERR_SYSTEM_ERROR | 71, + GPG_ERR_ENETDOWN = GPG_ERR_SYSTEM_ERROR | 72, + GPG_ERR_ENETRESET = GPG_ERR_SYSTEM_ERROR | 73, + GPG_ERR_ENETUNREACH = GPG_ERR_SYSTEM_ERROR | 74, + GPG_ERR_ENFILE = GPG_ERR_SYSTEM_ERROR | 75, + GPG_ERR_ENOANO = GPG_ERR_SYSTEM_ERROR | 76, + GPG_ERR_ENOBUFS = GPG_ERR_SYSTEM_ERROR | 77, + GPG_ERR_ENOCSI = GPG_ERR_SYSTEM_ERROR | 78, + GPG_ERR_ENODATA = GPG_ERR_SYSTEM_ERROR | 79, + GPG_ERR_ENODEV = GPG_ERR_SYSTEM_ERROR | 80, + GPG_ERR_ENOENT = GPG_ERR_SYSTEM_ERROR | 81, + GPG_ERR_ENOEXEC = GPG_ERR_SYSTEM_ERROR | 82, + GPG_ERR_ENOLCK = GPG_ERR_SYSTEM_ERROR | 83, + GPG_ERR_ENOLINK = GPG_ERR_SYSTEM_ERROR | 84, + GPG_ERR_ENOMEDIUM = GPG_ERR_SYSTEM_ERROR | 85, + GPG_ERR_ENOMEM = GPG_ERR_SYSTEM_ERROR | 86, + GPG_ERR_ENOMSG = GPG_ERR_SYSTEM_ERROR | 87, + GPG_ERR_ENONET = GPG_ERR_SYSTEM_ERROR | 88, + GPG_ERR_ENOPKG = GPG_ERR_SYSTEM_ERROR | 89, + GPG_ERR_ENOPROTOOPT = GPG_ERR_SYSTEM_ERROR | 90, + GPG_ERR_ENOSPC = GPG_ERR_SYSTEM_ERROR | 91, + GPG_ERR_ENOSR = GPG_ERR_SYSTEM_ERROR | 92, + GPG_ERR_ENOSTR = GPG_ERR_SYSTEM_ERROR | 93, + GPG_ERR_ENOSYS = GPG_ERR_SYSTEM_ERROR | 94, + GPG_ERR_ENOTBLK = GPG_ERR_SYSTEM_ERROR | 95, + GPG_ERR_ENOTCONN = GPG_ERR_SYSTEM_ERROR | 96, + GPG_ERR_ENOTDIR = GPG_ERR_SYSTEM_ERROR | 97, + GPG_ERR_ENOTEMPTY = GPG_ERR_SYSTEM_ERROR | 98, + GPG_ERR_ENOTNAM = GPG_ERR_SYSTEM_ERROR | 99, + GPG_ERR_ENOTSOCK = GPG_ERR_SYSTEM_ERROR | 100, + GPG_ERR_ENOTSUP = GPG_ERR_SYSTEM_ERROR | 101, + GPG_ERR_ENOTTY = GPG_ERR_SYSTEM_ERROR | 102, + GPG_ERR_ENOTUNIQ = GPG_ERR_SYSTEM_ERROR | 103, + GPG_ERR_ENXIO = GPG_ERR_SYSTEM_ERROR | 104, + GPG_ERR_EOPNOTSUPP = GPG_ERR_SYSTEM_ERROR | 105, + GPG_ERR_EOVERFLOW = GPG_ERR_SYSTEM_ERROR | 106, + GPG_ERR_EPERM = GPG_ERR_SYSTEM_ERROR | 107, + GPG_ERR_EPFNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 108, + GPG_ERR_EPIPE = GPG_ERR_SYSTEM_ERROR | 109, + GPG_ERR_EPROCLIM = GPG_ERR_SYSTEM_ERROR | 110, + GPG_ERR_EPROCUNAVAIL = GPG_ERR_SYSTEM_ERROR | 111, + GPG_ERR_EPROGMISMATCH = GPG_ERR_SYSTEM_ERROR | 112, + GPG_ERR_EPROGUNAVAIL = GPG_ERR_SYSTEM_ERROR | 113, + GPG_ERR_EPROTO = GPG_ERR_SYSTEM_ERROR | 114, + GPG_ERR_EPROTONOSUPPORT = GPG_ERR_SYSTEM_ERROR | 115, + GPG_ERR_EPROTOTYPE = GPG_ERR_SYSTEM_ERROR | 116, + GPG_ERR_ERANGE = GPG_ERR_SYSTEM_ERROR | 117, + GPG_ERR_EREMCHG = GPG_ERR_SYSTEM_ERROR | 118, + GPG_ERR_EREMOTE = GPG_ERR_SYSTEM_ERROR | 119, + GPG_ERR_EREMOTEIO = GPG_ERR_SYSTEM_ERROR | 120, + GPG_ERR_ERESTART = GPG_ERR_SYSTEM_ERROR | 121, + GPG_ERR_EROFS = GPG_ERR_SYSTEM_ERROR | 122, + GPG_ERR_ERPCMISMATCH = GPG_ERR_SYSTEM_ERROR | 123, + GPG_ERR_ESHUTDOWN = GPG_ERR_SYSTEM_ERROR | 124, + GPG_ERR_ESOCKTNOSUPPORT = GPG_ERR_SYSTEM_ERROR | 125, + GPG_ERR_ESPIPE = GPG_ERR_SYSTEM_ERROR | 126, + GPG_ERR_ESRCH = GPG_ERR_SYSTEM_ERROR | 127, + GPG_ERR_ESRMNT = GPG_ERR_SYSTEM_ERROR | 128, + GPG_ERR_ESTALE = GPG_ERR_SYSTEM_ERROR | 129, + GPG_ERR_ESTRPIPE = GPG_ERR_SYSTEM_ERROR | 130, + GPG_ERR_ETIME = GPG_ERR_SYSTEM_ERROR | 131, + GPG_ERR_ETIMEDOUT = GPG_ERR_SYSTEM_ERROR | 132, + GPG_ERR_ETOOMANYREFS = GPG_ERR_SYSTEM_ERROR | 133, + GPG_ERR_ETXTBSY = GPG_ERR_SYSTEM_ERROR | 134, + GPG_ERR_EUCLEAN = GPG_ERR_SYSTEM_ERROR | 135, + GPG_ERR_EUNATCH = GPG_ERR_SYSTEM_ERROR | 136, + GPG_ERR_EUSERS = GPG_ERR_SYSTEM_ERROR | 137, + GPG_ERR_EWOULDBLOCK = GPG_ERR_SYSTEM_ERROR | 138, + GPG_ERR_EXDEV = GPG_ERR_SYSTEM_ERROR | 139, + GPG_ERR_EXFULL = GPG_ERR_SYSTEM_ERROR | 140, + + /* This is one more than the largest allowed entry. */ + GPG_ERR_CODE_DIM = 65536 + } gpg_err_code_t; + + +/* The error value type gpg_error_t. */ + +/* We would really like to use bit-fields in a struct, but using + * structs as return values can cause binary compatibility issues, in + * particular if you want to do it efficiently (also see + * -freg-struct-return option to GCC). */ +typedef unsigned int gpg_error_t; + +/* We use the lowest 16 bits of gpg_error_t for error codes. The 16th + * bit indicates system errors. */ +#define GPG_ERR_CODE_MASK (GPG_ERR_CODE_DIM - 1) + +/* Bits 17 to 24 are reserved. */ + +/* We use the upper 7 bits of gpg_error_t for error sources. */ +#define GPG_ERR_SOURCE_MASK (GPG_ERR_SOURCE_DIM - 1) +#define GPG_ERR_SOURCE_SHIFT 24 + +/* The highest bit is reserved. It shouldn't be used to prevent + * potential negative numbers when transmitting error values as + * text. */ + + +/* + * GCC feature test. + */ +#if __GNUC__ +# define _GPG_ERR_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#else +# define _GPG_ERR_GCC_VERSION 0 +#endif + +#undef _GPG_ERR_HAVE_CONSTRUCTOR +#if _GPG_ERR_GCC_VERSION > 30100 +# define _GPG_ERR_CONSTRUCTOR __attribute__ ((__constructor__)) +# define _GPG_ERR_HAVE_CONSTRUCTOR +#else +# define _GPG_ERR_CONSTRUCTOR +#endif + +#define GPGRT_GCC_VERSION _GPG_ERR_GCC_VERSION + +#if _GPG_ERR_GCC_VERSION >= 29200 +# define _GPGRT__RESTRICT __restrict__ +#else +# define _GPGRT__RESTRICT +#endif + +/* The noreturn attribute. */ +#if _GPG_ERR_GCC_VERSION >= 20500 +# define GPGRT_ATTR_NORETURN __attribute__ ((__noreturn__)) +#else +# define GPGRT_ATTR_NORETURN +#endif + +/* The printf attributes. */ +#if _GPG_ERR_GCC_VERSION >= 40400 +# define GPGRT_ATTR_PRINTF(f, a) \ + __attribute__ ((format(__gnu_printf__,f,a))) +# define GPGRT_ATTR_NR_PRINTF(f, a) \ + __attribute__ ((__noreturn__, format(__gnu_printf__,f,a))) +#elif _GPG_ERR_GCC_VERSION >= 20500 +# define GPGRT_ATTR_PRINTF(f, a) \ + __attribute__ ((format(printf,f,a))) +# define GPGRT_ATTR_NR_PRINTF(f, a) \ + __attribute__ ((__noreturn__, format(printf,f,a))) +#else +# define GPGRT_ATTR_PRINTF(f, a) +# define GPGRT_ATTR_NR_PRINTF(f, a) +#endif +#if _GPG_ERR_GCC_VERSION >= 20800 +# define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a))) +#else +# define GPGRT_ATTR_FORMAT_ARG(a) +#endif + +/* The sentinel attribute. */ +#if _GPG_ERR_GCC_VERSION >= 40000 +# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a))) +#else +# define GPGRT_ATTR_SENTINEL(a) +#endif + +/* The used and unused attributes. + * I am not sure since when the unused attribute is really supported. + * In any case it it only needed for gcc versions which print a + * warning. Thus let us require gcc >= 3.5. */ +#if _GPG_ERR_GCC_VERSION >= 40000 +# define GPGRT_ATTR_USED __attribute__ ((used)) +#else +# define GPGRT_ATTR_USED +#endif +#if _GPG_ERR_GCC_VERSION >= 30500 +# define GPGRT_ATTR_UNUSED __attribute__ ((unused)) +#else +# define GPGRT_ATTR_UNUSED +#endif + +/* The deprecated attribute. */ +#if _GPG_ERR_GCC_VERSION >= 30100 +# define GPGRT_ATTR_DEPRECATED __attribute__ ((__deprecated__)) +#else +# define GPGRT_ATTR_DEPRECATED +#endif + +/* The pure attribute. */ +#if _GPG_ERR_GCC_VERSION >= 29600 +# define GPGRT_ATTR_PURE __attribute__ ((__pure__)) +#else +# define GPGRT_ATTR_PURE +#endif + +/* The malloc attribute. */ +#if _GPG_ERR_GCC_VERSION >= 30200 +# define GPGRT_ATTR_MALLOC __attribute__ ((__malloc__)) +#else +# define GPGRT_ATTR_MALLOC +#endif + +/* A macro defined if a GCC style __FUNCTION__ macro is available. */ +#undef GPGRT_HAVE_MACRO_FUNCTION +#if _GPG_ERR_GCC_VERSION >= 20500 +# define GPGRT_HAVE_MACRO_FUNCTION 1 +#endif + +/* A macro defined if the pragma GCC push_options is available. */ +#undef GPGRT_HAVE_PRAGMA_GCC_PUSH +#if _GPG_ERR_GCC_VERSION >= 40400 +# define GPGRT_HAVE_PRAGMA_GCC_PUSH 1 +#endif + +/* Detect LeakSanitizer (LSan) support for GCC and Clang based on + * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address). + * Note that -fsanitize=leak just affect the linker options which + * cannot be detected here. In that case you have to define the + * GPGRT_HAVE_LEAK_SANITIZER macro manually. */ +#ifdef __GNUC__ +# ifdef __SANITIZE_ADDRESS__ +# define GPGRT_HAVE_LEAK_SANITIZER +# elif defined(__has_feature) +# if __has_feature(address_sanitizer) +# define GPGRT_HAVE_LEAK_SANITIZER +# endif +# endif +#endif + + +/* The new name for the inline macro. */ +#define GPGRT_INLINE GPG_ERR_INLINE + +#ifdef GPGRT_HAVE_LEAK_SANITIZER +# include +#endif + +/* Mark heap objects as non-leaked memory. */ +static GPGRT_INLINE void +gpgrt_annotate_leaked_object (const void *p) +{ +#ifdef GPGRT_HAVE_LEAK_SANITIZER + __lsan_ignore_object(p); +#else + (void)p; +#endif +} + + +/* + * Initialization function. + */ + +/* Initialize the library. This function should be run early. */ +gpg_error_t gpg_err_init (void) _GPG_ERR_CONSTRUCTOR; + +/* If this is defined, the library is already initialized by the + constructor and does not need to be initialized explicitely. */ +#undef GPG_ERR_INITIALIZED +#ifdef _GPG_ERR_HAVE_CONSTRUCTOR +# define GPG_ERR_INITIALIZED 1 +# define gpgrt_init() do { gpg_err_init (); } while (0) +#else +# define gpgrt_init() do { ; } while (0) +#endif + +/* See the source on how to use the deinit function; it is usually not + required. */ +void gpg_err_deinit (int mode); + +/* Register blocking system I/O clamping functions. */ +void gpgrt_set_syscall_clamp (void (*pre)(void), void (*post)(void)); + +/* Get current I/O clamping functions. */ +void gpgrt_get_syscall_clamp (void (**r_pre)(void), void (**r_post)(void)); + +/* Register a custom malloc/realloc/free function. */ +void gpgrt_set_alloc_func (void *(*f)(void *a, size_t n)); + + + +/* + * Constructor and accessor functions. + */ + +/* Construct an error value from an error code and source. Within a + * subsystem, use gpg_error. */ +static GPG_ERR_INLINE gpg_error_t +gpg_err_make (gpg_err_source_t source, gpg_err_code_t code) +{ + return code == GPG_ERR_NO_ERROR ? GPG_ERR_NO_ERROR + : (((source & GPG_ERR_SOURCE_MASK) << GPG_ERR_SOURCE_SHIFT) + | (code & GPG_ERR_CODE_MASK)); +} + + +/* The user should define GPG_ERR_SOURCE_DEFAULT before including this + * file to specify a default source for gpg_error. */ +#ifndef GPG_ERR_SOURCE_DEFAULT +#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_UNKNOWN +#endif + +static GPG_ERR_INLINE gpg_error_t +gpg_error (gpg_err_code_t code) +{ + return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, code); +} + + +/* Retrieve the error code from an error value. */ +static GPG_ERR_INLINE gpg_err_code_t +gpg_err_code (gpg_error_t err) +{ + return (gpg_err_code_t) (err & GPG_ERR_CODE_MASK); +} + + +/* Retrieve the error source from an error value. */ +static GPG_ERR_INLINE gpg_err_source_t +gpg_err_source (gpg_error_t err) +{ + return (gpg_err_source_t) ((err >> GPG_ERR_SOURCE_SHIFT) + & GPG_ERR_SOURCE_MASK); +} + + +/* String functions. */ + +/* Return a pointer to a string containing a description of the error + * code in the error value ERR. This function is not thread-safe. */ +const char *gpg_strerror (gpg_error_t err); + +/* Return the error string for ERR in the user-supplied buffer BUF of + * size BUFLEN. This function is, in contrast to gpg_strerror, + * thread-safe if a thread-safe strerror_r() function is provided by + * the system. If the function succeeds, 0 is returned and BUF + * contains the string describing the error. If the buffer was not + * large enough, ERANGE is returned and BUF contains as much of the + * beginning of the error string as fits into the buffer. */ +int gpg_strerror_r (gpg_error_t err, char *buf, size_t buflen); + +/* Return a pointer to a string containing a description of the error + * source in the error value ERR. */ +const char *gpg_strsource (gpg_error_t err); + + +/* + * Mapping of system errors (errno). + */ + +/* Retrieve the error code for the system error ERR. This returns + * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report + * this). */ +gpg_err_code_t gpg_err_code_from_errno (int err); + +/* Retrieve the system error for the error code CODE. This returns 0 + * if CODE is not a system error code. */ +int gpg_err_code_to_errno (gpg_err_code_t code); + +/* Retrieve the error code directly from the ERRNO variable. This + * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped + * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */ +gpg_err_code_t gpg_err_code_from_syserror (void); + + +/* Set the ERRNO variable. This function is the preferred way to set + * ERRNO due to peculiarities on WindowsCE. */ +void gpg_err_set_errno (int err); + +/* Return or check the version. Both functions are identical. */ +const char *gpgrt_check_version (const char *req_version); +const char *gpg_error_check_version (const char *req_version); + +/* System specific type definitions. */ +#include + +typedef long gpgrt_ssize_t; + +#include + +typedef int64_t gpgrt_off_t; + + + +/* Decide whether to use the format_arg attribute. */ +#if _GPG_ERR_GCC_VERSION > 20800 +# define _GPG_ERR_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a))) +#else +# define _GPG_ERR_ATTR_FORMAT_ARG(a) +#endif + +/* A lean gettext implementation based on GNU style mo files which are + required to be encoded in UTF-8. There is a limit on 65534 entries + to save some RAM. Only Germanic plural rules are supported. */ +const char *_gpg_w32_bindtextdomain (const char *domainname, + const char *dirname); +const char *_gpg_w32_textdomain (const char *domainname); +const char *_gpg_w32_gettext (const char *msgid) + _GPG_ERR_ATTR_FORMAT_ARG (1); +const char *_gpg_w32_dgettext (const char *domainname, const char *msgid) + _GPG_ERR_ATTR_FORMAT_ARG (2); +const char *_gpg_w32_dngettext (const char *domainname, const char *msgid1, + const char *msgid2, unsigned long int n) + _GPG_ERR_ATTR_FORMAT_ARG (2) _GPG_ERR_ATTR_FORMAT_ARG (3); +const char *_gpg_w32_gettext_localename (void); +int _gpg_w32_gettext_use_utf8 (int value); + +#ifdef GPG_ERR_ENABLE_GETTEXT_MACROS +# define bindtextdomain(a,b) _gpg_w32_bindtextdomain ((a), (b)) +# define textdomain(a) _gpg_w32_textdomain ((a)) +# define gettext(a) _gpg_w32_gettext ((a)) +# define dgettext(a,b) _gpg_w32_dgettext ((a), (b)) +# define ngettext(a,b,c) _gpg_w32_dngettext (NULL, (a), (b), (c)) +# define dngettext(a,b,c,d) _gpg_w32_dngettext ((a), (b), (c), (d)) +# define gettext_localename() _gpg_w32_gettext_localename () +# define gettext_use_utf8(a) _gpg_w32_gettext_use_utf8 (a) +#endif /*GPG_ERR_ENABLE_GETTEXT_MACROS*/ + + +/* A simple iconv implementation w/o the need for an extra DLL. */ +struct _gpgrt_w32_iconv_s; +typedef struct _gpgrt_w32_iconv_s *gpgrt_w32_iconv_t; + +gpgrt_w32_iconv_t gpgrt_w32_iconv_open (const char *tocode, + const char *fromcode); +int gpgrt_w32_iconv_close (gpgrt_w32_iconv_t cd); +size_t gpgrt_w32_iconv (gpgrt_w32_iconv_t cd, + const char **inbuf, size_t *inbytesleft, + char **outbuf, size_t *outbytesleft); + +#ifdef GPGRT_ENABLE_W32_ICONV_MACROS +# define ICONV_CONST const +# define iconv_t gpgrt_w32_iconv_t +# define iconv_open(a,b) gpgrt_w32_iconv_open ((a), (b)) +# define iconv_close(a) gpgrt_w32_iconv_close ((a)) +# define iconv(a,b,c,d,e) gpgrt_w32_iconv ((a),(b),(c),(d),(e)) +#endif /*GPGRT_ENABLE_W32_ICONV_MACROS*/ + +/* Query a string in the registry. */ +char *gpgrt_w32_reg_query_string (const char *root, + const char *dir, + const char *name); + + +/* Self-documenting convenience functions. */ + +static GPG_ERR_INLINE gpg_error_t +gpg_err_make_from_errno (gpg_err_source_t source, int err) +{ + return gpg_err_make (source, gpg_err_code_from_errno (err)); +} + + +static GPG_ERR_INLINE gpg_error_t +gpg_error_from_errno (int err) +{ + return gpg_error (gpg_err_code_from_errno (err)); +} + +static GPG_ERR_INLINE gpg_error_t +gpg_error_from_syserror (void) +{ + return gpg_error (gpg_err_code_from_syserror ()); +} + + + +/* + * Malloc and friends + */ + +void *gpgrt_realloc (void *a, size_t n); +void *gpgrt_malloc (size_t n); +void *gpgrt_calloc (size_t n, size_t m); +char *gpgrt_strdup (const char *string); +char *gpgrt_strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0); +void gpgrt_free (void *a); + + +/* + * System specific function wrappers. + */ + +/* A getenv replacement which mallocs the returned string. */ +char *gpgrt_getenv (const char *name); + +/* A setenv and a unsetenv replacement.*/ +gpg_err_code_t gpgrt_setenv (const char *name, + const char *value, int overwrite); +#define gpgrt_unsetenv(n) gpgrt_setenv ((n), NULL, 1) + +/* A wrapper around mkdir using a string for the mode. */ +gpg_err_code_t gpgrt_mkdir (const char *name, const char *modestr); + +/* A simple wrapper around chdir. */ +gpg_err_code_t gpgrt_chdir (const char *name); + +/* Return the current WD as a malloced string. */ +char *gpgrt_getcwd (void); + + + + +/* + * Lock functions. + */ + + +#ifdef _WIN64 + +#pragma pack(push, 8) +typedef struct +{ + volatile unsigned char priv[56]; +} gpgrt_lock_t; +#pragma pack(pop) + +#define GPGRT_LOCK_INITIALIZER {{1,0,0,0,0,0,0,0,255,255,255,255, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0,0,0,0,0}} + +#else + +#pragma pack(push, 8) +typedef struct +{ + volatile unsigned char priv[36]; +} gpgrt_lock_t; +#pragma pack(pop) + +#define GPGRT_LOCK_INITIALIZER {{1,0,0,0,0,0,0,0,255,255,255,255, \ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, \ + 0,0,0,0,0,0,0,0}} +#endif + + +#define GPGRT_LOCK_DEFINE(name) \ + static gpgrt_lock_t name = GPGRT_LOCK_INITIALIZER + +/* NB: If GPGRT_LOCK_DEFINE is not used, zero out the lock variable + before passing it to gpgrt_lock_init. */ +gpg_err_code_t gpgrt_lock_init (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_lock (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_trylock (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_unlock (gpgrt_lock_t *lockhd); +gpg_err_code_t gpgrt_lock_destroy (gpgrt_lock_t *lockhd); + + + +/* + * Thread functions. + */ + +gpg_err_code_t gpgrt_yield (void); + + + + +/* + * Estream + */ + +/* The definition of this struct is entirely private. You must not + use it for anything. It is only here so some functions can be + implemented as macros. */ +struct _gpgrt_stream_internal; +struct _gpgrt__stream +{ + /* The layout of this struct must never change. It may be grown, + but only if all functions which access the new members are + versioned. */ + + /* Various flags. */ + struct { + unsigned int magic: 16; + unsigned int writing: 1; + unsigned int reserved: 15; + } flags; + + /* A pointer to the stream buffer. */ + unsigned char *buffer; + + /* The size of the buffer in bytes. */ + size_t buffer_size; + + /* The length of the usable data in the buffer, only valid when in + read mode (see flags). */ + size_t data_len; + + /* The current position of the offset pointer, valid in read and + write mode. */ + size_t data_offset; + + size_t data_flushed; + unsigned char *unread_buffer; + size_t unread_buffer_size; + + /* The number of unread bytes. */ + size_t unread_data_len; + + /* A pointer to our internal data for this stream. */ + struct _gpgrt_stream_internal *intern; +}; + +/* The opaque type for an estream. */ +typedef struct _gpgrt__stream *gpgrt_stream_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt__stream *estream_t; +#endif + +typedef gpgrt_ssize_t (*gpgrt_cookie_read_function_t) (void *cookie, + void *buffer, size_t size); +typedef gpgrt_ssize_t (*gpgrt_cookie_write_function_t) (void *cookie, + const void *buffer, + size_t size); +typedef int (*gpgrt_cookie_seek_function_t) (void *cookie, + gpgrt_off_t *pos, int whence); +typedef int (*gpgrt_cookie_close_function_t) (void *cookie); + +struct _gpgrt_cookie_io_functions +{ + gpgrt_cookie_read_function_t func_read; + gpgrt_cookie_write_function_t func_write; + gpgrt_cookie_seek_function_t func_seek; + gpgrt_cookie_close_function_t func_close; +}; +typedef struct _gpgrt_cookie_io_functions gpgrt_cookie_io_functions_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt_cookie_io_functions es_cookie_io_functions_t; +#define es_cookie_read_function_t gpgrt_cookie_read_function_t +#define es_cookie_write_function_t gpgrt_cookie_read_function_t +#define es_cookie_seek_function_t gpgrt_cookie_read_function_t +#define es_cookie_close_function_t gpgrt_cookie_read_function_t +#endif + +enum gpgrt_syshd_types + { + GPGRT_SYSHD_NONE = 0, /* No system handle available. */ + GPGRT_SYSHD_FD = 1, /* A file descriptor as returned by open(). */ + GPGRT_SYSHD_SOCK = 2, /* A socket as returned by socket(). */ + GPGRT_SYSHD_RVID = 3, /* A rendezvous id (see libassuan's gpgcedev.c). */ + GPGRT_SYSHD_HANDLE = 4 /* A HANDLE object (Windows). */ + }; + +struct _gpgrt_syshd +{ + enum gpgrt_syshd_types type; + union { + int fd; + int sock; + int rvid; + void *handle; + } u; +}; +typedef struct _gpgrt_syshd gpgrt_syshd_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt_syshd es_syshd_t; +#define ES_SYSHD_NONE GPGRT_SYSHD_NONE +#define ES_SYSHD_FD GPGRT_SYSHD_FD +#define ES_SYSHD_SOCK GPGRT_SYSHD_SOCK +#define ES_SYSHD_RVID GPGRT_SYSHD_RVID +#define ES_SYSHD_HANDLE GPGRT_SYSHD_HANDLE +#endif + +/* The object used with gpgrt_poll. */ +struct _gpgrt_poll_s +{ + gpgrt_stream_t stream; + unsigned int want_read:1; + unsigned int want_write:1; + unsigned int want_oob:1; + unsigned int want_rdhup:1; + unsigned int _reserv1:4; + unsigned int got_read:1; + unsigned int got_write:1; + unsigned int got_oob:1; + unsigned int got_rdhup:1; + unsigned int _reserv2:4; + unsigned int got_err:1; + unsigned int got_hup:1; + unsigned int got_nval:1; + unsigned int _reserv3:4; + unsigned int ignore:1; + unsigned int user:8; /* For application use. */ +}; +typedef struct _gpgrt_poll_s gpgrt_poll_t; +#ifdef GPGRT_ENABLE_ES_MACROS +typedef struct _gpgrt_poll_s es_poll_t; +#endif + +gpgrt_stream_t gpgrt_fopen (const char *_GPGRT__RESTRICT path, + const char *_GPGRT__RESTRICT mode); +gpgrt_stream_t gpgrt_mopen (void *_GPGRT__RESTRICT data, + size_t data_n, size_t data_len, + unsigned int grow, + void *(*func_realloc) (void *mem, size_t size), + void (*func_free) (void *mem), + const char *_GPGRT__RESTRICT mode); +gpgrt_stream_t gpgrt_fopenmem (size_t memlimit, + const char *_GPGRT__RESTRICT mode); +gpgrt_stream_t gpgrt_fopenmem_init (size_t memlimit, + const char *_GPGRT__RESTRICT mode, + const void *data, size_t datalen); +gpgrt_stream_t gpgrt_fdopen (int filedes, const char *mode); +gpgrt_stream_t gpgrt_fdopen_nc (int filedes, const char *mode); +gpgrt_stream_t gpgrt_sysopen (gpgrt_syshd_t *syshd, const char *mode); +gpgrt_stream_t gpgrt_sysopen_nc (gpgrt_syshd_t *syshd, const char *mode); +gpgrt_stream_t gpgrt_fpopen (FILE *fp, const char *mode); +gpgrt_stream_t gpgrt_fpopen_nc (FILE *fp, const char *mode); +gpgrt_stream_t gpgrt_freopen (const char *_GPGRT__RESTRICT path, + const char *_GPGRT__RESTRICT mode, + gpgrt_stream_t _GPGRT__RESTRICT stream); +gpgrt_stream_t gpgrt_fopencookie (void *_GPGRT__RESTRICT cookie, + const char *_GPGRT__RESTRICT mode, + gpgrt_cookie_io_functions_t functions); +int gpgrt_fclose (gpgrt_stream_t stream); +int gpgrt_fclose_snatch (gpgrt_stream_t stream, + void **r_buffer, size_t *r_buflen); +int gpgrt_onclose (gpgrt_stream_t stream, int mode, + void (*fnc) (gpgrt_stream_t, void*), void *fnc_value); +int gpgrt_fileno (gpgrt_stream_t stream); +int gpgrt_fileno_unlocked (gpgrt_stream_t stream); +int gpgrt_syshd (gpgrt_stream_t stream, gpgrt_syshd_t *syshd); +int gpgrt_syshd_unlocked (gpgrt_stream_t stream, gpgrt_syshd_t *syshd); + +void _gpgrt_set_std_fd (int no, int fd); +gpgrt_stream_t _gpgrt_get_std_stream (int fd); + +#define gpgrt_stdin _gpgrt_get_std_stream (0) +#define gpgrt_stdout _gpgrt_get_std_stream (1) +#define gpgrt_stderr _gpgrt_get_std_stream (2) + + +void gpgrt_flockfile (gpgrt_stream_t stream); +int gpgrt_ftrylockfile (gpgrt_stream_t stream); +void gpgrt_funlockfile (gpgrt_stream_t stream); + +int gpgrt_feof (gpgrt_stream_t stream); +int gpgrt_feof_unlocked (gpgrt_stream_t stream); +int gpgrt_ferror (gpgrt_stream_t stream); +int gpgrt_ferror_unlocked (gpgrt_stream_t stream); +void gpgrt_clearerr (gpgrt_stream_t stream); +void gpgrt_clearerr_unlocked (gpgrt_stream_t stream); + +int _gpgrt_pending (gpgrt_stream_t stream); /* (private) */ +int _gpgrt_pending_unlocked (gpgrt_stream_t stream); /* (private) */ + +#define gpgrt_pending(stream) _gpgrt_pending (stream) + +#define gpgrt_pending_unlocked(stream) \ + (((!(stream)->flags.writing) \ + && (((stream)->data_offset < (stream)->data_len) \ + || ((stream)->unread_data_len))) \ + ? 1 : _gpgrt_pending_unlocked ((stream))) + +int gpgrt_fflush (gpgrt_stream_t stream); +int gpgrt_fseek (gpgrt_stream_t stream, long int offset, int whence); +int gpgrt_fseeko (gpgrt_stream_t stream, gpgrt_off_t offset, int whence); +long int gpgrt_ftell (gpgrt_stream_t stream); +gpgrt_off_t gpgrt_ftello (gpgrt_stream_t stream); +void gpgrt_rewind (gpgrt_stream_t stream); + +int gpgrt_fgetc (gpgrt_stream_t stream); +int gpgrt_fputc (int c, gpgrt_stream_t stream); + +int _gpgrt_getc_underflow (gpgrt_stream_t stream); /* (private) */ +int _gpgrt_putc_overflow (int c, gpgrt_stream_t stream); /* (private) */ + +#define gpgrt_getc_unlocked(stream) \ + (((!(stream)->flags.writing) \ + && ((stream)->data_offset < (stream)->data_len) \ + && (! (stream)->unread_data_len)) \ + ? ((int) (stream)->buffer[((stream)->data_offset)++]) \ + : _gpgrt_getc_underflow ((stream))) + +#define gpgrt_putc_unlocked(c, stream) \ + (((stream)->flags.writing \ + && ((stream)->data_offset < (stream)->buffer_size) \ + && (c != '\n')) \ + ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \ + : _gpgrt_putc_overflow ((c), (stream))) + +#define gpgrt_getc(stream) gpgrt_fgetc (stream) +#define gpgrt_putc(c, stream) gpgrt_fputc (c, stream) + +int gpgrt_ungetc (int c, gpgrt_stream_t stream); + +int gpgrt_read (gpgrt_stream_t _GPGRT__RESTRICT stream, + void *_GPGRT__RESTRICT buffer, size_t bytes_to_read, + size_t *_GPGRT__RESTRICT bytes_read); +int gpgrt_write (gpgrt_stream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t bytes_to_write, + size_t *_GPGRT__RESTRICT bytes_written); +int gpgrt_write_sanitized (gpgrt_stream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t length, + const char *delimiters, + size_t *_GPGRT__RESTRICT bytes_written); +int gpgrt_write_hexstring (gpgrt_stream_t _GPGRT__RESTRICT stream, + const void *_GPGRT__RESTRICT buffer, size_t length, + int reserved, + size_t *_GPGRT__RESTRICT bytes_written); + +size_t gpgrt_fread (void *_GPGRT__RESTRICT ptr, size_t size, size_t nitems, + gpgrt_stream_t _GPGRT__RESTRICT stream); +size_t gpgrt_fwrite (const void *_GPGRT__RESTRICT ptr, size_t size, + size_t nitems, gpgrt_stream_t _GPGRT__RESTRICT stream); + +char *gpgrt_fgets (char *_GPGRT__RESTRICT s, int n, + gpgrt_stream_t _GPGRT__RESTRICT stream); +int gpgrt_fputs (const char *_GPGRT__RESTRICT s, + gpgrt_stream_t _GPGRT__RESTRICT stream); +int gpgrt_fputs_unlocked (const char *_GPGRT__RESTRICT s, + gpgrt_stream_t _GPGRT__RESTRICT stream); + +gpgrt_ssize_t gpgrt_getline (char *_GPGRT__RESTRICT *_GPGRT__RESTRICT lineptr, + size_t *_GPGRT__RESTRICT n, + gpgrt_stream_t stream); +gpgrt_ssize_t gpgrt_read_line (gpgrt_stream_t stream, + char **addr_of_buffer, size_t *length_of_buffer, + size_t *max_length); + +int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(2,3); +int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(2,3); + +int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(1,2); +int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(1,2); + +int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, va_list ap) + GPGRT_ATTR_PRINTF(2,0); +int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream, + const char *_GPGRT__RESTRICT format, va_list ap) + GPGRT_ATTR_PRINTF(2,0); + +int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream, + char *_GPGRT__RESTRICT buf, int mode, size_t size); +void gpgrt_setbuf (gpgrt_stream_t _GPGRT__RESTRICT stream, + char *_GPGRT__RESTRICT buf); + +void gpgrt_set_binary (gpgrt_stream_t stream); +int gpgrt_set_nonblock (gpgrt_stream_t stream, int onoff); +int gpgrt_get_nonblock (gpgrt_stream_t stream); + +int gpgrt_poll (gpgrt_poll_t *fdlist, unsigned int nfds, int timeout); + +gpgrt_stream_t gpgrt_tmpfile (void); + +void gpgrt_opaque_set (gpgrt_stream_t _GPGRT__RESTRICT stream, + void *_GPGRT__RESTRICT opaque); +void *gpgrt_opaque_get (gpgrt_stream_t stream); + +void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname); +const char *gpgrt_fname_get (gpgrt_stream_t stream); + +int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(2,3); +int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format, + va_list ap) + GPGRT_ATTR_PRINTF(2,0); +char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(1,2); +char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap) + GPGRT_ATTR_PRINTF(1,0); +int gpgrt_snprintf (char *buf, size_t bufsize, + const char * _GPGRT__RESTRICT format, ...) + GPGRT_ATTR_PRINTF(3,4); +int gpgrt_vsnprintf (char *buf,size_t bufsize, + const char * _GPGRT__RESTRICT format, va_list arg_ptr) + GPGRT_ATTR_PRINTF(3,0); + + +#ifdef GPGRT_ENABLE_ES_MACROS +# define es_fopen gpgrt_fopen +# define es_mopen gpgrt_mopen +# define es_fopenmem gpgrt_fopenmem +# define es_fopenmem_init gpgrt_fopenmem_init +# define es_fdopen gpgrt_fdopen +# define es_fdopen_nc gpgrt_fdopen_nc +# define es_sysopen gpgrt_sysopen +# define es_sysopen_nc gpgrt_sysopen_nc +# define es_fpopen gpgrt_fpopen +# define es_fpopen_nc gpgrt_fpopen_nc +# define es_freopen gpgrt_freopen +# define es_fopencookie gpgrt_fopencookie +# define es_fclose gpgrt_fclose +# define es_fclose_snatch gpgrt_fclose_snatch +# define es_onclose gpgrt_onclose +# define es_fileno gpgrt_fileno +# define es_fileno_unlocked gpgrt_fileno_unlocked +# define es_syshd gpgrt_syshd +# define es_syshd_unlocked gpgrt_syshd_unlocked +# define es_stdin _gpgrt_get_std_stream (0) +# define es_stdout _gpgrt_get_std_stream (1) +# define es_stderr _gpgrt_get_std_stream (2) +# define es_flockfile gpgrt_flockfile +# define es_ftrylockfile gpgrt_ftrylockfile +# define es_funlockfile gpgrt_funlockfile +# define es_feof gpgrt_feof +# define es_feof_unlocked gpgrt_feof_unlocked +# define es_ferror gpgrt_ferror +# define es_ferror_unlocked gpgrt_ferror_unlocked +# define es_clearerr gpgrt_clearerr +# define es_clearerr_unlocked gpgrt_clearerr_unlocked +# define es_pending gpgrt_pending +# define es_pending_unlocked gpgrt_pending_unlocked +# define es_fflush gpgrt_fflush +# define es_fseek gpgrt_fseek +# define es_fseeko gpgrt_fseeko +# define es_ftell gpgrt_ftell +# define es_ftello gpgrt_ftello +# define es_rewind gpgrt_rewind +# define es_fgetc gpgrt_fgetc +# define es_fputc gpgrt_fputc +# define es_getc_unlocked gpgrt_getc_unlocked +# define es_putc_unlocked gpgrt_putc_unlocked +# define es_getc gpgrt_getc +# define es_putc gpgrt_putc +# define es_ungetc gpgrt_ungetc +# define es_read gpgrt_read +# define es_write gpgrt_write +# define es_write_sanitized gpgrt_write_sanitized +# define es_write_hexstring gpgrt_write_hexstring +# define es_fread gpgrt_fread +# define es_fwrite gpgrt_fwrite +# define es_fgets gpgrt_fgets +# define es_fputs gpgrt_fputs +# define es_fputs_unlocked gpgrt_fputs_unlocked +# define es_getline gpgrt_getline +# define es_read_line gpgrt_read_line +# define es_free gpgrt_free +# define es_fprintf gpgrt_fprintf +# define es_fprintf_unlocked gpgrt_fprintf_unlocked +# define es_printf gpgrt_printf +# define es_printf_unlocked gpgrt_printf_unlocked +# define es_vfprintf gpgrt_vfprintf +# define es_vfprintf_unlocked gpgrt_vfprintf_unlocked +# define es_setvbuf gpgrt_setvbuf +# define es_setbuf gpgrt_setbuf +# define es_set_binary gpgrt_set_binary +# define es_set_nonblock gpgrt_set_nonblock +# define es_get_nonblock gpgrt_get_nonblock +# define es_poll gpgrt_poll +# define es_tmpfile gpgrt_tmpfile +# define es_opaque_set gpgrt_opaque_set +# define es_opaque_get gpgrt_opaque_get +# define es_fname_set gpgrt_fname_set +# define es_fname_get gpgrt_fname_get +# define es_asprintf gpgrt_asprintf +# define es_vasprintf gpgrt_vasprintf +# define es_bsprintf gpgrt_bsprintf +# define es_vbsprintf gpgrt_vbsprintf +#endif /*GPGRT_ENABLE_ES_MACROS*/ + + + +/* + * Base64 encode and decode functions. + */ + +struct _gpgrt_b64state; +typedef struct _gpgrt_b64state *gpgrt_b64state_t; + +gpgrt_b64state_t gpgrt_b64enc_start (gpgrt_stream_t stream, const char *title); +gpg_err_code_t gpgrt_b64enc_write (gpgrt_b64state_t state, + const void *buffer, size_t nbytes); +gpg_err_code_t gpgrt_b64enc_finish (gpgrt_b64state_t state); + +gpgrt_b64state_t gpgrt_b64dec_start (const char *title); +gpg_error_t gpgrt_b64dec_proc (gpgrt_b64state_t state, + void *buffer, size_t length, + size_t *r_nbytes); +gpg_error_t gpgrt_b64dec_finish (gpgrt_b64state_t state); + + + +/* + * Logging functions + */ + +/* Flag values for gpgrt_log_set_prefix. */ +#define GPGRT_LOG_WITH_PREFIX 1 +#define GPGRT_LOG_WITH_TIME 2 +#define GPGRT_LOG_WITH_PID 4 +#define GPGRT_LOG_RUN_DETACHED 256 +#define GPGRT_LOG_NO_REGISTRY 512 + +/* Log levels as used by gpgrt_log. */ +enum gpgrt_log_levels + { + GPGRT_LOGLVL_BEGIN, + GPGRT_LOGLVL_CONT, + GPGRT_LOGLVL_INFO, + GPGRT_LOGLVL_WARN, + GPGRT_LOGLVL_ERROR, + GPGRT_LOGLVL_FATAL, + GPGRT_LOGLVL_BUG, + GPGRT_LOGLVL_DEBUG + }; + + +/* The next 4 functions are not thread-safe - call them early. */ +void gpgrt_log_set_sink (const char *name, gpgrt_stream_t stream, int fd); +void gpgrt_log_set_socket_dir_cb (const char *(*fnc)(void)); +void gpgrt_log_set_pid_suffix_cb (int (*cb)(unsigned long *r_value)); +void gpgrt_log_set_prefix (const char *text, unsigned int flags); + +int gpgrt_get_errorcount (int clear); +void gpgrt_inc_errorcount (void); +const char *gpgrt_log_get_prefix (unsigned int *flags); +int gpgrt_log_test_fd (int fd); +int gpgrt_log_get_fd (void); +gpgrt_stream_t gpgrt_log_get_stream (void); + +void gpgrt_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3); +void gpgrt_logv (int level, const char *fmt, va_list arg_ptr); +void gpgrt_logv_prefix (int level, const char *prefix, + const char *fmt, va_list arg_ptr); +void gpgrt_log_string (int level, const char *string); +void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); +void gpgrt_log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); +void gpgrt_log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void gpgrt_log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void gpgrt_log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void gpgrt_log_debug_string (const char *string, + const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3); +void gpgrt_log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void gpgrt_log_printhex (const void *buffer, size_t length, + const char *fmt, ...) GPGRT_ATTR_PRINTF(3,4); +void gpgrt_log_clock (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void gpgrt_log_flush (void); +void _gpgrt_log_assert (const char *expr, const char *file, int line, + const char *func) GPGRT_ATTR_NORETURN; + +#ifdef GPGRT_HAVE_MACRO_FUNCTION +# define gpgrt_assert(expr) \ + ((expr) \ + ? (void) 0 \ + : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__)) +#else /*!GPGRT_HAVE_MACRO_FUNCTION*/ +# define gpgrt_assert(expr) \ + ((expr) \ + ? (void) 0 \ + : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL)) +#endif /*!GPGRT_HAVE_MACRO_FUNCTION*/ + +#ifdef GPGRT_ENABLE_LOG_MACROS +# define log_get_errorcount gpgrt_get_errorcount +# define log_inc_errorcount gpgrt_inc_errorcount +# define log_set_file(a) gpgrt_log_set_sink ((a), NULL, -1) +# define log_set_fd(a) gpgrt_log_set_sink (NULL, NULL, (a)) +# define log_set_stream(a) gpgrt_log_set_sink (NULL, (a), -1) +# define log_set_socket_dir_cb gpgrt_log_set_socket_dir_cb +# define log_set_pid_suffix_cb gpgrt_log_set_pid_suffix_cb +# define log_set_prefix gpgrt_log_set_prefix +# define log_get_prefix gpgrt_log_get_prefix +# define log_test_fd gpgrt_log_test_fd +# define log_get_fd gpgrt_log_get_fd +# define log_get_stream gpgrt_log_get_stream +# define log_log gpgrt_log +# define log_logv gpgrt_logv +# define log_logv_prefix gpgrt_logv_prefix +# define log_string gpgrt_log_string +# define log_bug gpgrt_log_bug +# define log_fatal gpgrt_log_fatal +# define log_error gpgrt_log_error +# define log_info gpgrt_log_info +# define log_debug gpgrt_log_debug +# define log_debug_string gpgrt_log_debug_string +# define log_printf gpgrt_log_printf +# define log_printhex gpgrt_log_printhex +# define log_clock gpgrt_log_clock +# define log_flush gpgrt_log_flush +# ifdef GPGRT_HAVE_MACRO_FUNCTION +# define log_assert(expr) \ + ((expr) \ + ? (void) 0 \ + : _gpgrt_log_assert (#expr, __FILE__, __LINE__, __FUNCTION__)) +# else /*!GPGRT_HAVE_MACRO_FUNCTION*/ +# define log_assert(expr) \ + ((expr) \ + ? (void) 0 \ + : _gpgrt_log_assert (#expr, __FILE__, __LINE__, NULL)) +# endif /*!GPGRT_HAVE_MACRO_FUNCTION*/ + +#endif /*GPGRT_ENABLE_LOG_MACROS*/ + + +/* + * Spawn functions (Not yet available) + */ +#define GPGRT_SPAWN_NONBLOCK 16 /* Set the streams to non-blocking. */ +#define GPGRT_SPAWN_RUN_ASFW 64 /* Use AllowSetForegroundWindow on W32. */ +#define GPGRT_SPAWN_DETACHED 128 /* Start the process in the background. */ + +#if 0 + +/* Function and convenience macros to create pipes. */ +gpg_err_code_t gpgrt_make_pipe (int filedes[2], gpgrt_stream_t *r_fp, + int direction, int nonblock); +#define gpgrt_create_pipe(a) gpgrt_make_pipe ((a),NULL, 0, 0); +#define gpgrt_create_inbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), -1,(c)); +#define gpgrt_create_outbound_pipe(a,b,c) gpgrt_make_pipe ((a), (b), 1,(c)); + + +/* Fork and exec PGMNAME. */ +gpg_err_code_t gpgrt_spawn_process (const char *pgmname, const char *argv[], + int *execpt, void (*preexec)(void), + unsigned int flags, + gpgrt_stream_t *r_infp, + gpgrt_stream_t *r_outfp, + gpgrt_stream_t *r_errfp, + pid_t *pid); + +/* Fork and exec PGNNAME and connect the process to the given FDs. */ +gpg_err_code_t gpgrt_spawn_process_fd (const char *pgmname, const char *argv[], + int infd, int outfd, int errfd, + pid_t *pid); + +/* Fork and exec PGMNAME as a detached process. */ +gpg_err_code_t gpgrt_spawn_process_detached (const char *pgmname, + const char *argv[], + const char *envp[] ); + +/* Wait for a single process. */ +gpg_err_code_t gpgrt_wait_process (const char *pgmname, pid_t pid, int hang, + int *r_exitcode); + +/* Wait for a multiple processes. */ +gpg_err_code_t gpgrt_wait_processes (const char **pgmnames, pid_t *pids, + size_t count, int hang, int *r_exitcodes); + +/* Kill the process identified by PID. */ +void gpgrt_kill_process (pid_t pid); + +/* Release process resources identified by PID. */ +void gpgrt_release_process (pid_t pid); + +#endif /*0*/ + + + +/* + * Option parsing. + */ + +struct _gpgrt_argparse_internal_s; +typedef struct +{ + int *argc; /* Pointer to ARGC (value subject to change). */ + char ***argv; /* Pointer to ARGV (value subject to change). */ + unsigned int flags; /* Global flags. May be set prior to calling the + parser. The parser may change the value. */ + int err; /* Print error description for last option. + Either 0, ARGPARSE_PRINT_WARNING or + ARGPARSE_PRINT_ERROR. */ + unsigned int lineno;/* The current line number. */ + int r_opt; /* Returns option code. */ + int r_type; /* Returns type of option value. */ + union { + int ret_int; + long ret_long; + unsigned long ret_ulong; + char *ret_str; + } r; /* Return values */ + + struct _gpgrt_argparse_internal_s *internal; +} gpgrt_argparse_t; + + +typedef struct +{ + int short_opt; + const char *long_opt; + unsigned int flags; + const char *description; /* Optional description. */ +} gpgrt_opt_t; + + +#ifdef GPGRT_ENABLE_ARGPARSE_MACROS + +/* Global flags for (gpgrt_argparse_t).flags. */ +#define ARGPARSE_FLAG_KEEP 1 /* Do not remove options form argv. */ +#define ARGPARSE_FLAG_ALL 2 /* Do not stop at last option but return + remaining args with R_OPT set to -1. */ +#define ARGPARSE_FLAG_MIXED 4 /* Assume options and args are mixed. */ +#define ARGPARSE_FLAG_NOSTOP 8 /* Do not stop processing at "--". */ +#define ARGPARSE_FLAG_ARG0 16 /* Do not skip the first arg. */ +#define ARGPARSE_FLAG_ONEDASH 32 /* Allow long options with one dash. */ +#define ARGPARSE_FLAG_NOVERSION 64 /* No output for "--version". */ +#define ARGPARSE_FLAG_RESET 128 /* Request to reset the internal state. */ +#define ARGPARSE_FLAG_STOP_SEEN 256 /* Set to true if a "--" has been seen. */ +#define ARGPARSE_FLAG_NOLINENO 512 /* Do not zero the lineno field. */ + +/* Constants for (gpgrt_argparse_t).err. */ +#define ARGPARSE_PRINT_WARNING 1 /* Print a diagnostic. */ +#define ARGPARSE_PRINT_ERROR 2 /* Print a diagnostic and call exit. */ + +/* Special return values of gpgrt_argparse. */ +#define ARGPARSE_IS_ARG (-1) +#define ARGPARSE_INVALID_OPTION (-2) +#define ARGPARSE_MISSING_ARG (-3) +#define ARGPARSE_KEYWORD_TOO_LONG (-4) +#define ARGPARSE_READ_ERROR (-5) +#define ARGPARSE_UNEXPECTED_ARG (-6) +#define ARGPARSE_INVALID_COMMAND (-7) +#define ARGPARSE_AMBIGUOUS_OPTION (-8) +#define ARGPARSE_AMBIGUOUS_COMMAND (-9) +#define ARGPARSE_INVALID_ALIAS (-10) +#define ARGPARSE_OUT_OF_CORE (-11) +#define ARGPARSE_INVALID_ARG (-12) + +/* Flags for the option descriptor (gpgrt_opt_t)->flags. Note that + * a TYPE constant may be or-ed with the OPT constants. */ +#define ARGPARSE_TYPE_NONE 0 /* Does not take an argument. */ +#define ARGPARSE_TYPE_INT 1 /* Takes an int argument. */ +#define ARGPARSE_TYPE_STRING 2 /* Takes a string argument. */ +#define ARGPARSE_TYPE_LONG 3 /* Takes a long argument. */ +#define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */ +#define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */ +#define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */ +#define ARGPARSE_OPT_IGNORE (1<<6) /* Ignore command or option. */ +#define ARGPARSE_OPT_COMMAND (1<<7) /* The argument is a command. */ + +/* A set of macros to make option definitions easier to read. */ +#define ARGPARSE_x(s,l,t,f,d) \ + { (s), (l), ARGPARSE_TYPE_ ## t | (f), (d) } + +#define ARGPARSE_s(s,l,t,d) \ + { (s), (l), ARGPARSE_TYPE_ ## t, (d) } +#define ARGPARSE_s_n(s,l,d) \ + { (s), (l), ARGPARSE_TYPE_NONE, (d) } +#define ARGPARSE_s_i(s,l,d) \ + { (s), (l), ARGPARSE_TYPE_INT, (d) } +#define ARGPARSE_s_s(s,l,d) \ + { (s), (l), ARGPARSE_TYPE_STRING, (d) } +#define ARGPARSE_s_l(s,l,d) \ + { (s), (l), ARGPARSE_TYPE_LONG, (d) } +#define ARGPARSE_s_u(s,l,d) \ + { (s), (l), ARGPARSE_TYPE_ULONG, (d) } + +#define ARGPARSE_o(s,l,t,d) \ + { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_OPTIONAL), (d) } +#define ARGPARSE_o_n(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_OPTIONAL), (d) } +#define ARGPARSE_o_i(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_OPTIONAL), (d) } +#define ARGPARSE_o_s(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_OPTIONAL), (d) } +#define ARGPARSE_o_l(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_OPTIONAL), (d) } +#define ARGPARSE_o_u(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_OPTIONAL), (d) } + +#define ARGPARSE_p(s,l,t,d) \ + { (s), (l), (ARGPARSE_TYPE_ ## t | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_p_n(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_p_i(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_INT | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_p_s(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_STRING | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_p_l(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_LONG | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_p_u(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_ULONG | ARGPARSE_OPT_PREFIX), (d) } + +#define ARGPARSE_op(s,l,t,d) \ + { (s), (l), (ARGPARSE_TYPE_ ## t \ + | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_op_n(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_NONE \ + | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_op_i(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_INT \ + | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_op_s(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_STRING \ + | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_op_l(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_LONG \ + | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) } +#define ARGPARSE_op_u(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_ULONG \ + | ARGPARSE_OPT_OPTIONAL | ARGPARSE_OPT_PREFIX), (d) } + +#define ARGPARSE_c(s,l,d) \ + { (s), (l), (ARGPARSE_TYPE_NONE | ARGPARSE_OPT_COMMAND), (d) } + +#define ARGPARSE_ignore(s,l) \ + { (s), (l), (ARGPARSE_OPT_IGNORE), "@" } + +#define ARGPARSE_group(s,d) \ + { (s), NULL, 0, (d) } + +/* Mark the end of the list (mandatory). */ +#define ARGPARSE_end() \ + { 0, NULL, 0, NULL } + +#endif /* GPGRT_ENABLE_ARGPARSE_MACROS */ + +/* Take care: gpgrt_argparse keeps state in ARG and requires that + * either ARGPARSE_FLAG_RESET is used after OPTS has been changed or + * gpgrt_argparse (NULL, ARG, NULL) is called first. */ +int gpgrt_argparse (gpgrt_stream_t fp, + gpgrt_argparse_t *arg, gpgrt_opt_t *opts); +void gpgrt_usage (int level); +const char *gpgrt_strusage (int level); +void gpgrt_set_strusage (const char *(*f)(int)); +void gpgrt_set_usage_outfnc (int (*f)(int, const char *)); +void gpgrt_set_fixed_string_mapper (const char *(*f)(const char*)); + + + +#ifdef __cplusplus +} +#endif +#endif /* GPGRT_H */ +#endif /* GPG_ERROR_H */ +/* +Local Variables: +buffer-read-only: t +End: +*/ diff --git a/gpg/include/gpgme.h b/gpg/include/gpgme.h new file mode 100644 index 0000000..a798c86 --- /dev/null +++ b/gpg/include/gpgme.h @@ -0,0 +1,2842 @@ +/* gpgme.h - Public interface to GnuPG Made Easy. -*- c -*- + * Copyright (C) 2000 Werner Koch (dd9jn) + * Copyright (C) 2001-2018 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, see . + * SPDX-License-Identifier: LGPL-2.1+ + * + * Generated from gpgme.h.in for i686-w64-mingw32. + */ + +#ifndef GPGME_H +#define GPGME_H + +/* Include stdio.h for the FILE type definition. */ +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#if 0 /*(Make Emacsen's auto-indent happy.)*/ +} +#endif +#endif /* __cplusplus */ + + +/* 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. */ +#define GPGME_VERSION "1.12.0" + +/* The version number of this header. It may be used to handle minor + * API incompatibilities. */ +#define GPGME_VERSION_NUMBER 0x010c00 + + +/* System specific typedefs. */ + +#ifdef _WIN64 +# include + typedef int64_t gpgme_off_t; + typedef int64_t gpgme_ssize_t; +#else /* _WIN32 */ + typedef long gpgme_off_t; + typedef long gpgme_ssize_t; +#endif /* _WIN32 */ + + + +/* + * Check for compiler features. + */ +#ifdef GPGRT_INLINE +# define _GPGME_INLINE GPGRT_INLINE +#elif defined(__GNUC__) +# define _GPGME_INLINE __inline__ +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define _GPGME_INLINE inline +#else +# define _GPGME_INLINE +#endif + + +/* The deprecated macro takes the version number of GPGME which + * introduced the deprecation as parameter for documentation. */ +#ifdef GPGRT_ATTR_DEPRECATED +# define _GPGME_DEPRECATED(a,b) GPGRT_ATTR_DEPRECATED +#elif defined(__GNUC__) +# define _GPGME_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +# if _GPGME_GCC_VERSION > 30100 +# define _GPGME_DEPRECATED(a,b) __attribute__ ((__deprecated__)) +# else +# define _GPGME_DEPRECATED(a,b) +# endif +#else +# define _GPGME_DEPRECATED(a,b) +#endif + + +/* The macro _GPGME_DEPRECATED_OUTSIDE_GPGME suppresses warnings for + * fields we must access in GPGME for ABI compatibility. */ +#ifdef _GPGME_IN_GPGME +#define _GPGME_DEPRECATED_OUTSIDE_GPGME(a,b) +#else +#define _GPGME_DEPRECATED_OUTSIDE_GPGME(a,b) _GPGME_DEPRECATED(a,b) +#endif + +/* We used to use some symbols which clash with keywords in some + * languages. This macro is used to obsolete them. */ +#if defined(__cplusplus) || defined(SWIGPYTHON) +# define _GPGME_OBSOLETE_SOME_SYMBOLS 1 +#endif + + +/* Check for a matching _FILE_OFFSET_BITS definition. */ +#if 0 +#ifndef _FILE_OFFSET_BITS +#error GPGME was compiled with _FILE_OFFSET_BITS = 0, please see the section "Largefile support (LFS)" in the GPGME manual. +#else +#if (_FILE_OFFSET_BITS) != (0) +#error GPGME was compiled with a different value for _FILE_OFFSET_BITS, namely 0, please see the section "Largefile support (LFS)" in the GPGME manual. +#endif +#endif +#endif + + + +/* + * Some opaque data types used by GPGME. + */ + +/* The context holds some global state and configuration options, as + * well as the results of a crypto operation. */ +struct gpgme_context; +typedef struct gpgme_context *gpgme_ctx_t; + +/* The data object is used by GPGME to exchange arbitrary data. */ +struct gpgme_data; +typedef struct gpgme_data *gpgme_data_t; + + + +/* + * Wrappers for the libgpg-error library. They are generally not + * needed and the gpg-error versions may be used instead. + */ + +typedef gpg_error_t gpgme_error_t; +typedef gpg_err_code_t gpgme_err_code_t; +typedef gpg_err_source_t gpgme_err_source_t; + + +static _GPGME_INLINE gpgme_error_t +gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code) +{ + return gpg_err_make (source, code); +} + + +/* The user can define GPGME_ERR_SOURCE_DEFAULT before including this + * file to specify a default source for gpgme_error. */ +#ifndef GPGME_ERR_SOURCE_DEFAULT +#define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1 +#endif + +static _GPGME_INLINE gpgme_error_t +gpgme_error (gpgme_err_code_t code) +{ + return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code); +} + + +static _GPGME_INLINE gpgme_err_code_t +gpgme_err_code (gpgme_error_t err) +{ + return gpg_err_code (err); +} + + +static _GPGME_INLINE gpgme_err_source_t +gpgme_err_source (gpgme_error_t err) +{ + return gpg_err_source (err); +} + + +/* Return a pointer to a string containing a description of the error + * code in the error value ERR. This function is not thread safe. */ +const char *gpgme_strerror (gpgme_error_t err); + +/* Return the error string for ERR in the user-supplied buffer BUF of + * size BUFLEN. This function is, in contrast to gpg_strerror, + * thread-safe if a thread-safe strerror_r() function is provided by + * the system. If the function succeeds, 0 is returned and BUF + * contains the string describing the error. If the buffer was not + * large enough, ERANGE is returned and BUF contains as much of the + * beginning of the error string as fits into the buffer. */ +int gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen); + +/* Return a pointer to a string containing a description of the error + * source in the error value ERR. */ +const char *gpgme_strsource (gpgme_error_t err); + +/* Retrieve the error code for the system error ERR. This returns + * GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report + * this). */ +gpgme_err_code_t gpgme_err_code_from_errno (int err); + +/* Retrieve the system error for the error code CODE. This returns 0 + * if CODE is not a system error code. */ +int gpgme_err_code_to_errno (gpgme_err_code_t code); + +/* Retrieve the error code directly from the ERRNO variable. This + * returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped + * (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */ +gpgme_err_code_t gpgme_err_code_from_syserror (void); + +/* Set the ERRNO variable. This function is the preferred way to set + * ERRNO due to peculiarities on WindowsCE. */ +void gpgme_err_set_errno (int err); + +/* Return an error value with the error source SOURCE and the system + * error ERR. FIXME: Should be inline. */ +gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err); + +/* Return an error value with the system error ERR. + * inline. */ +gpgme_error_t gpgme_error_from_errno (int err); + + +static _GPGME_INLINE gpgme_error_t +gpgme_error_from_syserror (void) +{ + return gpgme_error (gpgme_err_code_from_syserror ()); +} + + + +/* + * Various constants and types + */ + +/* The possible encoding mode of gpgme_data_t objects. */ +typedef enum + { + GPGME_DATA_ENCODING_NONE = 0, /* Not specified. */ + GPGME_DATA_ENCODING_BINARY = 1, + GPGME_DATA_ENCODING_BASE64 = 2, + GPGME_DATA_ENCODING_ARMOR = 3, /* Either PEM or OpenPGP Armor. */ + GPGME_DATA_ENCODING_URL = 4, /* LF delimited URL list. */ + GPGME_DATA_ENCODING_URLESC = 5, /* Ditto, but percent escaped. */ + GPGME_DATA_ENCODING_URL0 = 6, /* Nul delimited URL list. */ + GPGME_DATA_ENCODING_MIME = 7 /* Data is a MIME part. */ + } +gpgme_data_encoding_t; + + +/* Known data types. */ +typedef enum + { + GPGME_DATA_TYPE_INVALID = 0, /* Not detected. */ + GPGME_DATA_TYPE_UNKNOWN = 1, + GPGME_DATA_TYPE_PGP_SIGNED = 0x10, + GPGME_DATA_TYPE_PGP_ENCRYPTED= 0x11, + GPGME_DATA_TYPE_PGP_OTHER = 0x12, + GPGME_DATA_TYPE_PGP_KEY = 0x13, + GPGME_DATA_TYPE_PGP_SIGNATURE= 0x18, /* Detached signature */ + GPGME_DATA_TYPE_CMS_SIGNED = 0x20, + GPGME_DATA_TYPE_CMS_ENCRYPTED= 0x21, + GPGME_DATA_TYPE_CMS_OTHER = 0x22, + GPGME_DATA_TYPE_X509_CERT = 0x23, + GPGME_DATA_TYPE_PKCS12 = 0x24, + } +gpgme_data_type_t; + + +/* Public key algorithms. */ +typedef enum + { + GPGME_PK_RSA = 1, + GPGME_PK_RSA_E = 2, + GPGME_PK_RSA_S = 3, + GPGME_PK_ELG_E = 16, + GPGME_PK_DSA = 17, + GPGME_PK_ECC = 18, + GPGME_PK_ELG = 20, + GPGME_PK_ECDSA = 301, + GPGME_PK_ECDH = 302, + GPGME_PK_EDDSA = 303 + } +gpgme_pubkey_algo_t; + + +/* Hash algorithms (the values match those from libgcrypt). */ +typedef enum + { + GPGME_MD_NONE = 0, + GPGME_MD_MD5 = 1, + GPGME_MD_SHA1 = 2, + GPGME_MD_RMD160 = 3, + GPGME_MD_MD2 = 5, + GPGME_MD_TIGER = 6, /* TIGER/192. */ + GPGME_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */ + GPGME_MD_SHA256 = 8, + GPGME_MD_SHA384 = 9, + GPGME_MD_SHA512 = 10, + GPGME_MD_SHA224 = 11, + GPGME_MD_MD4 = 301, + GPGME_MD_CRC32 = 302, + GPGME_MD_CRC32_RFC1510 = 303, + GPGME_MD_CRC24_RFC2440 = 304 + } +gpgme_hash_algo_t; + + +/* The available signature modes. */ +typedef enum + { + GPGME_SIG_MODE_NORMAL = 0, + GPGME_SIG_MODE_DETACH = 1, + GPGME_SIG_MODE_CLEAR = 2 + } +gpgme_sig_mode_t; + + +/* The available validities for a trust item or key. */ +typedef enum + { + GPGME_VALIDITY_UNKNOWN = 0, + GPGME_VALIDITY_UNDEFINED = 1, + GPGME_VALIDITY_NEVER = 2, + GPGME_VALIDITY_MARGINAL = 3, + GPGME_VALIDITY_FULL = 4, + GPGME_VALIDITY_ULTIMATE = 5 + } +gpgme_validity_t; + + +/* The TOFU policies. */ +typedef enum + { + GPGME_TOFU_POLICY_NONE = 0, + GPGME_TOFU_POLICY_AUTO = 1, + GPGME_TOFU_POLICY_GOOD = 2, + GPGME_TOFU_POLICY_UNKNOWN = 3, + GPGME_TOFU_POLICY_BAD = 4, + GPGME_TOFU_POLICY_ASK = 5 + } +gpgme_tofu_policy_t; + + +/* The key origin values. */ +typedef enum + { + GPGME_KEYORG_UNKNOWN = 0, + GPGME_KEYORG_KS = 1, + GPGME_KEYORG_DANE = 3, + GPGME_KEYORG_WKD = 4, + GPGME_KEYORG_URL = 5, + GPGME_KEYORG_FILE = 6, + GPGME_KEYORG_SELF = 7, + GPGME_KEYORG_OTHER = 31 + } +gpgme_keyorg_t; + + +/* The available protocols. */ +typedef enum + { + GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */ + GPGME_PROTOCOL_CMS = 1, + GPGME_PROTOCOL_GPGCONF = 2, /* Special code for gpgconf. */ + GPGME_PROTOCOL_ASSUAN = 3, /* Low-level access to an Assuan server. */ + GPGME_PROTOCOL_G13 = 4, + GPGME_PROTOCOL_UISERVER= 5, + GPGME_PROTOCOL_SPAWN = 6, /* Direct access to any program. */ + GPGME_PROTOCOL_DEFAULT = 254, + GPGME_PROTOCOL_UNKNOWN = 255 + } +gpgme_protocol_t; +/* Convenience macro for the surprisingly mixed spelling. */ +#define GPGME_PROTOCOL_OPENPGP GPGME_PROTOCOL_OpenPGP + + +/* The available keylist mode flags. */ +#define GPGME_KEYLIST_MODE_LOCAL 1 +#define GPGME_KEYLIST_MODE_EXTERN 2 +#define GPGME_KEYLIST_MODE_SIGS 4 +#define GPGME_KEYLIST_MODE_SIG_NOTATIONS 8 +#define GPGME_KEYLIST_MODE_WITH_SECRET 16 +#define GPGME_KEYLIST_MODE_WITH_TOFU 32 +#define GPGME_KEYLIST_MODE_EPHEMERAL 128 +#define GPGME_KEYLIST_MODE_VALIDATE 256 + +#define GPGME_KEYLIST_MODE_LOCATE (1|2) + +typedef unsigned int gpgme_keylist_mode_t; + + +/* The pinentry modes. */ +typedef enum + { + GPGME_PINENTRY_MODE_DEFAULT = 0, + GPGME_PINENTRY_MODE_ASK = 1, + GPGME_PINENTRY_MODE_CANCEL = 2, + GPGME_PINENTRY_MODE_ERROR = 3, + GPGME_PINENTRY_MODE_LOOPBACK = 4 + } +gpgme_pinentry_mode_t; + + +/* The available export mode flags. */ +#define GPGME_EXPORT_MODE_EXTERN 2 +#define GPGME_EXPORT_MODE_MINIMAL 4 +#define GPGME_EXPORT_MODE_SECRET 16 +#define GPGME_EXPORT_MODE_RAW 32 +#define GPGME_EXPORT_MODE_PKCS12 64 +#define GPGME_EXPORT_MODE_NOUID 128 /* Experimental(!)*/ + +typedef unsigned int gpgme_export_mode_t; + + +/* Flags for the audit log functions. */ +#define GPGME_AUDITLOG_DEFAULT 0 +#define GPGME_AUDITLOG_HTML 1 +#define GPGME_AUDITLOG_DIAG 2 +#define GPGME_AUDITLOG_WITH_HELP 128 + + +/* The available signature notation flags. */ +#define GPGME_SIG_NOTATION_HUMAN_READABLE 1 +#define GPGME_SIG_NOTATION_CRITICAL 2 + +typedef unsigned int gpgme_sig_notation_flags_t; + +/* An object to hold information about notation data. This structure + * shall be considered read-only and an application must not allocate + * such a structure on its own. */ +struct _gpgme_sig_notation +{ + struct _gpgme_sig_notation *next; + + /* If NAME is a null pointer, then VALUE contains a policy URL + * rather than a notation. */ + char *name; + + /* The value of the notation data. */ + char *value; + + /* The length of the name of the notation data. */ + int name_len; + + /* The length of the value of the notation data. */ + int value_len; + + /* The accumulated flags. */ + gpgme_sig_notation_flags_t flags; + + /* Notation data is human-readable. */ + unsigned int human_readable : 1; + + /* Notation data is critical. */ + unsigned int critical : 1; + + /* Internal to GPGME, do not use. */ + int _unused : 30; +}; +typedef struct _gpgme_sig_notation *gpgme_sig_notation_t; + + + +/* + * Public structures. + */ + +/* The engine information structure. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_engine_info +{ + struct _gpgme_engine_info *next; + + /* The protocol ID. */ + gpgme_protocol_t protocol; + + /* The file name of the engine binary. */ + char *file_name; + + /* The version string of the installed engine. */ + char *version; + + /* The minimum version required for GPGME. */ + const char *req_version; + + /* The home directory used, or NULL if default. */ + char *home_dir; +}; +typedef struct _gpgme_engine_info *gpgme_engine_info_t; + + +/* An object with TOFU information. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_tofu_info +{ + struct _gpgme_tofu_info *next; + + /* The TOFU validity: + * 0 := conflict + * 1 := key without history + * 2 := key with too little history + * 3 := key with enough history for basic trust + * 4 := key with a lot of history + */ + unsigned int validity : 3; + + /* The TOFU policy (gpgme_tofu_policy_t). */ + unsigned int policy : 4; + + unsigned int _rfu : 25; + + /* Number of signatures seen for this binding. Capped at USHRT_MAX. */ + unsigned short signcount; + /* Number of encryptions done with this binding. Capped at USHRT_MAX. */ + unsigned short encrcount; + + /* Number of seconds since Epoch when the first and the most + * recently seen message were verified/decrypted. 0 means unknown. */ + unsigned long signfirst; + unsigned long signlast; + unsigned long encrfirst; + unsigned long encrlast; + + /* If non-NULL a human readable string summarizing the TOFU data. */ + char *description; +}; +typedef struct _gpgme_tofu_info *gpgme_tofu_info_t; + + +/* A subkey from a key. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_subkey +{ + struct _gpgme_subkey *next; + + /* True if subkey is revoked. */ + unsigned int revoked : 1; + + /* True if subkey is expired. */ + unsigned int expired : 1; + + /* True if subkey is disabled. */ + unsigned int disabled : 1; + + /* True if subkey is invalid. */ + unsigned int invalid : 1; + + /* True if subkey can be used for encryption. */ + unsigned int can_encrypt : 1; + + /* True if subkey can be used for signing. */ + unsigned int can_sign : 1; + + /* True if subkey can be used for certification. */ + unsigned int can_certify : 1; + + /* True if subkey is secret. */ + unsigned int secret : 1; + + /* True if subkey can be used for authentication. */ + unsigned int can_authenticate : 1; + + /* True if subkey is qualified for signatures according to German law. */ + unsigned int is_qualified : 1; + + /* True if the secret key is stored on a smart card. */ + unsigned int is_cardkey : 1; + + /* True if the key is compliant to the de-vs mode. */ + unsigned int is_de_vs : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 20; + + /* Public key algorithm supported by this subkey. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* Length of the subkey. */ + unsigned int length; + + /* The key ID of the subkey. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The fingerprint of the subkey in hex digit form. */ + char *fpr; + + /* The creation timestamp, -1 if invalid, 0 if not available. */ + long int timestamp; + + /* The expiration timestamp, 0 if the subkey does not expire. */ + long int expires; + + /* The serial number of a smart card holding this key or NULL. */ + char *card_number; + + /* The name of the curve for ECC algorithms or NULL. */ + char *curve; + + /* The keygrip of the subkey in hex digit form or NULL if not availabale. */ + char *keygrip; +}; +typedef struct _gpgme_subkey *gpgme_subkey_t; + + +/* A signature on a user ID. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_key_sig +{ + struct _gpgme_key_sig *next; + + /* True if the signature is a revocation signature. */ + unsigned int revoked : 1; + + /* True if the signature is expired. */ + unsigned int expired : 1; + + /* True if the signature is invalid. */ + unsigned int invalid : 1; + + /* True if the signature should be exported. */ + unsigned int exportable : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 28; + + /* The public key algorithm used to create the signature. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* The key ID of key used to create the signature. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The creation timestamp, -1 if invalid, 0 if not available. */ + long int timestamp; + + /* The expiration timestamp, 0 if the subkey does not expire. */ + long int expires; + + /* Same as in gpgme_signature_t. */ + gpgme_error_t status; + + /* Deprecated; use SIG_CLASS instead. */ +#ifdef _GPGME_OBSOLETE_SOME_SYMBOLS + unsigned int _obsolete_class _GPGME_DEPRECATED(0,4); +#else + unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4); +#endif + + /* The user ID string. */ + char *uid; + + /* The name part of the user ID. */ + char *name; + + /* The email part of the user ID. */ + char *email; + + /* The comment part of the user ID. */ + char *comment; + + /* Crypto backend specific signature class. */ + unsigned int sig_class; + + /* Notation data and policy URLs. */ + gpgme_sig_notation_t notations; + + /* Internal to GPGME, do not use. */ + gpgme_sig_notation_t _last_notation; +}; +typedef struct _gpgme_key_sig *gpgme_key_sig_t; + + +/* An user ID from a key. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_user_id +{ + struct _gpgme_user_id *next; + + /* True if the user ID is revoked. */ + unsigned int revoked : 1; + + /* True if the user ID is invalid. */ + unsigned int invalid : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 25; + + /* Origin of this user ID. */ + unsigned int origin : 5; + + /* The validity of the user ID. */ + gpgme_validity_t validity; + + /* The user ID string. */ + char *uid; + + /* The name part of the user ID. */ + char *name; + + /* The email part of the user ID. */ + char *email; + + /* The comment part of the user ID. */ + char *comment; + + /* The signatures of the user ID. */ + gpgme_key_sig_t signatures; + + /* Internal to GPGME, do not use. */ + gpgme_key_sig_t _last_keysig; + + /* The mail address (addr-spec from RFC5322) of the UID string. + * This is general the same as the EMAIL part of this struct but + * might be slightly different. If no mail address is available + * NULL is stored. */ + char *address; + + /* The malloced TOFU information or NULL. */ + gpgme_tofu_info_t tofu; + + /* Time of the last refresh of this user id. 0 if unknown. */ + unsigned long last_update; +}; +typedef struct _gpgme_user_id *gpgme_user_id_t; + + +/* A key from the keyring. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_key +{ + /* Internal to GPGME, do not use. */ + unsigned int _refs; + + /* True if key is revoked. */ + unsigned int revoked : 1; + + /* True if key is expired. */ + unsigned int expired : 1; + + /* True if key is disabled. */ + unsigned int disabled : 1; + + /* True if key is invalid. */ + unsigned int invalid : 1; + + /* True if key can be used for encryption. */ + unsigned int can_encrypt : 1; + + /* True if key can be used for signing. */ + unsigned int can_sign : 1; + + /* True if key can be used for certification. */ + unsigned int can_certify : 1; + + /* True if key is secret. */ + unsigned int secret : 1; + + /* True if key can be used for authentication. */ + unsigned int can_authenticate : 1; + + /* True if subkey is qualified for signatures according to German law. */ + unsigned int is_qualified : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 17; + + /* Origin of this key. */ + unsigned int origin : 5; + + /* This is the protocol supported by this key. */ + gpgme_protocol_t protocol; + + /* If protocol is GPGME_PROTOCOL_CMS, this string contains the + issuer serial. */ + char *issuer_serial; + + /* If protocol is GPGME_PROTOCOL_CMS, this string contains the + issuer name. */ + char *issuer_name; + + /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain + ID. */ + char *chain_id; + + /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the + owner trust. */ + gpgme_validity_t owner_trust; + + /* The subkeys of the key. */ + gpgme_subkey_t subkeys; + + /* The user IDs of the key. */ + gpgme_user_id_t uids; + + /* Internal to GPGME, do not use. */ + gpgme_subkey_t _last_subkey; + + /* Internal to GPGME, do not use. */ + gpgme_user_id_t _last_uid; + + /* The keylist mode that was active when listing the key. */ + gpgme_keylist_mode_t keylist_mode; + + /* This field gives the fingerprint of the primary key. Note that + * this is a copy of the FPR of the first subkey. We need it here + * to allow for an incomplete key object. */ + char *fpr; + + /* Time of the last refresh of the entire key. 0 if unknown. */ + unsigned long last_update; +}; +typedef struct _gpgme_key *gpgme_key_t; + + +/* An invalid key object. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_invalid_key +{ + struct _gpgme_invalid_key *next; + + /* The string used to request the key. Despite the name this may + * not be a fingerprint. */ + char *fpr; + + /* The error code. */ + gpgme_error_t reason; +}; +typedef struct _gpgme_invalid_key *gpgme_invalid_key_t; + + + +/* + * Types for callback functions. + */ + +/* Request a passphrase from the user. */ +typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook, + const char *uid_hint, + const char *passphrase_info, + int prev_was_bad, int fd); + +/* Inform the user about progress made. */ +typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what, + int type, int current, int total); + +/* Status messages from gpg. */ +typedef gpgme_error_t (*gpgme_status_cb_t) (void *opaque, const char *keyword, + const char *args); + +/* Interact with the user about an edit operation. */ +typedef gpgme_error_t (*gpgme_interact_cb_t) (void *opaque, + const char *keyword, + const char *args, int fd); + + + +/* + * Context management functions. + */ + +/* Create a new context and return it in CTX. */ +gpgme_error_t gpgme_new (gpgme_ctx_t *ctx); + +/* Release the context CTX. */ +void gpgme_release (gpgme_ctx_t ctx); + +/* Set the flag NAME for CTX to VALUE. */ +gpgme_error_t gpgme_set_ctx_flag (gpgme_ctx_t ctx, + const char *name, const char *value); + +/* Get the value of the flag NAME from CTX. */ +const char *gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name); + +/* Set the protocol to be used by CTX to PROTO. */ +gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto); + +/* Get the protocol used with CTX */ +gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx); + +/* Set the crypto protocol to be used by CTX to PROTO. + * gpgme_set_protocol actually sets the backend engine. This sets the + * crypto protocol used in engines that support more than one crypto + * prococol (for example, an UISERVER can support OpenPGP and CMS). + * This is reset to the default with gpgme_set_protocol. */ +gpgme_error_t gpgme_set_sub_protocol (gpgme_ctx_t ctx, + gpgme_protocol_t proto); + +/* Get the sub protocol. */ +gpgme_protocol_t gpgme_get_sub_protocol (gpgme_ctx_t ctx); + +/* Get the string describing protocol PROTO, or NULL if invalid. */ +const char *gpgme_get_protocol_name (gpgme_protocol_t proto); + +/* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */ +void gpgme_set_armor (gpgme_ctx_t ctx, int yes); + +/* Return non-zero if armor mode is set in CTX. */ +int gpgme_get_armor (gpgme_ctx_t ctx); + +/* If YES is non-zero, enable text mode in CTX, disable it otherwise. */ +void gpgme_set_textmode (gpgme_ctx_t ctx, int yes); + +/* Return non-zero if text mode is set in CTX. */ +int gpgme_get_textmode (gpgme_ctx_t ctx); + +/* If YES is non-zero, enable offline mode in CTX, disable it otherwise. */ +void gpgme_set_offline (gpgme_ctx_t ctx, int yes); + +/* Return non-zero if offline mode is set in CTX. */ +int gpgme_get_offline (gpgme_ctx_t ctx); + +/* Use whatever the default of the backend crypto engine is. */ +#define GPGME_INCLUDE_CERTS_DEFAULT -256 + +/* Include up to NR_OF_CERTS certificates in an S/MIME message. */ +void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs); + +/* Return the number of certs to include in an S/MIME message. */ +int gpgme_get_include_certs (gpgme_ctx_t ctx); + +/* Set keylist mode in CTX to MODE. */ +gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx, + gpgme_keylist_mode_t mode); + +/* Get keylist mode in CTX. */ +gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx); + +/* Set the pinentry mode for CTX to MODE. */ +gpgme_error_t gpgme_set_pinentry_mode (gpgme_ctx_t ctx, + gpgme_pinentry_mode_t mode); + +/* Get the pinentry mode of CTX. */ +gpgme_pinentry_mode_t gpgme_get_pinentry_mode (gpgme_ctx_t ctx); + +/* 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 (gpgme_ctx_t ctx, + gpgme_passphrase_cb_t cb, void *hook_value); + +/* Get the current passphrase callback function in *CB and the current + * hook value in *HOOK_VALUE. */ +void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb, + void **hook_value); + +/* 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 (gpgme_ctx_t c, gpgme_progress_cb_t cb, + void *hook_value); + +/* Get the current progress callback function in *CB and the current + * hook value in *HOOK_VALUE. */ +void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb, + void **hook_value); + +/* Set the status callback function in CTX to CB. HOOK_VALUE is + * passed as first argument to the status callback function. */ +void gpgme_set_status_cb (gpgme_ctx_t c, gpgme_status_cb_t cb, + void *hook_value); + +/* Get the current status callback function in *CB and the current + * hook value in *HOOK_VALUE. */ +void gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *cb, + void **hook_value); + +/* This function sets the locale for the context CTX, or the default + * locale if CTX is a null pointer. */ +gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category, + const char *value); + +/* Get the information about the configured engines. A pointer to the + * first engine in the statically allocated linked list is returned. + * The returned data is valid until the next gpgme_ctx_set_engine_info. */ +gpgme_engine_info_t gpgme_ctx_get_engine_info (gpgme_ctx_t ctx); + +/* Set the engine info for the context CTX, protocol PROTO, to the + * file name FILE_NAME and the home directory HOME_DIR. */ +gpgme_error_t gpgme_ctx_set_engine_info (gpgme_ctx_t ctx, + gpgme_protocol_t proto, + const char *file_name, + const char *home_dir); + +/* Delete all signers from CTX. */ +void gpgme_signers_clear (gpgme_ctx_t ctx); + +/* Add KEY to list of signers in CTX. */ +gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key); + +/* Return the number of signers in CTX. */ +unsigned int gpgme_signers_count (const gpgme_ctx_t ctx); + +/* Return the SEQth signer's key in CTX. */ +gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq); + +/* Clear all notation data from the context. */ +void gpgme_sig_notation_clear (gpgme_ctx_t ctx); + +/* Add the human-readable notation data with name NAME and value VALUE + * to the context CTX, using the flags FLAGS. If NAME is NULL, then + * VALUE should be a policy URL. The flag + * GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation + * data, and false for policy URLs. */ +gpgme_error_t gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name, + const char *value, + gpgme_sig_notation_flags_t flags); + +/* Get the sig notations for this context. */ +gpgme_sig_notation_t gpgme_sig_notation_get (gpgme_ctx_t ctx); + +/* Store a sender address in the context. */ +gpgme_error_t gpgme_set_sender (gpgme_ctx_t ctx, const char *address); + +/* Get the sender address from the context. */ +const char *gpgme_get_sender (gpgme_ctx_t ctx); + + + +/* + * Run control. + */ + +/* The type of an I/O callback function. */ +typedef gpgme_error_t (*gpgme_io_cb_t) (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: for writing, + * 1: for reading). FNC_DATA should be passed as DATA to FNC. The + * function should return a TAG suitable for the corresponding + * gpgme_remove_io_cb_t, and an error value. */ +typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir, + gpgme_io_cb_t fnc, + void *fnc_data, void **tag); + +/* 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 (*gpgme_remove_io_cb_t) (void *tag); + +typedef enum + { + GPGME_EVENT_START, + GPGME_EVENT_DONE, + GPGME_EVENT_NEXT_KEY, + GPGME_EVENT_NEXT_TRUSTITEM + } +gpgme_event_io_t; + +struct gpgme_io_event_done_data +{ + /* A fatal IPC error or an operational error in state-less + * protocols. */ + gpgme_error_t err; + + /* An operational errors in session-based protocols. */ + gpgme_error_t op_err; +}; +typedef struct gpgme_io_event_done_data *gpgme_io_event_done_data_t; + +/* The type of a function that is called when a context finished an + * operation. */ +typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type, + void *type_data); + +struct gpgme_io_cbs +{ + gpgme_register_io_cb_t add; + void *add_priv; + gpgme_remove_io_cb_t remove; + gpgme_event_io_cb_t event; + void *event_priv; +}; +typedef struct gpgme_io_cbs *gpgme_io_cbs_t; + +/* Set the I/O callback functions in CTX to IO_CBS. */ +void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs); + +/* Get the current I/O callback functions. */ +void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs); + +/* Wrappers around the internal I/O functions for use with + * gpgme_passphrase_cb_t and gpgme_interact_cb_t. */ +gpgme_ssize_t gpgme_io_read (int fd, void *buffer, size_t count); +gpgme_ssize_t gpgme_io_write (int fd, const void *buffer, size_t count); +int gpgme_io_writen (int fd, const void *buffer, size_t count); + +/* Process the pending operation and, if HANG is non-zero, wait for + * the pending operation to finish. */ +gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang); + +gpgme_ctx_t gpgme_wait_ext (gpgme_ctx_t ctx, gpgme_error_t *status, + gpgme_error_t *op_err, int hang); + +/* Cancel a pending asynchronous operation. */ +gpgme_error_t gpgme_cancel (gpgme_ctx_t ctx); + +/* Cancel a pending operation asynchronously. */ +gpgme_error_t gpgme_cancel_async (gpgme_ctx_t ctx); + + + +/* + * Functions to handle data objects. + */ + +/* Read up to SIZE bytes into buffer BUFFER from the data object with + * the handle HANDLE. Return the number of characters read, 0 on EOF + * and -1 on error. If an error occurs, errno is set. */ +typedef gpgme_ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer, + size_t size); + +/* Write up to SIZE bytes from buffer BUFFER to the data object with + * the handle HANDLE. Return the number of characters written, or -1 + * on error. If an error occurs, errno is set. */ +typedef gpgme_ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer, + size_t size); + +/* Set the current position from where the next read or write starts + * in the data object with the handle HANDLE to OFFSET, relativ to + * WHENCE. Returns the new offset in bytes from the beginning of the + * data object. */ +typedef gpgme_off_t (*gpgme_data_seek_cb_t) (void *handle, + gpgme_off_t offset, int whence); + +/* Close the data object with the handle HANDLE. */ +typedef void (*gpgme_data_release_cb_t) (void *handle); + +struct gpgme_data_cbs +{ + gpgme_data_read_cb_t read; + gpgme_data_write_cb_t write; + gpgme_data_seek_cb_t seek; + gpgme_data_release_cb_t release; +}; +typedef struct gpgme_data_cbs *gpgme_data_cbs_t; + +/* Read up to SIZE bytes into buffer BUFFER from the data object with + * the handle DH. Return the number of characters read, 0 on EOF and + * -1 on error. If an error occurs, errno is set. */ +gpgme_ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size); + +/* Write up to SIZE bytes from buffer BUFFER to the data object with + * the handle DH. Return the number of characters written, or -1 on + * error. If an error occurs, errno is set. */ +gpgme_ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size); + +/* Set the current position from where the next read or write starts + * in the data object with the handle DH to OFFSET, relativ to WHENCE. + * Returns the new offset in bytes from the beginning of the data + * object. */ +gpgme_off_t gpgme_data_seek (gpgme_data_t dh, gpgme_off_t offset, int whence); + +/* Create a new data buffer and return it in R_DH. */ +gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh); + +/* Destroy the data buffer DH. */ +void gpgme_data_release (gpgme_data_t 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); + +/* 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); + +/* Release the memory returned by gpgme_data_release_and_get_mem() and + * some other functions. */ +void gpgme_free (void *buffer); + +gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh, + gpgme_data_cbs_t cbs, + void *handle); + +gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd); + +gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream); +gpgme_error_t gpgme_data_new_from_estream (gpgme_data_t *r_dh, + gpgrt_stream_t stream); + +/* Return the encoding attribute of the data buffer DH */ +gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh); + +/* Set the encoding attribute of data buffer DH to ENC */ +gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh, + gpgme_data_encoding_t enc); + +/* Get the file name associated with the data object with handle DH, or + * NULL if there is none. */ +char *gpgme_data_get_file_name (gpgme_data_t dh); + +/* Set the file name associated with the data object with handle DH to + * FILE_NAME. */ +gpgme_error_t gpgme_data_set_file_name (gpgme_data_t dh, + const char *file_name); + +/* Set a flag for the data object DH. See the manual for details. */ +gpg_error_t gpgme_data_set_flag (gpgme_data_t dh, + const char *name, const char *value); + +/* Try to identify the type of the data in DH. */ +gpgme_data_type_t gpgme_data_identify (gpgme_data_t dh, int reserved); + + +/* Create a new data buffer filled with the content of file FNAME. + * COPY must be non-zero. For delayed read, please use + * gpgme_data_new_from_fd or gpgme_data_new_from_stream instead. */ +gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *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). */ +gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh, + const char *fname, FILE *fp, + gpgme_off_t offset, size_t length); + +/* Convenience function to do a gpgme_data_seek (dh, 0, SEEK_SET). */ +gpgme_error_t gpgme_data_rewind (gpgme_data_t dh); + + + +/* + * Key and trust functions. + */ + +/* Get the key with the fingerprint FPR from the crypto backend. If + * SECRET is true, get the secret key. */ +gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, + gpgme_key_t *r_key, int secret); + +/* Create a dummy key to specify an email address. */ +gpgme_error_t gpgme_key_from_uid (gpgme_key_t *key, const char *name); + +/* Acquire a reference to KEY. */ +void gpgme_key_ref (gpgme_key_t key); + +/* Release a reference to KEY. If this was the last one the key is + * destroyed. */ +void gpgme_key_unref (gpgme_key_t key); +void gpgme_key_release (gpgme_key_t key); + + + +/* + * Encryption. + */ + +/* An object to return results from an encryption operation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_encrypt_result +{ + /* The list of invalid recipients. */ + gpgme_invalid_key_t invalid_recipients; +}; +typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t; + +/* Retrieve a pointer to the result of the encrypt operation. */ +gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx); + +/* The valid encryption flags. */ +typedef enum + { + GPGME_ENCRYPT_ALWAYS_TRUST = 1, + GPGME_ENCRYPT_NO_ENCRYPT_TO = 2, + GPGME_ENCRYPT_PREPARE = 4, + GPGME_ENCRYPT_EXPECT_SIGN = 8, + GPGME_ENCRYPT_NO_COMPRESS = 16, + GPGME_ENCRYPT_SYMMETRIC = 32, + GPGME_ENCRYPT_THROW_KEYIDS = 64, + GPGME_ENCRYPT_WRAP = 128, + GPGME_ENCRYPT_WANT_ADDRESS = 256 + } +gpgme_encrypt_flags_t; + +/* Encrypt plaintext PLAIN within CTX for the recipients RECP and + * store the resulting ciphertext in CIPHER. */ +gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt_ext_start (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *recpstring, + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt_ext (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *recpstring, + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); + +/* 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. */ +gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx, + gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt_sign_ext_start (gpgme_ctx_t ctx, + gpgme_key_t recp[], + const char *recpstring, + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt_sign_ext (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *recpstring, + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); + + +/* + * Decryption. + */ + +/* An object to hold information about a recipient. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_recipient +{ + struct _gpgme_recipient *next; + + /* The key ID of key for which the text was encrypted. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The public key algorithm of the recipient key. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* The status of the recipient. */ + gpgme_error_t status; +}; +typedef struct _gpgme_recipient *gpgme_recipient_t; + + +/* An object to return results from a decryption operation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_decrypt_result +{ + char *unsupported_algorithm; + + /* Key should not have been used for encryption. */ + unsigned int wrong_key_usage : 1; + + /* True if the message was encrypted in compliance to the de-vs + * mode. */ + unsigned int is_de_vs : 1; + + /* The message claims that the content is a MIME object. */ + unsigned int is_mime : 1; + + /* The message was made by a legacy algorithm without any integrity + * protection. This might be an old but legitimate message. */ + unsigned int legacy_cipher_nomdc : 1; + + /* Internal to GPGME, do not use. */ + int _unused : 28; + + gpgme_recipient_t recipients; + + /* The original file name of the plaintext message, if + * available. */ + char *file_name; + + /* A textual representation of the session key used to decrypt the + * message, if available */ + char *session_key; + + /* A string with the symmetric encryption algorithm and mode using + * the format ".". */ + char *symkey_algo; +}; +typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t; + + +/* Retrieve a pointer to the result of the decrypt operation. */ +gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx); + + +/* The valid decryption flags. */ +typedef enum + { + GPGME_DECRYPT_VERIFY = 1, + GPGME_DECRYPT_UNWRAP = 128 + } +gpgme_decrypt_flags_t; + + +/* Decrypt ciphertext CIPHER within CTX and store the resulting + * plaintext in PLAIN. */ +gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain); +gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx, + gpgme_data_t cipher, gpgme_data_t plain); + +/* Decrypt ciphertext CIPHER and make a signature verification within + * CTX and store the resulting plaintext in PLAIN. */ +gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx, + gpgme_data_t cipher, + gpgme_data_t plain); +gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain); + +/* Decrypt ciphertext CIPHER within CTX and store the resulting + * plaintext in PLAIN. With the flag GPGME_DECRYPT_VERIFY also do a + * signature verification pn the plaintext. */ +gpgme_error_t gpgme_op_decrypt_ext_start (gpgme_ctx_t ctx, + gpgme_decrypt_flags_t flags, + gpgme_data_t cipher, + gpgme_data_t plain); +gpgme_error_t gpgme_op_decrypt_ext (gpgme_ctx_t ctx, + gpgme_decrypt_flags_t flags, + gpgme_data_t cipher, + gpgme_data_t plain); + + + +/* + * Signing. + */ + +/* An object with signatures data. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_new_signature +{ + struct _gpgme_new_signature *next; + + /* The type of the signature. */ + gpgme_sig_mode_t type; + + /* The public key algorithm used to create the signature. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* The hash algorithm used to create the signature. */ + gpgme_hash_algo_t hash_algo; + + /* Internal to GPGME, do not use. Must be set to the same value as + * CLASS below. */ + unsigned long _obsolete_class; + + /* Signature creation time. */ + long int timestamp; + + /* The fingerprint of the signature. */ + char *fpr; + + /* Deprecated; use SIG_CLASS instead. */ +#ifdef _GPGME_OBSOLETE_SOME_SYMBOLS + unsigned int _obsolete_class_2; +#else + unsigned int class _GPGME_DEPRECATED_OUTSIDE_GPGME(0,4); +#endif + + /* Crypto backend specific signature class. */ + unsigned int sig_class; +}; +typedef struct _gpgme_new_signature *gpgme_new_signature_t; + + +/* An object to return results from a signing operation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_sign_result +{ + /* The list of invalid signers. */ + gpgme_invalid_key_t invalid_signers; + gpgme_new_signature_t signatures; +}; +typedef struct _gpgme_op_sign_result *gpgme_sign_result_t; + + +/* Retrieve a pointer to the result of the signing operation. */ +gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx); + +/* Sign the plaintext PLAIN and store the signature in SIG. */ +gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx, + gpgme_data_t plain, gpgme_data_t sig, + gpgme_sig_mode_t mode); +gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx, + gpgme_data_t plain, gpgme_data_t sig, + gpgme_sig_mode_t mode); + + +/* + * Verify. + */ + +/* Flags used for the SUMMARY field in a gpgme_signature_t. */ +typedef 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 occurred. */ + GPGME_SIGSUM_TOFU_CONFLICT=0x1000 /* Tofu conflict detected. */ + } +gpgme_sigsum_t; + + +/* An object to hold the verification status of a signature. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_signature +{ + struct _gpgme_signature *next; + + /* A summary of the signature status. */ + gpgme_sigsum_t summary; + + /* The fingerprint of the signature. This can be a subkey. */ + char *fpr; + + /* The status of the signature. */ + gpgme_error_t status; + + /* Notation data and policy URLs. */ + gpgme_sig_notation_t notations; + + /* Signature creation time. */ + unsigned long timestamp; + + /* Signature expiration time or 0. */ + unsigned long exp_timestamp; + + /* Key should not have been used for signing. */ + unsigned int wrong_key_usage : 1; + + /* PKA status: 0 = not available, 1 = bad, 2 = okay, 3 = RFU. */ + unsigned int pka_trust : 2; + + /* Validity has been verified using the chain model. */ + unsigned int chain_model : 1; + + /* True if the signature is in compliance to the de-vs mode. */ + unsigned int is_de_vs : 1; + + /* Internal to GPGME, do not use. */ + int _unused : 27; + + gpgme_validity_t validity; + gpgme_error_t validity_reason; + + /* The public key algorithm used to create the signature. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* The hash algorithm used to create the signature. */ + gpgme_hash_algo_t hash_algo; + + /* The mailbox from the PKA information or NULL. */ + char *pka_address; + + /* If non-NULL, a possible incomplete key object with the data + * available for the signature. */ + gpgme_key_t key; +}; +typedef struct _gpgme_signature *gpgme_signature_t; + + +/* An object to return the results of a verify operation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_verify_result +{ + gpgme_signature_t signatures; + + /* The original file name of the plaintext message, if available. + * Warning: This information is not covered by the signature. */ + char *file_name; + + /* The message claims that the content is a MIME object. */ + /* Warning: This flag is not covered by the signature. */ + unsigned int is_mime : 1; + + /* Internal to GPGME; do not use. */ + unsigned int _unused : 31; +}; +typedef struct _gpgme_op_verify_result *gpgme_verify_result_t; + + +/* Retrieve a pointer to the result of the verify operation. */ +gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx); + +/* Verify within CTX that SIG is a valid signature for TEXT. */ +gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig, + gpgme_data_t signed_text, + gpgme_data_t plaintext); +gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, + gpgme_data_t signed_text, + gpgme_data_t plaintext); + + +/* + * Import/Export + */ + +#define GPGME_IMPORT_NEW 1 /* The key was new. */ +#define GPGME_IMPORT_UID 2 /* The key contained new user IDs. */ +#define GPGME_IMPORT_SIG 4 /* The key contained new signatures. */ +#define GPGME_IMPORT_SUBKEY 8 /* The key contained new sub keys. */ +#define GPGME_IMPORT_SECRET 16 /* The key contained a secret key. */ + + +/* An object to hold results for one imported key. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_import_status +{ + struct _gpgme_import_status *next; + + /* Fingerprint. */ + char *fpr; + + /* If a problem occurred, the reason why the key could not be + imported. Otherwise GPGME_No_Error. */ + gpgme_error_t result; + + /* The result of the import, the GPGME_IMPORT_* values bit-wise + ORed. 0 means the key was already known and no new components + have been added. */ + unsigned int status; +}; +typedef struct _gpgme_import_status *gpgme_import_status_t; + + +/* Import result object. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_import_result +{ + /* Number of considered keys. */ + int considered; + + /* Keys without user ID. */ + int no_user_id; + + /* Imported keys. */ + int imported; + + /* Imported RSA keys. */ + int imported_rsa; + + /* Unchanged keys. */ + int unchanged; + + /* Number of new user ids. */ + int new_user_ids; + + /* Number of new sub keys. */ + int new_sub_keys; + + /* Number of new signatures. */ + int new_signatures; + + /* Number of new revocations. */ + int new_revocations; + + /* Number of secret keys read. */ + int secret_read; + + /* Number of secret keys imported. */ + int secret_imported; + + /* Number of secret keys unchanged. */ + int secret_unchanged; + + /* Number of new keys skipped. */ + int skipped_new_keys; + + /* Number of keys not imported. */ + int not_imported; + + /* List of keys for which an import was attempted. */ + gpgme_import_status_t imports; + + /* Number of v3 keys skipped. */ + int skipped_v3_keys; +}; +typedef struct _gpgme_op_import_result *gpgme_import_result_t; + + +/* Retrieve a pointer to the result of the import operation. */ +gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx); + +/* Import the key in KEYDATA into the keyring. */ +gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata); +gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata); + +/* Import the keys from the array KEYS into the keyring. */ +gpgme_error_t gpgme_op_import_keys_start (gpgme_ctx_t ctx, gpgme_key_t keys[]); +gpgme_error_t gpgme_op_import_keys (gpgme_ctx_t ctx, gpgme_key_t keys[]); + + +/* Export the keys found by PATTERN into KEYDATA. */ +gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern, + gpgme_export_mode_t mode, + gpgme_data_t keydata); +gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern, + gpgme_export_mode_t mode, + gpgme_data_t keydata); + +gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx, + const char *pattern[], + gpgme_export_mode_t mode, + gpgme_data_t keydata); +gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[], + gpgme_export_mode_t mode, + gpgme_data_t keydata); + +/* Export the keys from the array KEYS into KEYDATA. */ +gpgme_error_t gpgme_op_export_keys_start (gpgme_ctx_t ctx, + gpgme_key_t keys[], + gpgme_export_mode_t mode, + gpgme_data_t keydata); +gpgme_error_t gpgme_op_export_keys (gpgme_ctx_t ctx, + gpgme_key_t keys[], + gpgme_export_mode_t mode, + gpgme_data_t keydata); + + + +/* + * Key generation. + */ + +/* Flags for the key creation functions. */ +#define GPGME_CREATE_SIGN (1 << 0) /* Allow usage: signing. */ +#define GPGME_CREATE_ENCR (1 << 1) /* Allow usage: encryption. */ +#define GPGME_CREATE_CERT (1 << 2) /* Allow usage: certification. */ +#define GPGME_CREATE_AUTH (1 << 3) /* Allow usage: authentication. */ +#define GPGME_CREATE_NOPASSWD (1 << 7) /* Create w/o passphrase. */ +#define GPGME_CREATE_SELFSIGNED (1 << 8) /* Create self-signed cert. */ +#define GPGME_CREATE_NOSTORE (1 << 9) /* Do not store the key. */ +#define GPGME_CREATE_WANTPUB (1 << 10) /* Return the public key. */ +#define GPGME_CREATE_WANTSEC (1 << 11) /* Return the secret key. */ +#define GPGME_CREATE_FORCE (1 << 12) /* Force creation. */ +#define GPGME_CREATE_NOEXPIRE (1 << 13) /* Create w/o expiration. */ + + +/* An object to return result from a key generation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_genkey_result +{ + /* A primary key was generated. */ + unsigned int primary : 1; + + /* A sub key was generated. */ + unsigned int sub : 1; + + /* A user id was generated. */ + unsigned int uid : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 29; + + /* The fingerprint of the generated key. */ + char *fpr; + + /* A memory data object with the created public key. Only set when + * GPGME_CREATE_WANTPUB has been used. */ + gpgme_data_t pubkey; + + /* A memory data object with the created secret key. Only set when + * GPGME_CREATE_WANTSEC has been used. */ + gpgme_data_t seckey; +}; +typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t; + + +/* 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. */ +gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms, + gpgme_data_t pubkey, gpgme_data_t seckey); +gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms, + gpgme_data_t pubkey, gpgme_data_t seckey); + +/* Generate a key pair using the modern interface. */ +gpgme_error_t gpgme_op_createkey_start (gpgme_ctx_t ctx, + const char *userid, + const char *algo, + unsigned long reserved, + unsigned long expires, + gpgme_key_t certkey, + unsigned int flags); +gpgme_error_t gpgme_op_createkey (gpgme_ctx_t ctx, + const char *userid, + const char *algo, + unsigned long reserved, + unsigned long expires, + gpgme_key_t certkey, + unsigned int flags); +/* Add a new subkey to KEY. */ +gpgme_error_t gpgme_op_createsubkey_start (gpgme_ctx_t ctx, + gpgme_key_t key, + const char *algo, + unsigned long reserved, + unsigned long expires, + unsigned int flags); +gpgme_error_t gpgme_op_createsubkey (gpgme_ctx_t ctx, + gpgme_key_t key, + const char *algo, + unsigned long reserved, + unsigned long expires, + unsigned int flags); + +/* Add USERID to an existing KEY. */ +gpgme_error_t gpgme_op_adduid_start (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + unsigned int reserved); +gpgme_error_t gpgme_op_adduid (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + unsigned int reserved); + +/* Revoke a USERID from a KEY. */ +gpgme_error_t gpgme_op_revuid_start (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + unsigned int reserved); +gpgme_error_t gpgme_op_revuid (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + unsigned int reserved); + +/* Set a flag on the USERID of KEY. See the manual for supported flags. */ +gpgme_error_t gpgme_op_set_uid_flag_start (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + const char *name, const char *value); +gpgme_error_t gpgme_op_set_uid_flag (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + const char *name, const char *value); + + +/* Retrieve a pointer to the result of a genkey, createkey, or + * createsubkey operation. */ +gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx); + + +/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret + * keys are also deleted. */ +gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key, + int allow_secret); +gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key, + int allow_secret); + +/* Flags for the key delete functions. */ +#define GPGME_DELETE_ALLOW_SECRET (1 << 0) /* Also delete secret key. */ +#define GPGME_DELETE_FORCE (1 << 1) /* Do not ask user to confirm. */ + +gpgme_error_t gpgme_op_delete_ext_start (gpgme_ctx_t ctx, const gpgme_key_t key, + unsigned int flags); +gpgme_error_t gpgme_op_delete_ext (gpgme_ctx_t ctx, const gpgme_key_t key, + unsigned int flags); + + +/* + * Key signing interface + */ + +/* Flags for the key signing functions. */ +#define GPGME_KEYSIGN_LOCAL (1 << 7) /* Create a local signature. */ +#define GPGME_KEYSIGN_LFSEP (1 << 8) /* Indicate LF separated user ids. */ +#define GPGME_KEYSIGN_NOEXPIRE (1 << 9) /* Force no expiration. */ + + +/* Sign the USERID of KEY using the current set of signers. */ +gpgme_error_t gpgme_op_keysign_start (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + unsigned long expires, + unsigned int flags); +gpgme_error_t gpgme_op_keysign (gpgme_ctx_t ctx, + gpgme_key_t key, const char *userid, + unsigned long expires, + unsigned int flags); + + + + +/* + * Key edit interface + */ + +/* Flags to select the mode of the interact. */ +#define GPGME_INTERACT_CARD (1 << 0) /* Use --card-edit mode. */ + + +/* Edit the KEY. Send status and command requests to FNC and + output of edit commands to OUT. */ +gpgme_error_t gpgme_op_interact_start (gpgme_ctx_t ctx, + gpgme_key_t key, + unsigned int flags, + gpgme_interact_cb_t fnc, + void *fnc_value, + gpgme_data_t out); +gpgme_error_t gpgme_op_interact (gpgme_ctx_t ctx, gpgme_key_t key, + unsigned int flags, + gpgme_interact_cb_t fnc, + void *fnc_value, + gpgme_data_t out); + + +/* Set the Tofu policy of KEY to POLCIY. */ +gpgme_error_t gpgme_op_tofu_policy_start (gpgme_ctx_t ctx, + gpgme_key_t key, + gpgme_tofu_policy_t policy); +gpgme_error_t gpgme_op_tofu_policy (gpgme_ctx_t ctx, + gpgme_key_t key, + gpgme_tofu_policy_t policy); + + + + +/* + * Key listing + */ + +/* An object to return results from a key listing operation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_keylist_result +{ + unsigned int truncated : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 31; +}; +typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t; + +/* Retrieve a pointer to the result of the key listing operation. */ +gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx); + +/* Start a keylist operation within CTX, searching for keys which + * match PATTERN. If SECRET_ONLY is true, only secret keys are + * returned. */ +gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern, + int secret_only); +gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, + const char *pattern[], + int secret_only, int reserved); + +/* List the keys contained in DATA. */ +gpgme_error_t gpgme_op_keylist_from_data_start (gpgme_ctx_t ctx, + gpgme_data_t data, + int reserved); + +/* Return the next key from the keylist in R_KEY. */ +gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key); + +/* Terminate a pending keylist operation within CTX. */ +gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx); + + + +/* + * Protecting keys + */ + +/* Change the passphrase for KEY. FLAGS is reserved for future use + * and must be passed as 0. */ +gpgme_error_t gpgme_op_passwd_start (gpgme_ctx_t ctx, gpgme_key_t key, + unsigned int flags); +gpgme_error_t gpgme_op_passwd (gpgme_ctx_t ctx, gpgme_key_t key, + unsigned int flags); + + + +/* + * Trust items and operations. + */ + +/* An object to hold data of a trust item. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_trust_item +{ + /* Internal to GPGME, do not use. */ + unsigned int _refs; + + /* The key ID to which the trust item belongs. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The type of the trust item, 1 refers to a key, 2 to a user ID. */ + int type; + + /* The trust level. */ + int level; + + /* The owner trust if TYPE is 1. */ + char *owner_trust; + + /* Internal to GPGME, do not use. */ + char _owner_trust[2]; + + /* The calculated validity. */ + char *validity; + + /* Internal to GPGME, do not use. */ + char _validity[2]; + + /* The user name if TYPE is 2. */ + char *name; +}; +typedef struct _gpgme_trust_item *gpgme_trust_item_t; + +/* Start a trustlist operation within CTX, searching for trust items + which match PATTERN. */ +gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx, + const char *pattern, int max_level); + +/* Return the next trust item from the trustlist in R_ITEM. */ +gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx, + gpgme_trust_item_t *r_item); + +/* Terminate a pending trustlist operation within CTX. */ +gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx); + +/* Acquire a reference to ITEM. */ +void gpgme_trust_item_ref (gpgme_trust_item_t item); + +/* Release a reference to ITEM. If this was the last one the trust + * item is destroyed. */ +void gpgme_trust_item_unref (gpgme_trust_item_t item); + + + +/* + * Audit log + */ + +/* Return the auditlog for the current session. This may be called + after a successful or failed operation. If no audit log is + available GPG_ERR_NO_DATA is returned. */ +gpgme_error_t gpgme_op_getauditlog_start (gpgme_ctx_t ctx, gpgme_data_t output, + unsigned int flags); +gpgme_error_t gpgme_op_getauditlog (gpgme_ctx_t ctx, gpgme_data_t output, + unsigned int flags); + + + +/* + * Spawn interface + */ + +/* Flags for the spawn operations. */ +#define GPGME_SPAWN_DETACHED 1 +#define GPGME_SPAWN_ALLOW_SET_FG 2 +#define GPGME_SPAWN_SHOW_WINDOW 4 + + +/* Run the command FILE with the arguments in ARGV. Connect stdin to + * DATAIN, stdout to DATAOUT, and STDERR to DATAERR. If one the data + * streams is NULL, connect to /dev/null instead. */ +gpgme_error_t gpgme_op_spawn_start (gpgme_ctx_t ctx, + const char *file, const char *argv[], + gpgme_data_t datain, + gpgme_data_t dataout, gpgme_data_t dataerr, + unsigned int flags); +gpgme_error_t gpgme_op_spawn (gpgme_ctx_t ctx, + const char *file, const char *argv[], + gpgme_data_t datain, + gpgme_data_t dataout, gpgme_data_t dataerr, + unsigned int flags); + + +/* + * Low-level Assuan protocol access. + */ + +typedef gpgme_error_t (*gpgme_assuan_data_cb_t) + (void *opaque, const void *data, size_t datalen); + +typedef gpgme_error_t (*gpgme_assuan_inquire_cb_t) + (void *opaque, const char *name, const char *args, + gpgme_data_t *r_data); + +typedef gpgme_error_t (*gpgme_assuan_status_cb_t) + (void *opaque, const char *status, const char *args); + +/* Send the Assuan COMMAND and return results via the callbacks. + * Asynchronous variant. */ +gpgme_error_t gpgme_op_assuan_transact_start (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t stat_cb, + void *stat_cb_value); + +/* Send the Assuan COMMAND and return results via the callbacks. + * Synchronous variant. */ +gpgme_error_t gpgme_op_assuan_transact_ext (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t stat_cb, + void *stat_cb_value, + gpgme_error_t *op_err); + + +/* + * Crypto container support. + */ + +/* An object to return results from a VFS mount operation. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_vfs_mount_result +{ + char *mount_dir; +}; +typedef struct _gpgme_op_vfs_mount_result *gpgme_vfs_mount_result_t; + +gpgme_vfs_mount_result_t gpgme_op_vfs_mount_result (gpgme_ctx_t ctx); + +/* The container is automatically unmounted when the context is reset + * or destroyed. Transmission errors are returned directly, + * operational errors are returned in OP_ERR. */ +gpgme_error_t gpgme_op_vfs_mount (gpgme_ctx_t ctx, const char *container_file, + const char *mount_dir, unsigned int flags, + gpgme_error_t *op_err); + +gpgme_error_t gpgme_op_vfs_create (gpgme_ctx_t ctx, gpgme_key_t recp[], + const char *container_file, + unsigned int flags, gpgme_error_t *op_err); + + +/* + * Interface to gpgconf(1). + */ + +/* The expert level at which a configuration option or group of + * options should be displayed. See the gpgconf(1) documentation for + * more details. */ +typedef enum + { + GPGME_CONF_BASIC = 0, + GPGME_CONF_ADVANCED = 1, + GPGME_CONF_EXPERT = 2, + GPGME_CONF_INVISIBLE = 3, + GPGME_CONF_INTERNAL = 4 + } +gpgme_conf_level_t; + + +/* The data type of a configuration option argument. See the gpgconf(1) + * documentation for more details. */ +typedef enum + { + /* Basic types. */ + GPGME_CONF_NONE = 0, + GPGME_CONF_STRING = 1, + GPGME_CONF_INT32 = 2, + GPGME_CONF_UINT32 = 3, + + /* Complex types. */ + GPGME_CONF_FILENAME = 32, + GPGME_CONF_LDAP_SERVER = 33, + GPGME_CONF_KEY_FPR = 34, + GPGME_CONF_PUB_KEY = 35, + GPGME_CONF_SEC_KEY = 36, + GPGME_CONF_ALIAS_LIST = 37 + } +gpgme_conf_type_t; + +/* For now, compatibility. */ +#define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME + + +/* This represents a single argument for a configuration option. + * Which of the members of value is used depends on the ALT_TYPE. */ +typedef struct gpgme_conf_arg +{ + struct gpgme_conf_arg *next; + /* True if the option appears without an (optional) argument. */ + unsigned int no_arg; + union + { + unsigned int count; + unsigned int uint32; + int int32; + char *string; + } value; +} *gpgme_conf_arg_t; + + +/* The flags of a configuration option. See the gpgconf + * documentation for details. */ +#define GPGME_CONF_GROUP (1 << 0) +#define GPGME_CONF_OPTIONAL (1 << 1) +#define GPGME_CONF_LIST (1 << 2) +#define GPGME_CONF_RUNTIME (1 << 3) +#define GPGME_CONF_DEFAULT (1 << 4) +#define GPGME_CONF_DEFAULT_DESC (1 << 5) +#define GPGME_CONF_NO_ARG_DESC (1 << 6) +#define GPGME_CONF_NO_CHANGE (1 << 7) + + +/* The representation of a single configuration option. See the + * gpg-conf documentation for details. */ +typedef struct gpgme_conf_opt +{ + struct gpgme_conf_opt *next; + + /* The option name. */ + char *name; + + /* The flags for this option. */ + unsigned int flags; + + /* The level of this option. */ + gpgme_conf_level_t level; + + /* The localized description of this option. */ + char *description; + + /* The type and alternate type of this option. */ + gpgme_conf_type_t type; + gpgme_conf_type_t alt_type; + + /* The localized (short) name of the argument, if any. */ + char *argname; + + /* The default value. */ + gpgme_conf_arg_t default_value; + char *default_description; + + /* The default value if the option is not set. */ + gpgme_conf_arg_t no_arg_value; + char *no_arg_description; + + /* The current value if the option is set. */ + gpgme_conf_arg_t value; + + /* The new value, if any. NULL means reset to default. */ + int change_value; + gpgme_conf_arg_t new_value; + + /* Free for application use. */ + void *user_data; +} *gpgme_conf_opt_t; + + +/* The representation of a component that can be configured. See the + * gpg-conf documentation for details. */ +typedef struct gpgme_conf_comp +{ + struct gpgme_conf_comp *next; + + /* Internal to GPGME, do not use! */ + gpgme_conf_opt_t *_last_opt_p; + + /* The component name. */ + char *name; + + /* A human-readable description for the component. */ + char *description; + + /* The program name (an absolute path to the program). */ + char *program_name; + + /* A linked list of options for this component. */ + struct gpgme_conf_opt *options; +} *gpgme_conf_comp_t; + + +/* Allocate a new gpgme_conf_arg_t. If VALUE is NULL, a "no arg + * default" is prepared. If type is a string type, VALUE should point + * to the string. Else, it should point to an unsigned or signed + * integer respectively. */ +gpgme_error_t gpgme_conf_arg_new (gpgme_conf_arg_t *arg_p, + gpgme_conf_type_t type, const void *value); + +/* This also releases all chained argument structures! */ +void gpgme_conf_arg_release (gpgme_conf_arg_t arg, gpgme_conf_type_t type); + +/* Register a change for the value of OPT to ARG. If RESET is 1 (do + * not use any values but 0 or 1), ARG is ignored and the option is + * not changed (reverting a previous change). Otherwise, if ARG is + * NULL, the option is cleared or reset to its default. The change + * is done with gpgconf's --runtime option to immediately take effect. */ +gpgme_error_t gpgme_conf_opt_change (gpgme_conf_opt_t opt, int reset, + gpgme_conf_arg_t arg); + +/* Release a set of configurations. */ +void gpgme_conf_release (gpgme_conf_comp_t conf); + +/* Retrieve the current configurations. */ +gpgme_error_t gpgme_op_conf_load (gpgme_ctx_t ctx, gpgme_conf_comp_t *conf_p); + +/* Save the configuration of component comp. This function does not + follow chained components! */ +gpgme_error_t gpgme_op_conf_save (gpgme_ctx_t ctx, gpgme_conf_comp_t comp); + +/* Retrieve the configured directory. */ +gpgme_error_t gpgme_op_conf_dir(gpgme_ctx_t ctx, const char *what, + char **result); + + +/* Information about software versions. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +typedef struct _gpgme_op_query_swdb_result +{ + /* RFU */ + struct _gpgme_op_query_swdb_result *next; + + /* The name of the package (e.g. "gpgme", "gnupg") */ + char *name; + + /* The version number of the installed version. */ + char *iversion; + + /* The time the online info was created. */ + unsigned long created; + + /* The time the online info was retrieved. */ + unsigned long retrieved; + + /* This bit is set if an error occured or some of the information + * in this structure may not be set. */ + unsigned int warning : 1; + + /* An update is available. */ + unsigned int update : 1; + + /* The update is important. */ + unsigned int urgent : 1; + + /* No information at all available. */ + unsigned int noinfo : 1; + + /* The package name is not known. */ + unsigned int unknown : 1; + + /* The information here is too old. */ + unsigned int tooold : 1; + + /* Other error. */ + unsigned int error : 1; + + unsigned int _reserved : 25; + + /* The version number of the latest released version. */ + char *version; + + /* The release date of that version. */ + unsigned long reldate; + +} *gpgme_query_swdb_result_t; + + +/* Run the gpgconf --query-swdb command. */ +gpgme_error_t gpgme_op_query_swdb (gpgme_ctx_t ctx, + const char *name, const char *iversion, + unsigned int reserved); + +/* Return the result from the last query_swdb operation. */ +gpgme_query_swdb_result_t gpgme_op_query_swdb_result (gpgme_ctx_t ctx); + + + + +/* + * Various functions. + */ + +/* Set special global flags; consult the manual before use. */ +int gpgme_set_global_flag (const char *name, const char *value); + +/* Check that the library fulfills the version requirement. Note: + * This is here only for the case where a user takes a pointer from + * the old version of this function. The new version and macro for + * run-time checks are below. */ +const char *gpgme_check_version (const char *req_version); + +/* Do not call this directly; use the macro below. */ +const char *gpgme_check_version_internal (const char *req_version, + size_t offset_sig_validity); + +/* Check that the library fulfills the version requirement and check + * for struct layout mismatch involving bitfields. */ +#define gpgme_check_version(req_version) \ + gpgme_check_version_internal (req_version, \ + offsetof (struct _gpgme_signature, validity)) + +/* Return the default values for various directories. */ +const char *gpgme_get_dirinfo (const char *what); + +/* Get the information about the configured and installed engines. A + * pointer to the first engine in the statically allocated linked list + * is returned in *INFO. If an error occurs, it is returned. The + * returned data is valid until the next gpgme_set_engine_info. */ +gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info); + +/* Set the default engine info for the protocol PROTO to the file name + * FILE_NAME and the home directory HOME_DIR. */ +gpgme_error_t gpgme_set_engine_info (gpgme_protocol_t proto, + const char *file_name, + const char *home_dir); + +/* Verify that the engine implementing PROTO is installed and + * available. */ +gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto); + + +/* Reference counting for result objects. */ +void gpgme_result_ref (void *result); +void gpgme_result_unref (void *result); + +/* Return a public key algorithm string (e.g. "rsa2048"). Caller must + * free using gpgme_free. */ +char *gpgme_pubkey_algo_string (gpgme_subkey_t subkey); + +/* Return a statically allocated string with the name of the public + * key algorithm ALGO, or NULL if that name is not known. */ +const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo); + +/* Return a statically allocated string with the name of the hash + * algorithm ALGO, or NULL if that name is not known. */ +const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo); + +/* Return the addr-spec from a user id. Caller must free the result + * with gpgme_free. */ +char *gpgme_addrspec_from_uid (const char *uid); + + + +/* + * Deprecated types, constants and functions. + */ + +/* The possible stati for gpgme_op_edit. The use of that function and + * these status codes are deprecated in favor of gpgme_op_interact. */ +typedef enum + { + GPGME_STATUS_EOF = 0, + /* mkstatus processing starts here */ + GPGME_STATUS_ENTER = 1, + GPGME_STATUS_LEAVE = 2, + GPGME_STATUS_ABORT = 3, + + GPGME_STATUS_GOODSIG = 4, + GPGME_STATUS_BADSIG = 5, + GPGME_STATUS_ERRSIG = 6, + + GPGME_STATUS_BADARMOR = 7, + + GPGME_STATUS_RSA_OR_IDEA = 8, /* (legacy) */ + GPGME_STATUS_KEYEXPIRED = 9, + GPGME_STATUS_KEYREVOKED = 10, + + GPGME_STATUS_TRUST_UNDEFINED = 11, + GPGME_STATUS_TRUST_NEVER = 12, + GPGME_STATUS_TRUST_MARGINAL = 13, + GPGME_STATUS_TRUST_FULLY = 14, + GPGME_STATUS_TRUST_ULTIMATE = 15, + + GPGME_STATUS_SHM_INFO = 16, /* (legacy) */ + GPGME_STATUS_SHM_GET = 17, /* (legacy) */ + GPGME_STATUS_SHM_GET_BOOL = 18, /* (legacy) */ + GPGME_STATUS_SHM_GET_HIDDEN = 19, /* (legacy) */ + + GPGME_STATUS_NEED_PASSPHRASE = 20, + GPGME_STATUS_VALIDSIG = 21, + GPGME_STATUS_SIG_ID = 22, + GPGME_STATUS_ENC_TO = 23, + GPGME_STATUS_NODATA = 24, + GPGME_STATUS_BAD_PASSPHRASE = 25, + GPGME_STATUS_NO_PUBKEY = 26, + GPGME_STATUS_NO_SECKEY = 27, + GPGME_STATUS_NEED_PASSPHRASE_SYM = 28, + GPGME_STATUS_DECRYPTION_FAILED = 29, + GPGME_STATUS_DECRYPTION_OKAY = 30, + GPGME_STATUS_MISSING_PASSPHRASE = 31, + GPGME_STATUS_GOOD_PASSPHRASE = 32, + GPGME_STATUS_GOODMDC = 33, + GPGME_STATUS_BADMDC = 34, + GPGME_STATUS_ERRMDC = 35, + GPGME_STATUS_IMPORTED = 36, + GPGME_STATUS_IMPORT_OK = 37, + GPGME_STATUS_IMPORT_PROBLEM = 38, + GPGME_STATUS_IMPORT_RES = 39, + GPGME_STATUS_FILE_START = 40, + GPGME_STATUS_FILE_DONE = 41, + GPGME_STATUS_FILE_ERROR = 42, + + GPGME_STATUS_BEGIN_DECRYPTION = 43, + GPGME_STATUS_END_DECRYPTION = 44, + GPGME_STATUS_BEGIN_ENCRYPTION = 45, + GPGME_STATUS_END_ENCRYPTION = 46, + + GPGME_STATUS_DELETE_PROBLEM = 47, + GPGME_STATUS_GET_BOOL = 48, + GPGME_STATUS_GET_LINE = 49, + GPGME_STATUS_GET_HIDDEN = 50, + GPGME_STATUS_GOT_IT = 51, + GPGME_STATUS_PROGRESS = 52, + GPGME_STATUS_SIG_CREATED = 53, + GPGME_STATUS_SESSION_KEY = 54, + GPGME_STATUS_NOTATION_NAME = 55, + GPGME_STATUS_NOTATION_DATA = 56, + GPGME_STATUS_POLICY_URL = 57, + GPGME_STATUS_BEGIN_STREAM = 58, /* (legacy) */ + GPGME_STATUS_END_STREAM = 59, /* (legacy) */ + GPGME_STATUS_KEY_CREATED = 60, + GPGME_STATUS_USERID_HINT = 61, + GPGME_STATUS_UNEXPECTED = 62, + GPGME_STATUS_INV_RECP = 63, + GPGME_STATUS_NO_RECP = 64, + GPGME_STATUS_ALREADY_SIGNED = 65, + GPGME_STATUS_SIGEXPIRED = 66, /* (legacy) */ + GPGME_STATUS_EXPSIG = 67, + GPGME_STATUS_EXPKEYSIG = 68, + GPGME_STATUS_TRUNCATED = 69, + GPGME_STATUS_ERROR = 70, + GPGME_STATUS_NEWSIG = 71, + GPGME_STATUS_REVKEYSIG = 72, + GPGME_STATUS_SIG_SUBPACKET = 73, + GPGME_STATUS_NEED_PASSPHRASE_PIN = 74, + GPGME_STATUS_SC_OP_FAILURE = 75, + GPGME_STATUS_SC_OP_SUCCESS = 76, + GPGME_STATUS_CARDCTRL = 77, + GPGME_STATUS_BACKUP_KEY_CREATED = 78, + GPGME_STATUS_PKA_TRUST_BAD = 79, + GPGME_STATUS_PKA_TRUST_GOOD = 80, + GPGME_STATUS_PLAINTEXT = 81, + GPGME_STATUS_INV_SGNR = 82, + GPGME_STATUS_NO_SGNR = 83, + GPGME_STATUS_SUCCESS = 84, + GPGME_STATUS_DECRYPTION_INFO = 85, + GPGME_STATUS_PLAINTEXT_LENGTH = 86, + GPGME_STATUS_MOUNTPOINT = 87, + GPGME_STATUS_PINENTRY_LAUNCHED = 88, + GPGME_STATUS_ATTRIBUTE = 89, + GPGME_STATUS_BEGIN_SIGNING = 90, + GPGME_STATUS_KEY_NOT_CREATED = 91, + GPGME_STATUS_INQUIRE_MAXLEN = 92, + GPGME_STATUS_FAILURE = 93, + GPGME_STATUS_KEY_CONSIDERED = 94, + GPGME_STATUS_TOFU_USER = 95, + GPGME_STATUS_TOFU_STATS = 96, + GPGME_STATUS_TOFU_STATS_LONG = 97, + GPGME_STATUS_NOTATION_FLAGS = 98, + GPGME_STATUS_DECRYPTION_COMPLIANCE_MODE = 99, + GPGME_STATUS_VERIFICATION_COMPLIANCE_MODE = 100 + } +gpgme_status_code_t; + +/* The callback type used by the deprecated functions gpgme_op_edit + * and gpgme_op_card_edit. */ +typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque, + gpgme_status_code_t status, + const char *args, int fd); + +gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out) _GPGME_DEPRECATED(1,7); +gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out) _GPGME_DEPRECATED(1,7); +gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out) + _GPGME_DEPRECATED(1,7); +gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out) + _GPGME_DEPRECATED(1,7); + +/* The possible signature stati. Deprecated, use error value in sig + * status. */ +typedef enum + { + GPGME_SIG_STAT_NONE = 0, + GPGME_SIG_STAT_GOOD = 1, + GPGME_SIG_STAT_BAD = 2, + GPGME_SIG_STAT_NOKEY = 3, + GPGME_SIG_STAT_NOSIG = 4, + GPGME_SIG_STAT_ERROR = 5, + GPGME_SIG_STAT_DIFF = 6, + GPGME_SIG_STAT_GOOD_EXP = 7, + GPGME_SIG_STAT_GOOD_EXPKEY = 8 + } +_gpgme_sig_stat_t; +typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED(0,4); + +/* The available key and signature attributes. Deprecated, use the + * individual result structures instead. */ +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, + GPGME_ATTR_KEY_DISABLED = 25, + GPGME_ATTR_SERIAL = 26, + GPGME_ATTR_ISSUER = 27, + GPGME_ATTR_CHAINID = 28, + GPGME_ATTR_SIG_STATUS = 29, + GPGME_ATTR_ERRTOK = 30, + GPGME_ATTR_SIG_SUMMARY = 31, + GPGME_ATTR_SIG_CLASS = 32 + } +_gpgme_attr_t; +typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED(0,4); + +/* 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. + * Deprecated, use verify result directly. */ +const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx, + _gpgme_sig_stat_t *r_stat, + time_t *r_created) _GPGME_DEPRECATED(0,4); + +/* 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 c, int idx, + _gpgme_attr_t what, int whatidx) + _GPGME_DEPRECATED(0,4); +const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx, + _gpgme_attr_t what, int whatidx) + _GPGME_DEPRECATED(0,4); + + +/* 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_DEPRECATED(0,4); + +/* Create a new data buffer which retrieves the data from the callback + * function READ_CB. Deprecated, please use gpgme_data_new_from_cbs + * instead. */ +gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh, + int (*read_cb) (void*,char *, + size_t,size_t*), + void *read_cb_value) + _GPGME_DEPRECATED(0,4); + +/* Return the value of the attribute WHAT of KEY, which has to be + * representable by a string. IDX specifies the sub key or user ID + * for attributes related to sub keys or user IDs. Deprecated, use + * key structure directly instead. */ +const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED(0,4); + +/* Return the value of the attribute WHAT of KEY, which has to be + * representable by an unsigned integer. IDX specifies the sub key or + * user ID for attributes related to sub keys or user IDs. + * Deprecated, use key structure directly instead. */ +unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED(0,4); + +/* Return the value of the attribute WHAT of a signature on user ID + * UID_IDX in KEY, which has to be representable by a string. IDX + * specifies the signature. Deprecated, use key structure directly + * instead. */ +const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx, + _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED(0,4); + +/* Return the value of the attribute WHAT of a signature on user ID + * UID_IDX in KEY, which has to be representable by an unsigned + * integer string. IDX specifies the signature. Deprecated, use key + * structure directly instead. */ +unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx, + _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED(0,4); + + +gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata, + int *nr) _GPGME_DEPRECATED(0,4); + +/* Release the trust item ITEM. Deprecated, use + * gpgme_trust_item_unref. */ +void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED(0,4); + +/* Return the value of the attribute WHAT of ITEM, which has to be + * representable by a string. Deprecated, use trust item structure + * directly. */ +const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item, + _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED(0,4); + +/* 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. Deprecated, use trust + * item structure directly. */ +int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED(0,4); + +/* Compat. + * This structure shall be considered read-only and an application + * must not allocate such a structure on its own. */ +struct _gpgme_op_assuan_result +{ + /* Deprecated. Use the second value in a DONE event or the + synchronous variant gpgme_op_assuan_transact_ext. */ + gpgme_error_t err _GPGME_DEPRECATED_OUTSIDE_GPGME(1,2); +}; +typedef struct _gpgme_op_assuan_result *gpgme_assuan_result_t; + + +/* Return the result of the last Assuan command. */ +gpgme_assuan_result_t gpgme_op_assuan_result (gpgme_ctx_t ctx) + _GPGME_DEPRECATED(1,2); + +gpgme_error_t +gpgme_op_assuan_transact (gpgme_ctx_t ctx, + const char *command, + gpgme_assuan_data_cb_t data_cb, + void *data_cb_value, + gpgme_assuan_inquire_cb_t inq_cb, + void *inq_cb_value, + gpgme_assuan_status_cb_t status_cb, + void *status_cb_value) _GPGME_DEPRECATED(1,2); + + + +typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED(0,4); +typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED(0,4); +typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED(0,4); +typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED(0,4); +typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED(0,4); +typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED(0,4); +typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED(0,4); +typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED(0,4); +typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED(0,4); +typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED(0,4); +typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED(0,4); +typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED(0,4); +typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED(0,4); +typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED(0,4); +typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED(0,4); +typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED(0,4); +typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED(0,4); +typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED(0,4); +typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED(0,4); +typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED(0,4); +typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED(0,4); +typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED(0,4); +typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED(0,4); +#define GpgmeIOCbs gpgme_io_cbs +typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED(0,4); +typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED(0,4); +typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED(0,4); +typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED(0,4); +#define GpgmeDataCbs gpgme_data_cbs +typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED(0,4); +typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED(0,4); +typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED(0,4); +typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED(0,4); +typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED(0,4); +typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED(0,4); +typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED(0,4); +typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED(0,4); +typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED(0,4); + +#ifdef __cplusplus +} +#endif +#endif /* GPGME_H */ +/* +Local Variables: +buffer-read-only: t +End: +*/ diff --git a/gpg/include/ksba.h b/gpg/include/ksba.h new file mode 100644 index 0000000..955dc06 --- /dev/null +++ b/gpg/include/ksba.h @@ -0,0 +1,553 @@ +/* ksba.h - X.509 library used by GnuPG + * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011 + * 2012, 2013, 2104, 2015 g10 Code GmbH + * + * This file is part of KSBA. + * + * KSBA is free software; you can redistribute it and/or modify + * it under the terms of either + * + * - the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * or + * + * - 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. + * + * or both in parallel, as here. + * + * KSBA 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 copies of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, see . + */ + +#ifndef KSBA_H +#define KSBA_H 1 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#if 0 + } +#endif +#endif + + +/* Check for compiler features. */ +#ifdef __GNUC__ +#define _KSBA_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#if _KSBA_GCC_VERSION > 30100 +#define _KSBA_DEPRECATED __attribute__ ((__deprecated__)) +#endif +#endif /*__GNUC__*/ + +#ifndef _KSBA_DEPRECATED +#define _KSBA_DEPRECATED +#endif + + +typedef gpg_error_t KsbaError _KSBA_DEPRECATED; + +typedef enum + { + KSBA_CT_NONE = 0, + KSBA_CT_DATA = 1, + KSBA_CT_SIGNED_DATA = 2, + KSBA_CT_ENVELOPED_DATA = 3, + KSBA_CT_DIGESTED_DATA = 4, + KSBA_CT_ENCRYPTED_DATA = 5, + KSBA_CT_AUTH_DATA = 6, + KSBA_CT_PKCS12 = 7 + } +ksba_content_type_t; +typedef ksba_content_type_t KsbaContentType _KSBA_DEPRECATED; + + + +typedef enum + { + KSBA_SR_NONE = 0, /* Never seen by libksba user. */ + KSBA_SR_RUNNING = 1, /* Never seen by libksba user. */ + KSBA_SR_GOT_CONTENT = 2, + KSBA_SR_NEED_HASH = 3, + KSBA_SR_BEGIN_DATA = 4, + KSBA_SR_END_DATA = 5, + KSBA_SR_READY = 6, + KSBA_SR_NEED_SIG = 7, + KSBA_SR_DETACHED_DATA = 8, + KSBA_SR_BEGIN_ITEMS = 9, + KSBA_SR_GOT_ITEM = 10, + KSBA_SR_END_ITEMS = 11 + } +ksba_stop_reason_t; +typedef ksba_stop_reason_t KsbaStopReason _KSBA_DEPRECATED; + +typedef enum + { + KSBA_CRLREASON_UNSPECIFIED = 1, + KSBA_CRLREASON_KEY_COMPROMISE = 2, + KSBA_CRLREASON_CA_COMPROMISE = 4, + KSBA_CRLREASON_AFFILIATION_CHANGED = 8, + KSBA_CRLREASON_SUPERSEDED = 16, + KSBA_CRLREASON_CESSATION_OF_OPERATION = 32, + KSBA_CRLREASON_CERTIFICATE_HOLD = 64, + KSBA_CRLREASON_REMOVE_FROM_CRL = 256, + KSBA_CRLREASON_PRIVILEGE_WITHDRAWN = 512, + KSBA_CRLREASON_AA_COMPROMISE = 1024, + KSBA_CRLREASON_OTHER = 32768 + } +ksba_crl_reason_t; +typedef ksba_crl_reason_t KsbaCRLReason _KSBA_DEPRECATED; + +typedef enum + { + KSBA_OCSP_RSPSTATUS_SUCCESS = 0, + KSBA_OCSP_RSPSTATUS_MALFORMED = 1, + KSBA_OCSP_RSPSTATUS_INTERNAL = 2, + KSBA_OCSP_RSPSTATUS_TRYLATER = 3, + KSBA_OCSP_RSPSTATUS_SIGREQUIRED = 5, + KSBA_OCSP_RSPSTATUS_UNAUTHORIZED = 6, + KSBA_OCSP_RSPSTATUS_REPLAYED = 253, + KSBA_OCSP_RSPSTATUS_OTHER = 254, + KSBA_OCSP_RSPSTATUS_NONE = 255 + } +ksba_ocsp_response_status_t; + +typedef enum + { + KSBA_STATUS_NONE = 0, + KSBA_STATUS_UNKNOWN = 1, + KSBA_STATUS_GOOD = 2, + KSBA_STATUS_REVOKED = 4 + } +ksba_status_t; + + +typedef enum + { + KSBA_KEYUSAGE_DIGITAL_SIGNATURE = 1, + KSBA_KEYUSAGE_NON_REPUDIATION = 2, + KSBA_KEYUSAGE_KEY_ENCIPHERMENT = 4, + KSBA_KEYUSAGE_DATA_ENCIPHERMENT = 8, + KSBA_KEYUSAGE_KEY_AGREEMENT = 16, + KSBA_KEYUSAGE_KEY_CERT_SIGN = 32, + KSBA_KEYUSAGE_CRL_SIGN = 64, + KSBA_KEYUSAGE_ENCIPHER_ONLY = 128, + KSBA_KEYUSAGE_DECIPHER_ONLY = 256 + } +ksba_key_usage_t; +typedef ksba_key_usage_t KsbaKeyUsage _KSBA_DEPRECATED; + +/* ISO format, e.g. "19610711T172059", assumed to be UTC. */ +typedef char ksba_isotime_t[16]; + + +/* X.509 certificates are represented by this object. + ksba_cert_new() creates such an object */ +struct ksba_cert_s; +typedef struct ksba_cert_s *ksba_cert_t; +typedef struct ksba_cert_s *KsbaCert _KSBA_DEPRECATED; + +/* CMS objects are controlled by this object. + ksba_cms_new() creates it */ +struct ksba_cms_s; +typedef struct ksba_cms_s *ksba_cms_t; +typedef struct ksba_cms_s *KsbaCMS _KSBA_DEPRECATED; + +/* CRL objects are controlled by this object. + ksba_crl_new() creates it */ +struct ksba_crl_s; +typedef struct ksba_crl_s *ksba_crl_t; +typedef struct ksba_crl_s *KsbaCRL _KSBA_DEPRECATED; + +/* OCSP objects are controlled by this object. + ksba_ocsp_new() creates it. */ +struct ksba_ocsp_s; +typedef struct ksba_ocsp_s *ksba_ocsp_t; + +/* PKCS-10 creation is controlled by this object. + ksba_certreq_new() creates it */ +struct ksba_certreq_s; +typedef struct ksba_certreq_s *ksba_certreq_t; +typedef struct ksba_certreq_s *KsbaCertreq _KSBA_DEPRECATED; + +/* This is a reader object for various purposes + see ksba_reader_new et al. */ +struct ksba_reader_s; +typedef struct ksba_reader_s *ksba_reader_t; +typedef struct ksba_reader_s *KsbaReader _KSBA_DEPRECATED; + +/* This is a writer object for various purposes + see ksba_writer_new et al. */ +struct ksba_writer_s; +typedef struct ksba_writer_s *ksba_writer_t; +typedef struct ksba_writer_s *KsbaWriter _KSBA_DEPRECATED; + +/* This is an object to store an ASN.1 parse tree as + create by ksba_asn_parse_file() */ +struct ksba_asn_tree_s; +typedef struct ksba_asn_tree_s *ksba_asn_tree_t; +typedef struct ksba_asn_tree_s *KsbaAsnTree _KSBA_DEPRECATED; + +/* This is an object to reference a General Name. Such an object is + returned by several functions. */ +struct ksba_name_s; +typedef struct ksba_name_s *ksba_name_t; +typedef struct ksba_name_s *KsbaName _KSBA_DEPRECATED; + +/* KsbaSexp is just an unsigned char * which should be used for + documentation purpose. The S-expressions returned by libksba are + always in canonical representation with an extra 0 byte at the end, + so that one can print the values in the debugger and at least see + the first bytes */ +typedef unsigned char *ksba_sexp_t; +typedef unsigned char *KsbaSexp _KSBA_DEPRECATED; +typedef const unsigned char *ksba_const_sexp_t; +typedef const unsigned char *KsbaConstSexp _KSBA_DEPRECATED; + + +/*-- cert.c --*/ +gpg_error_t ksba_cert_new (ksba_cert_t *acert); +void ksba_cert_ref (ksba_cert_t cert); +void ksba_cert_release (ksba_cert_t cert); +gpg_error_t ksba_cert_set_user_data (ksba_cert_t cert, const char *key, + const void *data, size_t datalen); +gpg_error_t ksba_cert_get_user_data (ksba_cert_t cert, const char *key, + void *buffer, size_t bufferlen, + size_t *datalen); + +gpg_error_t ksba_cert_read_der (ksba_cert_t cert, ksba_reader_t reader); +gpg_error_t ksba_cert_init_from_mem (ksba_cert_t cert, + const void *buffer, size_t length); +const unsigned char *ksba_cert_get_image (ksba_cert_t cert, size_t *r_length); +gpg_error_t ksba_cert_hash (ksba_cert_t cert, + int what, + void (*hasher)(void *, + const void *, + size_t length), + void *hasher_arg); +const char *ksba_cert_get_digest_algo (ksba_cert_t cert); +ksba_sexp_t ksba_cert_get_serial (ksba_cert_t cert); +char *ksba_cert_get_issuer (ksba_cert_t cert, int idx); +gpg_error_t ksba_cert_get_validity (ksba_cert_t cert, int what, + ksba_isotime_t r_time); +char *ksba_cert_get_subject (ksba_cert_t cert, int idx); +ksba_sexp_t ksba_cert_get_public_key (ksba_cert_t cert); +ksba_sexp_t ksba_cert_get_sig_val (ksba_cert_t cert); + +gpg_error_t ksba_cert_get_extension (ksba_cert_t cert, int idx, + char const **r_oid, int *r_crit, + size_t *r_deroff, size_t *r_derlen); + +gpg_error_t ksba_cert_is_ca (ksba_cert_t cert, int *r_ca, int *r_pathlen); +gpg_error_t ksba_cert_get_key_usage (ksba_cert_t cert, unsigned int *r_flags); +gpg_error_t ksba_cert_get_cert_policies (ksba_cert_t cert, char **r_policies); +gpg_error_t ksba_cert_get_ext_key_usages (ksba_cert_t cert, char **result); +gpg_error_t ksba_cert_get_crl_dist_point (ksba_cert_t cert, int idx, + ksba_name_t *r_distpoint, + ksba_name_t *r_issuer, + ksba_crl_reason_t *r_reason); +gpg_error_t ksba_cert_get_auth_key_id (ksba_cert_t cert, + ksba_sexp_t *r_keyid, + ksba_name_t *r_name, + ksba_sexp_t *r_serial); +gpg_error_t ksba_cert_get_subj_key_id (ksba_cert_t cert, + int *r_crit, + ksba_sexp_t *r_keyid); +gpg_error_t ksba_cert_get_authority_info_access (ksba_cert_t cert, int idx, + char **r_method, + ksba_name_t *r_location); +gpg_error_t ksba_cert_get_subject_info_access (ksba_cert_t cert, int idx, + char **r_method, + ksba_name_t *r_location); + + +/*-- cms.c --*/ +ksba_content_type_t ksba_cms_identify (ksba_reader_t reader); + +gpg_error_t ksba_cms_new (ksba_cms_t *r_cms); +void ksba_cms_release (ksba_cms_t cms); +gpg_error_t ksba_cms_set_reader_writer (ksba_cms_t cms, + ksba_reader_t r, ksba_writer_t w); + +gpg_error_t ksba_cms_parse (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason); +gpg_error_t ksba_cms_build (ksba_cms_t cms, ksba_stop_reason_t *r_stopreason); + +ksba_content_type_t ksba_cms_get_content_type (ksba_cms_t cms, int what); +const char *ksba_cms_get_content_oid (ksba_cms_t cms, int what); +gpg_error_t ksba_cms_get_content_enc_iv (ksba_cms_t cms, void *iv, + size_t maxivlen, size_t *ivlen); +const char *ksba_cms_get_digest_algo_list (ksba_cms_t cms, int idx); +gpg_error_t ksba_cms_get_issuer_serial (ksba_cms_t cms, int idx, + char **r_issuer, + ksba_sexp_t *r_serial); +const char *ksba_cms_get_digest_algo (ksba_cms_t cms, int idx); +ksba_cert_t ksba_cms_get_cert (ksba_cms_t cms, int idx); +gpg_error_t ksba_cms_get_message_digest (ksba_cms_t cms, int idx, + char **r_digest, size_t *r_digest_len); +gpg_error_t ksba_cms_get_signing_time (ksba_cms_t cms, int idx, + ksba_isotime_t r_sigtime); +gpg_error_t ksba_cms_get_sigattr_oids (ksba_cms_t cms, int idx, + const char *reqoid, char **r_value); +ksba_sexp_t ksba_cms_get_sig_val (ksba_cms_t cms, int idx); +ksba_sexp_t ksba_cms_get_enc_val (ksba_cms_t cms, int idx); + +void ksba_cms_set_hash_function (ksba_cms_t cms, + void (*hash_fnc)(void *, const void *, size_t), + void *hash_fnc_arg); + +gpg_error_t ksba_cms_hash_signed_attrs (ksba_cms_t cms, int idx); + + +gpg_error_t ksba_cms_set_content_type (ksba_cms_t cms, int what, + ksba_content_type_t type); +gpg_error_t ksba_cms_add_digest_algo (ksba_cms_t cms, const char *oid); +gpg_error_t ksba_cms_add_signer (ksba_cms_t cms, ksba_cert_t cert); +gpg_error_t ksba_cms_add_cert (ksba_cms_t cms, ksba_cert_t cert); +gpg_error_t ksba_cms_add_smime_capability (ksba_cms_t cms, const char *oid, + const unsigned char *der, + size_t derlen); +gpg_error_t ksba_cms_set_message_digest (ksba_cms_t cms, int idx, + const unsigned char *digest, + size_t digest_len); +gpg_error_t ksba_cms_set_signing_time (ksba_cms_t cms, int idx, + const ksba_isotime_t sigtime); +gpg_error_t ksba_cms_set_sig_val (ksba_cms_t cms, + int idx, ksba_const_sexp_t sigval); + +gpg_error_t ksba_cms_set_content_enc_algo (ksba_cms_t cms, + const char *oid, + const void *iv, + size_t ivlen); +gpg_error_t ksba_cms_add_recipient (ksba_cms_t cms, ksba_cert_t cert); +gpg_error_t ksba_cms_set_enc_val (ksba_cms_t cms, + int idx, ksba_const_sexp_t encval); + + +/*-- crl.c --*/ +gpg_error_t ksba_crl_new (ksba_crl_t *r_crl); +void ksba_crl_release (ksba_crl_t crl); +gpg_error_t ksba_crl_set_reader (ksba_crl_t crl, ksba_reader_t r); +void ksba_crl_set_hash_function (ksba_crl_t crl, + void (*hash_fnc)(void *, + const void *, size_t), + void *hash_fnc_arg); +const char *ksba_crl_get_digest_algo (ksba_crl_t crl); +gpg_error_t ksba_crl_get_issuer (ksba_crl_t crl, char **r_issuer); +gpg_error_t ksba_crl_get_extension (ksba_crl_t crl, int idx, + char const **oid, int *critical, + unsigned char const **der, size_t *derlen); +gpg_error_t ksba_crl_get_auth_key_id (ksba_crl_t crl, + ksba_sexp_t *r_keyid, + ksba_name_t *r_name, + ksba_sexp_t *r_serial); +gpg_error_t ksba_crl_get_crl_number (ksba_crl_t crl, ksba_sexp_t *number); +gpg_error_t ksba_crl_get_update_times (ksba_crl_t crl, + ksba_isotime_t this_update, + ksba_isotime_t next_update); +gpg_error_t ksba_crl_get_item (ksba_crl_t crl, + ksba_sexp_t *r_serial, + ksba_isotime_t r_revocation_date, + ksba_crl_reason_t *r_reason); +ksba_sexp_t ksba_crl_get_sig_val (ksba_crl_t crl); +gpg_error_t ksba_crl_parse (ksba_crl_t crl, ksba_stop_reason_t *r_stopreason); + + + +/*-- ocsp.c --*/ +gpg_error_t ksba_ocsp_new (ksba_ocsp_t *r_oscp); +void ksba_ocsp_release (ksba_ocsp_t ocsp); +gpg_error_t ksba_ocsp_set_digest_algo (ksba_ocsp_t ocsp, const char *oid); +gpg_error_t ksba_ocsp_set_requestor (ksba_ocsp_t ocsp, ksba_cert_t cert); +gpg_error_t ksba_ocsp_add_target (ksba_ocsp_t ocsp, + ksba_cert_t cert, ksba_cert_t issuer_cert); +size_t ksba_ocsp_set_nonce (ksba_ocsp_t ocsp, + unsigned char *nonce, size_t noncelen); + +gpg_error_t ksba_ocsp_prepare_request (ksba_ocsp_t ocsp); +gpg_error_t ksba_ocsp_hash_request (ksba_ocsp_t ocsp, + void (*hasher)(void *, const void *, + size_t length), + void *hasher_arg); +gpg_error_t ksba_ocsp_set_sig_val (ksba_ocsp_t ocsp, + ksba_const_sexp_t sigval); +gpg_error_t ksba_ocsp_add_cert (ksba_ocsp_t ocsp, ksba_cert_t cert); +gpg_error_t ksba_ocsp_build_request (ksba_ocsp_t ocsp, + unsigned char **r_buffer, + size_t *r_buflen); + +gpg_error_t ksba_ocsp_parse_response (ksba_ocsp_t ocsp, + const unsigned char *msg, size_t msglen, + ksba_ocsp_response_status_t *resp_status); + +const char *ksba_ocsp_get_digest_algo (ksba_ocsp_t ocsp); +gpg_error_t ksba_ocsp_hash_response (ksba_ocsp_t ocsp, + const unsigned char *msg, size_t msglen, + void (*hasher)(void *, const void *, + size_t length), + void *hasher_arg); +ksba_sexp_t ksba_ocsp_get_sig_val (ksba_ocsp_t ocsp, + ksba_isotime_t produced_at); +gpg_error_t ksba_ocsp_get_responder_id (ksba_ocsp_t ocsp, + char **r_name, + ksba_sexp_t *r_keyid); +ksba_cert_t ksba_ocsp_get_cert (ksba_ocsp_t ocsp, int idx); +gpg_error_t ksba_ocsp_get_status (ksba_ocsp_t ocsp, ksba_cert_t cert, + ksba_status_t *r_status, + ksba_isotime_t r_this_update, + ksba_isotime_t r_next_update, + ksba_isotime_t r_revocation_time, + ksba_crl_reason_t *r_reason); +gpg_error_t ksba_ocsp_get_extension (ksba_ocsp_t ocsp, ksba_cert_t cert, + int idx, + char const **r_oid, int *r_crit, + unsigned char const **r_der, + size_t *r_derlen); + + +/*-- certreq.c --*/ +gpg_error_t ksba_certreq_new (ksba_certreq_t *r_cr); +void ksba_certreq_release (ksba_certreq_t cr); +gpg_error_t ksba_certreq_set_writer (ksba_certreq_t cr, ksba_writer_t w); +void ksba_certreq_set_hash_function ( + ksba_certreq_t cr, + void (*hash_fnc)(void *, const void *, size_t), + void *hash_fnc_arg); +gpg_error_t ksba_certreq_add_subject (ksba_certreq_t cr, const char *name); +gpg_error_t ksba_certreq_set_public_key (ksba_certreq_t cr, + ksba_const_sexp_t key); +gpg_error_t ksba_certreq_add_extension (ksba_certreq_t cr, + const char *oid, int is_crit, + const void *der, + size_t derlen); +gpg_error_t ksba_certreq_set_sig_val (ksba_certreq_t cr, + ksba_const_sexp_t sigval); +gpg_error_t ksba_certreq_build (ksba_certreq_t cr, + ksba_stop_reason_t *r_stopreason); + +/* The functions below are used to switch to X.509 certificate creation. */ +gpg_error_t ksba_certreq_set_serial (ksba_certreq_t cr, ksba_const_sexp_t sn); +gpg_error_t ksba_certreq_set_issuer (ksba_certreq_t cr, const char *name); +gpg_error_t ksba_certreq_set_validity (ksba_certreq_t cr, int what, + const ksba_isotime_t timebuf); +gpg_error_t ksba_certreq_set_siginfo (ksba_certreq_t cr, + ksba_const_sexp_t siginfo); + + + +/*-- reader.c --*/ +gpg_error_t ksba_reader_new (ksba_reader_t *r_r); +void ksba_reader_release (ksba_reader_t r); +gpg_error_t ksba_reader_set_release_notify (ksba_reader_t r, + void (*notify)(void*,ksba_reader_t), + void *notify_value); +gpg_error_t ksba_reader_clear (ksba_reader_t r, + unsigned char **buffer, size_t *buflen); +gpg_error_t ksba_reader_error (ksba_reader_t r); + +gpg_error_t ksba_reader_set_mem (ksba_reader_t r, + const void *buffer, size_t length); +gpg_error_t ksba_reader_set_fd (ksba_reader_t r, int fd); +gpg_error_t ksba_reader_set_file (ksba_reader_t r, FILE *fp); +gpg_error_t ksba_reader_set_cb (ksba_reader_t r, + int (*cb)(void*,char *,size_t,size_t*), + void *cb_value ); + +gpg_error_t ksba_reader_read (ksba_reader_t r, + char *buffer, size_t length, size_t *nread); +gpg_error_t ksba_reader_unread (ksba_reader_t r, const void *buffer, size_t count); +unsigned long ksba_reader_tell (ksba_reader_t r); + +/*-- writer.c --*/ +gpg_error_t ksba_writer_new (ksba_writer_t *r_w); +void ksba_writer_release (ksba_writer_t w); +gpg_error_t ksba_writer_set_release_notify (ksba_writer_t w, + void (*notify)(void*,ksba_writer_t), + void *notify_value); +int ksba_writer_error (ksba_writer_t w); +unsigned long ksba_writer_tell (ksba_writer_t w); +gpg_error_t ksba_writer_set_fd (ksba_writer_t w, int fd); +gpg_error_t ksba_writer_set_file (ksba_writer_t w, FILE *fp); +gpg_error_t ksba_writer_set_cb (ksba_writer_t w, + int (*cb)(void*,const void *,size_t), + void *cb_value); +gpg_error_t ksba_writer_set_mem (ksba_writer_t w, size_t initial_size); +const void *ksba_writer_get_mem (ksba_writer_t w, size_t *nbytes); +void * ksba_writer_snatch_mem (ksba_writer_t w, size_t *nbytes); +gpg_error_t ksba_writer_set_filter (ksba_writer_t w, + gpg_error_t (*filter)(void*, + const void *,size_t, size_t *, + void *, size_t, size_t *), + void *filter_arg); + +gpg_error_t ksba_writer_write (ksba_writer_t w, const void *buffer, size_t length); +gpg_error_t ksba_writer_write_octet_string (ksba_writer_t w, + const void *buffer, size_t length, + int flush); + +/*-- asn1-parse.y --*/ +int ksba_asn_parse_file (const char *filename, ksba_asn_tree_t *result, + int debug); +void ksba_asn_tree_release (ksba_asn_tree_t tree); + +/*-- asn1-func.c --*/ +void ksba_asn_tree_dump (ksba_asn_tree_t tree, const char *name, FILE *fp); +gpg_error_t ksba_asn_create_tree (const char *mod_name, ksba_asn_tree_t *result); + +/*-- oid.c --*/ +char *ksba_oid_to_str (const char *buffer, size_t length); +gpg_error_t ksba_oid_from_str (const char *string, + unsigned char **rbuf, size_t *rlength); + +/*-- dn.c --*/ +gpg_error_t ksba_dn_der2str (const void *der, size_t derlen, char **r_string); +gpg_error_t ksba_dn_str2der (const char *string, + unsigned char **rder, size_t *rderlen); +gpg_error_t ksba_dn_teststr (const char *string, int seq, + size_t *rerroff, size_t *rerrlen); + + +/*-- name.c --*/ +gpg_error_t ksba_name_new (ksba_name_t *r_name); +void ksba_name_ref (ksba_name_t name); +void ksba_name_release (ksba_name_t name); +const char *ksba_name_enum (ksba_name_t name, int idx); +char *ksba_name_get_uri (ksba_name_t name, int idx); + + +/*-- util.c --*/ +void ksba_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), + void *(*new_realloc_func)(void *p, size_t n), + void (*new_free_func)(void*) ); +void ksba_set_hash_buffer_function ( gpg_error_t (*fnc) + (void *arg, const char *oid, + const void *buffer, size_t length, + size_t resultsize, + unsigned char *result, + size_t *resultlen), + void *fnc_arg); +void *ksba_malloc (size_t n ); +void *ksba_calloc (size_t n, size_t m ); +void *ksba_realloc (void *p, size_t n); +char *ksba_strdup (const char *p); +void ksba_free ( void *a ); + +/*--version.c --*/ +const char *ksba_check_version (const char *req_version); + +#ifdef __cplusplus +} +#endif +#endif /*KSBA_H*/ diff --git a/gpg/include/npth.h b/gpg/include/npth.h new file mode 100644 index 0000000..008001b --- /dev/null +++ b/gpg/include/npth.h @@ -0,0 +1,238 @@ +/* npth.h - a lightweight implementation of pth over native threads + * Copyright (C) 2011, 2015 g10 Code GmbH + * + * This file is part of nPth. + * + * nPth 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. + * + * nPth 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, see . + */ + +#ifndef _NPTH_H +#define _NPTH_H + +#include +#include +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#if 0 /* (Keep Emacsens' auto-indent happy.) */ +} +#endif +#endif + +struct msghdr; + +/* The mingw-w64 headers define timespec. For older compilers we keep + our replacement. */ +#ifndef __MINGW64_VERSION_MAJOR +struct timespec { + long tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +#endif /*__MINGW64_VERSION_MAJOR */ + + +#ifndef ETIMEDOUT +#define ETIMEDOUT 10060 /* This is WSAETIMEDOUT. */ +#endif +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 10045 /* This is WSAEOPNOTSUPP. */ +#endif + + +int npth_init (void); + +typedef struct npth_attr_s *npth_attr_t; +typedef unsigned long int npth_t; +typedef struct npth_mutexattr_s *npth_mutexattr_t; +typedef struct npth_mutex_s *npth_mutex_t; +typedef struct npth_rwlockattr_s *npth_rwlockattr_t; +typedef struct npth_rwlock_s *npth_rwlock_t; +typedef struct npth_condattr_s *npth_condattr_t; +typedef struct npth_cond_s *npth_cond_t; + +int npth_attr_init (npth_attr_t *attr); +int npth_attr_destroy (npth_attr_t *attr); +#define NPTH_CREATE_JOINABLE 0 +#define NPTH_CREATE_DETACHED 1 +int npth_attr_getdetachstate(npth_attr_t *attr, int *detachstate); +int npth_attr_setdetachstate(npth_attr_t *attr, int detachstate); +int npth_getname_np (npth_t target_thread, char *buf, size_t buflen); +int npth_setname_np (npth_t target_thread, const char *name); + +int npth_create (npth_t *newthread, const npth_attr_t *attr, + void *(*start_routine) (void *), void *arg); + +npth_t npth_self (void); + +int npth_join (npth_t th, void **thread_return); +int npth_detach (npth_t th); +void npth_exit (void *retval); + +typedef DWORD npth_key_t; +int npth_key_create (npth_key_t *key, + void (*destr_function) (void *)); +int npth_key_delete (npth_key_t key); +void *npth_getspecific (npth_key_t key); +int npth_setspecific (npth_key_t key, const void *pointer); + +int npth_mutexattr_init (npth_mutexattr_t *attr); +int npth_mutexattr_destroy (npth_mutexattr_t *attr); +int npth_mutexattr_gettype (const npth_mutexattr_t *attr, + int *kind); +int npth_mutexattr_settype (npth_mutexattr_t *attr, int kind); +#define NPTH_MUTEX_NORMAL 0 +#define NPTH_MUTEX_RECURSIVE 1 +#define NPTH_MUTEX_ERRORCHECK 2 +#define NPTH_MUTEX_DEFAULT NPTH_MUTEX_NORMAL + +#define NPTH_MUTEX_INITIALIZER ((npth_mutex_t) -1) +#define NPTH_RECURSIVE_MUTEX_INITIALIZER_NP ((npth_mutex_t) -2) +#define NPTH_ERRORCHECK_MUTEX_INITIALIZER_NP ((npth_mutex_t) -3) +int npth_mutex_init (npth_mutex_t *mutex, const npth_mutexattr_t *mutexattr); +int npth_mutex_destroy (npth_mutex_t *mutex); +int npth_mutex_trylock(npth_mutex_t *mutex); +int npth_mutex_lock(npth_mutex_t *mutex); +int npth_mutex_timedlock(npth_mutex_t *mutex, const struct timespec *abstime); +int npth_mutex_unlock(npth_mutex_t *mutex); + +int npth_rwlockattr_init (npth_rwlockattr_t *attr); +int npth_rwlockattr_destroy (npth_rwlockattr_t *attr); +int npth_rwlockattr_gettype_np (const npth_rwlockattr_t *attr, + int *kind); +int npth_rwlockattr_settype_np (npth_rwlockattr_t *attr, int kind); +#define NPTH_RWLOCK_PREFER_READER_NP 0 +#define NPTH_RWLOCK_PREFER_WRITER_NP 1 +#define NPTH_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP 2 +#define NPTH_RWLOCK_DEFAULT_NP NPTH_RWLOCK_PREFER_READER_NP +#define NPTH_RWLOCK_INITIALIZER ((npth_rwlock_t) -1) +#define NPTH_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP ((npth_rwlock_t) -2) + +/* For now, we don't support any rwlock attributes. */ +int npth_rwlock_init (npth_rwlock_t *rwlock, + const npth_rwlockattr_t *attr); +int npth_rwlock_destroy (npth_rwlock_t *rwlock); +int npth_rwlock_tryrdlock (npth_rwlock_t *rwlock); +int npth_rwlock_rdlock (npth_rwlock_t *rwlock); +int npth_rwlock_timedrdlock (npth_rwlock_t *rwlock, + const struct timespec *abstime); +int npth_rwlock_trywrlock (npth_rwlock_t *rwlock); + +int npth_rwlock_wrlock (npth_rwlock_t *rwlock); +int npth_rwlock_timedwrlock (npth_rwlock_t *rwlock, + const struct timespec *abstime); +int npth_rwlock_unlock (npth_rwlock_t *rwlock); + +#define NPTH_COND_INITIALIZER ((npth_cond_t) -1) +/* For now, we don't support any cond attributes. */ +int npth_cond_init (npth_cond_t *cond, + const npth_condattr_t *cond_attr); +int npth_cond_broadcast (npth_cond_t *cond); +int npth_cond_signal (npth_cond_t *cond); +int npth_cond_destroy (npth_cond_t *cond); +int npth_cond_wait (npth_cond_t *cond, npth_mutex_t *mutex); +int npth_cond_timedwait (npth_cond_t *cond, npth_mutex_t *mutex, + const struct timespec *abstime); + +int npth_usleep(unsigned int usec); +unsigned int npth_sleep(unsigned int sec); + +pid_t npth_waitpid(pid_t pid, int *status, int options); +int npth_system(const char *cmd); + +#if 0 +/* We do not support this on windows. */ +int npth_sigmask(int how, const sigset_t *set, sigset_t *oldset); +int npth_sigwait(const sigset_t *set, int *sig); +#endif + +int npth_connect(int s, const struct sockaddr *addr, socklen_t addrlen); +int npth_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +/* Only good for sockets! */ +int npth_select(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds, + struct timeval *timeout); +#if 0 +/* We do not support this on windows. */ +int npth_pselect(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds, + const struct timespec *timeout, const sigset_t *sigmask); +#endif +/* Wait on the FDs (only good for sockets!) and the + INVALID_HANDLE_VALUE terminated list of extra events. On return + (even on error), the bits in EVENTS_SET will contain the extra + events that occured (which means that there can only be up to 31 + extra events). */ +int npth_eselect(int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds, + const struct timespec *timeout, + HANDLE *events, unsigned int *events_set); + +ssize_t npth_read(int fd, void *buf, size_t nbytes); +ssize_t npth_write(int fd, const void *buf, size_t nbytes); +int npth_recvmsg (int fd, struct msghdr *msg, int flags); +int npth_sendmsg (int fd, const struct msghdr *msg, int flags); + +void npth_unprotect (void); +void npth_protect (void); + +/* Return true when we hold the sceptre. This is used to debug + * problems with npth_unprotect and npth_protect. */ +int npth_is_protected (void); + +int npth_clock_gettime(struct timespec *tp); + +/* CMP may be ==, < or >. Do not use <= or >=. */ +#define npth_timercmp(t1, t2, cmp) \ + (((t1)->tv_sec == (t2)->tv_sec) ? \ + ((t1)->tv_nsec cmp (t2)->tv_nsec) : \ + ((t1)->tv_sec cmp (t2)->tv_sec)) +#define npth_timeradd(t1, t2, result) \ + do { \ + (result)->tv_sec = (t1)->tv_sec + (t2)->tv_sec; \ + (result)->tv_nsec = (t1)->tv_nsec + (t2)->tv_nsec; \ + if ((result)->tv_nsec >= 1000000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_nsec -= 1000000000; \ + } \ + } while (0) +#define npth_timersub(t1, t2, result) \ + do { \ + (result)->tv_sec = (t1)->tv_sec - (t2)->tv_sec; \ + (result)->tv_nsec = (t1)->tv_nsec - (t2)->tv_nsec; \ + if ((result)->tv_nsec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_nsec += 1000000000; \ + } \ + } while (0) + + +#if 0 +/* We do not support this on windows. */ +void npth_sigev_init (void); +void npth_sigev_add (int signum); +void npth_sigev_fini (void); +sigset_t *npth_sigev_sigmask (void); +int npth_sigev_get_pending (int *r_signum); +#endif + +#if 0 /* (Keep Emacsens' auto-indent happy.) */ +{ +#endif +#ifdef __cplusplus +} +#endif +#endif /*_NPTH_H*/ diff --git a/gpg/lib/libassuan.imp b/gpg/lib/libassuan.imp new file mode 100644 index 0000000..c25a22d Binary files /dev/null and b/gpg/lib/libassuan.imp differ diff --git a/gpg/lib/libgcrypt.imp b/gpg/lib/libgcrypt.imp new file mode 100644 index 0000000..b1f0e70 Binary files /dev/null and b/gpg/lib/libgcrypt.imp differ diff --git a/gpg/lib/libgpg-error.imp b/gpg/lib/libgpg-error.imp new file mode 100644 index 0000000..c6490e3 Binary files /dev/null and b/gpg/lib/libgpg-error.imp differ diff --git a/gpg/lib/libgpgme.imp b/gpg/lib/libgpgme.imp new file mode 100644 index 0000000..066a1a5 Binary files /dev/null and b/gpg/lib/libgpgme.imp differ diff --git a/gpg/lib/libksba.imp b/gpg/lib/libksba.imp new file mode 100644 index 0000000..2876661 Binary files /dev/null and b/gpg/lib/libksba.imp differ diff --git a/gpg/lib/libnpth.imp b/gpg/lib/libnpth.imp new file mode 100644 index 0000000..c19f4af Binary files /dev/null and b/gpg/lib/libnpth.imp differ diff --git a/gpg/share/gnupg/distsigkey.gpg b/gpg/share/gnupg/distsigkey.gpg new file mode 100644 index 0000000..219b7ed Binary files /dev/null and b/gpg/share/gnupg/distsigkey.gpg differ diff --git a/gpg/share/gnupg/sks-keyservers.netCA.pem b/gpg/share/gnupg/sks-keyservers.netCA.pem new file mode 100644 index 0000000..24a2ad2 --- /dev/null +++ b/gpg/share/gnupg/sks-keyservers.netCA.pem @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFizCCA3OgAwIBAgIJAK9zyLTPn4CPMA0GCSqGSIb3DQEBBQUAMFwxCzAJBgNV +BAYTAk5PMQ0wCwYDVQQIDARPc2xvMR4wHAYDVQQKDBVza3Mta2V5c2VydmVycy5u +ZXQgQ0ExHjAcBgNVBAMMFXNrcy1rZXlzZXJ2ZXJzLm5ldCBDQTAeFw0xMjEwMDkw +MDMzMzdaFw0yMjEwMDcwMDMzMzdaMFwxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARP +c2xvMR4wHAYDVQQKDBVza3Mta2V5c2VydmVycy5uZXQgQ0ExHjAcBgNVBAMMFXNr +cy1rZXlzZXJ2ZXJzLm5ldCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC +ggIBANdsWy4PXWNUCkS3L//nrd0GqN3dVwoBGZ6w94Tw2jPDPifegwxQozFXkG6I +6A4TK1CJLXPvfz0UP0aBYyPmTNadDinaB9T4jIwd4rnxl+59GiEmqkN3IfPsv5Jj +MkKUmJnvOT0DEVlEaO1UZIwx5WpfprB3mR81/qm4XkAgmYrmgnLXd/pJDAMk7y1F +45b5zWofiD5l677lplcIPRbFhpJ6kDTODXh/XEdtF71EAeaOdEGOvyGDmCO0GWqS +FDkMMPTlieLA/0rgFTcz4xwUYj/cD5e0ZBuSkYsYFAU3hd1cGfBue0cPZaQH2HYx +Qk4zXD8S3F4690fRhr+tki5gyG6JDR67aKp3BIGLqm7f45WkX1hYp+YXywmEziM4 +aSbGYhx8hoFGfq9UcfPEvp2aoc8u5sdqjDslhyUzM1v3m3ZGbhwEOnVjljY6JJLx +MxagxnZZSAY424ZZ3t71E/Mn27dm2w+xFRuoy8JEjv1d+BT3eChM5KaNwrj0IO/y +u8kFIgWYA1vZ/15qMT+tyJTfyrNVV/7Df7TNeWyNqjJ5rBmt0M6NpHG7CrUSkBy9 +p8JhimgjP5r0FlEkgg+lyD+V79H98gQfVgP3pbJICz0SpBQf2F/2tyS4rLm+49rP +fcOajiXEuyhpcmzgusAj/1FjrtlynH1r9mnNaX4e+rLWzvU5AgMBAAGjUDBOMB0G +A1UdDgQWBBTkwyoJFGfYTVISTpM8E+igjdq28zAfBgNVHSMEGDAWgBTkwyoJFGfY +TVISTpM8E+igjdq28zAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4ICAQAR +OXnYwu3g1ZjHyley3fZI5aLPsaE17cOImVTehC8DcIphm2HOMR/hYTTL+V0G4P+u +gH+6xeRLKSHMHZTtSBIa6GDL03434y9CBuwGvAFCMU2GV8w92/Z7apkAhdLToZA/ +X/iWP2jeaVJhxgEcH8uPrnSlqoPBcKC9PrgUzQYfSZJkLmB+3jEa3HKruy1abJP5 +gAdQvwvcPpvYRnIzUc9fZODsVmlHVFBCl2dlu/iHh2h4GmL4Da2rRkUMlbVTdioB +UYIvMycdOkpH5wJftzw7cpjsudGas0PARDXCFfGyKhwBRFY7Xp7lbjtU5Rz0Gc04 +lPrhDf0pFE98Aw4jJRpFeWMjpXUEaG1cq7D641RpgcMfPFvOHY47rvDTS7XJOaUT +BwRjmDt896s6vMDcaG/uXJbQjuzmmx3W2Idyh3s5SI0GTHb0IwMKYb4eBUIpQOnB +cE77VnCYqKvN1NVYAqhWjXbY7XasZvszCRcOG+W3FqNaHOK/n/0ueb0uijdLan+U +f4p1bjbAox8eAOQS/8a3bzkJzdyBNUKGx1BIK2IBL9bn/HravSDOiNRSnZ/R3l9G +ZauX0tu7IIDlRCILXSyeazu0aj/vdT3YFQXPcvt5Fkf5wiNTo53f72/jYEJd6qph +WrpoKqrwGwTpRUCMhYIUt65hsTxCiJJ5nKe39h46sg== +-----END CERTIFICATE----- diff --git a/gpg/share/locale/ca/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/ca/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..1197531 Binary files /dev/null and b/gpg/share/locale/ca/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/cs/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/cs/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..07d1c1c Binary files /dev/null and b/gpg/share/locale/cs/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/cs/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/cs/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..4f2532c Binary files /dev/null and b/gpg/share/locale/cs/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/da/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/da/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..00472a8 Binary files /dev/null and b/gpg/share/locale/da/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/da/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/da/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..61b9cc0 Binary files /dev/null and b/gpg/share/locale/da/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/de/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/de/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..286fc10 Binary files /dev/null and b/gpg/share/locale/de/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/de/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/de/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..4e90f34 Binary files /dev/null and b/gpg/share/locale/de/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/el/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/el/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..3db5a68 Binary files /dev/null and b/gpg/share/locale/el/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/en@boldquot/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/en@boldquot/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..691978a Binary files /dev/null and b/gpg/share/locale/en@boldquot/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/en@quot/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/en@quot/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..92568e4 Binary files /dev/null and b/gpg/share/locale/en@quot/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/eo/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/eo/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..a04e4bf Binary files /dev/null and b/gpg/share/locale/eo/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/eo/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/eo/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..b9c4c58 Binary files /dev/null and b/gpg/share/locale/eo/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/es/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/es/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..132ee61 Binary files /dev/null and b/gpg/share/locale/es/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/et/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/et/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..7ed9f68 Binary files /dev/null and b/gpg/share/locale/et/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/fi/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/fi/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..15d1d0d Binary files /dev/null and b/gpg/share/locale/fi/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/fr/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/fr/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..ea3fe11 Binary files /dev/null and b/gpg/share/locale/fr/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/fr/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/fr/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..76b565f Binary files /dev/null and b/gpg/share/locale/fr/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/gl/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/gl/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..bd19058 Binary files /dev/null and b/gpg/share/locale/gl/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/hu/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/hu/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..d11f880 Binary files /dev/null and b/gpg/share/locale/hu/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/hu/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/hu/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..917e3d9 Binary files /dev/null and b/gpg/share/locale/hu/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/id/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/id/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..e204841 Binary files /dev/null and b/gpg/share/locale/id/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/it/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/it/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..0f4567d Binary files /dev/null and b/gpg/share/locale/it/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/it/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/it/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..f07b6b1 Binary files /dev/null and b/gpg/share/locale/it/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/ja/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/ja/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..3d1b27a Binary files /dev/null and b/gpg/share/locale/ja/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/ja/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/ja/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..90dd172 Binary files /dev/null and b/gpg/share/locale/ja/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/nb/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/nb/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..37dd8c7 Binary files /dev/null and b/gpg/share/locale/nb/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/nl/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/nl/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..8722bf8 Binary files /dev/null and b/gpg/share/locale/nl/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/pl/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/pl/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..13fdf02 Binary files /dev/null and b/gpg/share/locale/pl/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/pl/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/pl/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..b78f931 Binary files /dev/null and b/gpg/share/locale/pl/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/pt/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/pt/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..61a8944 Binary files /dev/null and b/gpg/share/locale/pt/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/pt/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/pt/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..a022f0f Binary files /dev/null and b/gpg/share/locale/pt/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/ro/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/ro/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..a0172a7 Binary files /dev/null and b/gpg/share/locale/ro/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/ro/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/ro/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..27aaeb0 Binary files /dev/null and b/gpg/share/locale/ro/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/ru/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/ru/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..355f799 Binary files /dev/null and b/gpg/share/locale/ru/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/ru/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/ru/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..a618d4b Binary files /dev/null and b/gpg/share/locale/ru/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/sk/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/sk/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..09a18ca Binary files /dev/null and b/gpg/share/locale/sk/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/sr/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/sr/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..3537131 Binary files /dev/null and b/gpg/share/locale/sr/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/sv/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/sv/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..931fc93 Binary files /dev/null and b/gpg/share/locale/sv/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/sv/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/sv/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..b11dcfc Binary files /dev/null and b/gpg/share/locale/sv/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/tr/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/tr/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..b5439b5 Binary files /dev/null and b/gpg/share/locale/tr/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/uk/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/uk/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..2b0ae79 Binary files /dev/null and b/gpg/share/locale/uk/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/uk/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/uk/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..be25a70 Binary files /dev/null and b/gpg/share/locale/uk/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/vi/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/vi/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..5e84a5b Binary files /dev/null and b/gpg/share/locale/vi/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/zh_CN/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/zh_CN/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..e398f89 Binary files /dev/null and b/gpg/share/locale/zh_CN/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/zh_CN/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/zh_CN/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..68561b2 Binary files /dev/null and b/gpg/share/locale/zh_CN/LC_MESSAGES/libgpg-error.mo differ diff --git a/gpg/share/locale/zh_TW/LC_MESSAGES/gnupg2.mo b/gpg/share/locale/zh_TW/LC_MESSAGES/gnupg2.mo new file mode 100644 index 0000000..c956066 Binary files /dev/null and b/gpg/share/locale/zh_TW/LC_MESSAGES/gnupg2.mo differ diff --git a/gpg/share/locale/zh_TW/LC_MESSAGES/libgpg-error.mo b/gpg/share/locale/zh_TW/LC_MESSAGES/libgpg-error.mo new file mode 100644 index 0000000..012bbb4 Binary files /dev/null and b/gpg/share/locale/zh_TW/LC_MESSAGES/libgpg-error.mo differ