diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ChangeLog | 214 | ||||
| -rw-r--r-- | include/_regex.h | 4 | ||||
| -rw-r--r-- | include/assuan.h | 262 | ||||
| -rw-r--r-- | include/cipher.h | 213 | ||||
| -rw-r--r-- | include/distfiles | 4 | ||||
| -rw-r--r-- | include/dynload.h | 72 | ||||
| -rw-r--r-- | include/errors.h | 33 | ||||
| -rw-r--r-- | include/host2net.h | 6 | ||||
| -rw-r--r-- | include/http.h | 6 | ||||
| -rw-r--r-- | include/iobuf.h | 162 | ||||
| -rw-r--r-- | include/keyserver.h | 8 | ||||
| -rw-r--r-- | include/memory.h | 43 | ||||
| -rw-r--r-- | include/mpi.h | 19 | ||||
| -rw-r--r-- | include/ttyio.h | 59 | ||||
| -rw-r--r-- | include/types.h | 12 | ||||
| -rw-r--r-- | include/util.h | 113 |
16 files changed, 188 insertions, 1042 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index eaee0ddd3..3fd3fe48c 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,205 +1,40 @@ -2006-04-20 David Shaw <[email protected]> +2006-04-28 Werner Koch <[email protected]> - * cipher.h: Add dsa2_generate(); + * cipher.h (DIGEST_ALGO_SHA224): Define it. -2006-04-19 David Shaw <[email protected]> +2006-04-18 Werner Koch <[email protected]> - * cipher.h: Add SHA-224. + * keyserver.h, i18n.h, http.h, cipher.h: Updated to gpg 1.4.3. -2006-03-16 David Shaw <[email protected]> - - * util.h: Handle the fixed IPGP type with fingerprint. - -2006-02-14 Werner Koch <[email protected]> - - * errors.h (G10ERR_NO_DATA): New. - -2005-12-23 David Shaw <[email protected]> - - * util.h: Prototype get_cert(). - -2005-07-27 Werner Koch <[email protected]> - - * memory.h (m_free, m_alloc, m_realloc, m_strdup): Removed and - replaced all over by xfoo functions. This is to ease porting to - gnupg 1.9. - (xmalloc_secure) [M_DEBUG]: Correctly map to m_debug_alloc_secure. - -2005-06-23 David Shaw <[email protected]> - - * http.h: Fix prototypes for http_open_document and http_open - again, to handle the new different auth for regular files and - proxies. - -2005-06-21 David Shaw <[email protected]> - - * http.h: Fix prototypes for http_open_document and http_open to - pass in auth and proxyauth. - -2005-05-19 Werner Koch <[email protected]> - - * util.h: Add definitions for membuf functions. - -2005-05-05 David Shaw <[email protected]> - - * util.h: Remove add_days_to_timestamp as unused. - -2005-04-22 David Shaw <[email protected]> - - * distfiles: Add assuan.h. - -2005-04-04 Werner Koch <[email protected]> - - * memory.h (xcalloc, xcalloc_secure): Replaced macros by functions. - -2005-03-31 Werner Koch <[email protected]> - - * assuan.h: New. Taken from libassuan 0.6.9. - -2005-03-18 David Shaw <[email protected]> - - * ttyio.h: Prototype tty_enable_completion(), and - tty_disable_completion(). - -2005-02-09 David Shaw <[email protected]> - - * cipher.h: Add a flag for a symmetric DEK. - -2004-12-16 David Shaw <[email protected]> - - * memory.h: Return a flag to indicate whether we got the lock. - -2004-11-29 David Shaw <[email protected]> - - * cipher.h: Add PUBKEY_USAGE_UNKNOWN. - -2004-11-03 Timo Schulz <[email protected]> - - * errors.h: Add w32_strerror prototype. - * dynload.h: Use w32_strerror. - -2004-10-27 Werner Koch <[email protected]> - - * dynload.h: Always use it for _WIN32. - -2004-10-21 Werner Koch <[email protected]> - - * util.h [!HAVE_VASPRINTF]: Removed prototype. - -2004-10-15 Werner Koch <[email protected]> - - * util.h [!HAVE_VASPRINTF]: Add asprintf prototype. - -2004-10-13 David Shaw <[email protected]> - - * keyserver.h: Add KEYSERVER_TIMEOUT. - -2004-09-30 David Shaw <[email protected]> - - * util.h: Prototype destroy_dotlock(). From Werner on stable - branch. - -2004-09-10 David Shaw <[email protected]> - - * http.h: Add auth field for a parsed_uri to allow for basic auth. - -2004-09-09 Werner Koch <[email protected]> - - * errors.h (G10ERR_NO_CARD, G10ERR_CANCELED): New error codes. - -2004-04-27 Werner Koch <[email protected]> - - * mpi.h: Renamed prototype parameter name to avoid gcc warnings. - -2004-03-04 David Shaw <[email protected]> - - * iobuf.h: Remove iobuf_set_block_mode() and - iobuf_in_block_mode(). - -2004-02-21 David Shaw <[email protected]> - - * util.h: Prototype for hextobyte(). - -2004-01-16 David Shaw <[email protected]> - - * cipher.h: Remove the old CIPHER_ALGO_RINJDAEL values. - is_ELGAMAL() now only matches type 16 and not type 20. - -2004-01-15 David Shaw <[email protected]> - - * util.h: Add prototype for print_string2(). - -2003-12-28 David Shaw <[email protected]> - - * http.h: Pass the http proxy from outside rather than pulling it - from the evironment. - -2003-12-28 Stefan Bellon <[email protected]> - - * util.h [__riscos__]: Removal of unnecessary RISC OS stuff. - -2003-12-17 David Shaw <[email protected]> - - * mpi.h (gcry_mpi, mpi_get_opaque, mpi_set_opaque): Make nbits and - the length of an opaque MPI unsigned. - - * cipher.h (pubkey_verify): Remove old unused code. - -2003-12-03 David Shaw <[email protected]> - - * cipher.h: Make cipher list match 2440bis-09. - -2003-11-20 David Shaw <[email protected]> - - * util.h: Add prototype for match_multistr(). - -2003-10-31 David Shaw <[email protected]> - - * cipher.h: Add COMPRESS_ALGO_BZIP2. - -2003-10-04 Timo Schulz <[email protected]> - - * dynload [WIN32] (dlclose): Do not use CloseHandle but FreeLibrary. - -2003-09-29 Werner Koch <[email protected]> - - * cipher.h (PUBKEY_USAGE_AUTH): New. - -2003-09-28 Timo Schulz <[email protected]> - - * util.h [WIN32]: Prototype for asprintf. - * dynload.h [WIN32]: Define RTLD_LAZY. - -2003-09-28 Werner Koch <[email protected]> +2003-09-04 David Shaw <[email protected]> - * util.h: Add the atoi_* and xtoi_* suite of macros from 1.9. - * dynload.h: New. Taken from 1.9. + * cipher.h: Drop TIGER/192 support. -2003-09-27 Werner Koch <[email protected]> + * types.h: Prefer using uint64_t when creating a 64-bit unsigned + type. This avoids a warning on compilers that support but complain + about unsigned long long. - * memory.h (xmalloc): Define xmalloc macros in terms of m_alloc. + * util.h: Make sure that only ascii is passed to isfoo + functions. (From Werner on stable branch). -2003-09-04 David Shaw <[email protected]> +2003-09-04 Werner Koch <[email protected]> - * cipher.h: Drop TIGER/192 support. + * cipher.h (PUBKEY_USAGE_AUTH): Added. -2003-08-28 David Shaw <[email protected]> +2003-07-03 Werner Koch <[email protected]> - * util.h: s/__MINGW32__/_WIN32/ to help building on native Windows - compilers. Requested by Brian Gladman. From Werner on stable - branch. + * cipher.h (DBG_CIPHER,g10c_debug_mode): Removed. -2003-07-10 David Shaw <[email protected]> +2003-06-11 Werner Koch <[email protected]> - * types.h: Prefer using uint64_t when creating a 64-bit unsigned - type. This avoids a warning on compilers that support but complain - about unsigned long long. + * cipher.h: Include gcrypt.h and mapped cipher algo names to + gcrypt ones. Removed twofish_old and skipjack. Removed all + handle definitions and other raerely used stuff. This file will + eventually be entirely removed. - * util.h (ascii_isspace): New variation on isspace() that is - immune from locale changes. +2003-06-10 Werner Koch <[email protected]> - * util.h: Make sure that only ascii is passed to isfoo - functions. (From Werner on stable branch). + * types.h (struct strlist): Removed. 2003-05-24 David Shaw <[email protected]> @@ -563,8 +398,7 @@ Tue Mar 3 15:11:21 1998 Werner Koch ([email protected]) functions to this header. - Copyright 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without @@ -573,3 +407,5 @@ Tue Mar 3 15:11:21 1998 Werner Koch ([email protected]) This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + diff --git a/include/_regex.h b/include/_regex.h index 88acc352d..ddd002484 100644 --- a/include/_regex.h +++ b/include/_regex.h @@ -16,8 +16,8 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02110-1301 USA. */ + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. */ #ifndef _REGEX_H #define _REGEX_H 1 diff --git a/include/assuan.h b/include/assuan.h deleted file mode 100644 index 683f55bc1..000000000 --- a/include/assuan.h +++ /dev/null @@ -1,262 +0,0 @@ -/* assuan.c - Definitions for the Assuan protocol - * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. - * Copyright (C) 2005 Free Software Foundation, Inc. - * - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -/* Please note that this is a stripped down and modified version of - the orginal Assuan code from libassuan. For the standalone version - of gnupg we only need the ability to connect to a server, so we - dropped everything else and maintain this separate copy. */ - -#ifndef ASSUAN_H -#define ASSUAN_H - -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> - -typedef enum -{ - ASSUAN_No_Error = 0, - ASSUAN_General_Error = 1, - ASSUAN_Out_Of_Core = 2, - ASSUAN_Invalid_Value = 3, - ASSUAN_Timeout = 4, - ASSUAN_Read_Error = 5, - ASSUAN_Write_Error = 6, - ASSUAN_Problem_Starting_Server = 7, - ASSUAN_Not_A_Server = 8, - ASSUAN_Not_A_Client = 9, - ASSUAN_Nested_Commands = 10, - ASSUAN_Invalid_Response = 11, - ASSUAN_No_Data_Callback = 12, - ASSUAN_No_Inquire_Callback = 13, - ASSUAN_Connect_Failed = 14, - ASSUAN_Accept_Failed = 15, - - /* Error codes above 99 are meant as status codes */ - ASSUAN_Not_Implemented = 100, - ASSUAN_Server_Fault = 101, - ASSUAN_Invalid_Command = 102, - ASSUAN_Unknown_Command = 103, - ASSUAN_Syntax_Error = 104, - ASSUAN_Parameter_Error = 105, - ASSUAN_Parameter_Conflict = 106, - ASSUAN_Line_Too_Long = 107, - ASSUAN_Line_Not_Terminated = 108, - ASSUAN_No_Input = 109, - ASSUAN_No_Output = 110, - ASSUAN_Canceled = 111, - ASSUAN_Unsupported_Algorithm = 112, - ASSUAN_Server_Resource_Problem = 113, - ASSUAN_Server_IO_Error = 114, - ASSUAN_Server_Bug = 115, - ASSUAN_No_Data_Available = 116, - ASSUAN_Invalid_Data = 117, - ASSUAN_Unexpected_Command = 118, - ASSUAN_Too_Much_Data = 119, - ASSUAN_Inquire_Unknown = 120, - ASSUAN_Inquire_Error = 121, - ASSUAN_Invalid_Option = 122, - ASSUAN_Invalid_Index = 123, - ASSUAN_Unexpected_Status = 124, - ASSUAN_Unexpected_Data = 125, - ASSUAN_Invalid_Status = 126, - ASSUAN_Locale_Problem = 127, - ASSUAN_Not_Confirmed = 128, - - /* Error codes in the range 1000 to 9999 may be used by applications - at their own discretion. */ - ASSUAN_USER_ERROR_FIRST = 1000, - ASSUAN_USER_ERROR_LAST = 9999 - -} assuan_error_t; - - -#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */ - -struct assuan_context_s; -typedef struct assuan_context_s *assuan_context_t; - -/*-- assuan-handler.c --*/ -int assuan_register_command (assuan_context_t ctx, - const char *cmd_string, - int (*handler)(assuan_context_t, char *)); -int assuan_register_bye_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_reset_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_cancel_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t)); -int assuan_register_input_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); -int assuan_register_output_notify (assuan_context_t ctx, - void (*fnc)(assuan_context_t, const char *)); - -int assuan_register_option_handler (assuan_context_t ctx, - int (*fnc)(assuan_context_t, - const char*, const char*)); - -int assuan_process (assuan_context_t ctx); -int assuan_process_next (assuan_context_t ctx); -int assuan_get_active_fds (assuan_context_t ctx, int what, - int *fdarray, int fdarraysize); - - -FILE *assuan_get_data_fp (assuan_context_t ctx); -assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line); -assuan_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). */ -assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line, - int *rfd); - -/*-- assuan-listen.c --*/ -assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line); -assuan_error_t assuan_accept (assuan_context_t ctx); -int assuan_get_input_fd (assuan_context_t ctx); -int assuan_get_output_fd (assuan_context_t ctx); -assuan_error_t assuan_close_input_fd (assuan_context_t ctx); -assuan_error_t assuan_close_output_fd (assuan_context_t ctx); - - -/*-- assuan-pipe-server.c --*/ -int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]); -void assuan_deinit_server (assuan_context_t ctx); - -/*-- assuan-socket-server.c --*/ -int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd); -int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd); - - -/*-- assuan-pipe-connect.c --*/ -assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, const char *name, - char *const argv[], int *fd_child_list); -assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, const char *name, - char *const argv[], int *fd_child_list, - void (*atfork) (void*, int), - void *atforkvalue); -/*-- assuan-socket-connect.c --*/ -assuan_error_t assuan_socket_connect (assuan_context_t *ctx, const char *name, - pid_t server_pid); - -/*-- assuan-domain-connect.c --*/ - -/* Connect to a Unix domain socket server. RENDEZVOUSFD is - bidirectional file descriptor (normally returned via socketpair) - which the client can use to rendezvous with the server. SERVER s - the server's pid. */ -assuan_error_t assuan_domain_connect (assuan_context_t *r_ctx, - int rendezvousfd, - pid_t server); - -/*-- assuan-domain-server.c --*/ - -/* RENDEZVOUSFD is a bidirectional file descriptor (normally returned - via socketpair) that the domain server can use to rendezvous with - the client. CLIENT is the client's pid. */ -assuan_error_t assuan_init_domain_server (assuan_context_t *r_ctx, - int rendezvousfd, - pid_t client); - - -/*-- assuan-connect.c --*/ -void assuan_disconnect (assuan_context_t ctx); -pid_t assuan_get_pid (assuan_context_t ctx); - -/*-- assuan-client.c --*/ -assuan_error_t -assuan_transact (assuan_context_t ctx, - const char *command, - assuan_error_t (*data_cb)(void *, const void *, size_t), - void *data_cb_arg, - assuan_error_t (*inquire_cb)(void*, const char *), - void *inquire_cb_arg, - assuan_error_t (*status_cb)(void*, const char *), - void *status_cb_arg); -assuan_error_t -assuan_transact2 (assuan_context_t ctx, - const char *command, - assuan_error_t (*data_cb)(void *, const void *, size_t), - void *data_cb_arg, - assuan_error_t (*inquire_cb)(void*, const char *), - void *inquire_cb_arg, - assuan_error_t (*status_cb)(void*, const char *), - void *status_cb_arg, - assuan_error_t (*okay_cb)(void*, const char *), - void *okay_cb_arg); - - -/*-- assuan-inquire.c --*/ -assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword, - unsigned char **r_buffer, size_t *r_length, - size_t maxlen); - -/*-- assuan-buffer.c --*/ -assuan_error_t assuan_read_line (assuan_context_t ctx, - char **line, size_t *linelen); -int assuan_pending_line (assuan_context_t ctx); -assuan_error_t assuan_write_line (assuan_context_t ctx, const char *line ); -assuan_error_t assuan_send_data (assuan_context_t ctx, - const void *buffer, size_t length); - -/*-- assuan-util.c --*/ -void assuan_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 assuan_set_log_stream (assuan_context_t ctx, FILE *fp); -int assuan_set_error (assuan_context_t ctx, int err, const char *text); -void assuan_set_pointer (assuan_context_t ctx, void *pointer); -void *assuan_get_pointer (assuan_context_t ctx); - -void assuan_begin_confidential (assuan_context_t ctx); -void assuan_end_confidential (assuan_context_t ctx); - -/*-- assuan-errors.c (built) --*/ -const char *assuan_strerror (assuan_error_t err); - -/*-- assuan-logging.c --*/ - -/* Set the stream to which assuan should log message not associated - with a context. By default, this is stderr. The default value - will be changed when the first log stream is associated with a - context. Note, that this function is not thread-safe and should - in general be used right at startup. */ -extern void assuan_set_assuan_log_stream (FILE *fp); - -/* Return the stream which is currently being using for global logging. */ -extern FILE *assuan_get_assuan_log_stream (void); - -/* 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); - -#endif /* ASSUAN_H */ diff --git a/include/cipher.h b/include/cipher.h index 5b531ccd2..d8b15cf9a 100644 --- a/include/cipher.h +++ b/include/cipher.h @@ -1,15 +1,14 @@ -/* cipher.h - * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, - * 2006 Free Software Foundation, Inc. +/* cipher.h - Definitions for OpenPGP + * Copyright (C) 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc. * - * This file is part of GNUPG. + * This file is part of GnuPG. * - * GNUPG is free software; you can redistribute it and/or modify + * GnuPG is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * GNUPG is distributed in the hope that it will be useful, + * GnuPG 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. @@ -22,49 +21,60 @@ #ifndef G10_CIPHER_H #define G10_CIPHER_H -#define DBG_CIPHER g10c_debug_mode +#include <gcrypt.h> + +/* Macros for compatibility with older libgcrypt versions. */ +#ifndef GCRY_PK_USAGE_CERT +# define GCRY_PK_USAGE_CERT 4 +# define GCRY_PK_USAGE_AUTH 8 +# define GCRY_PK_USAGE_UNKN 128 +#endif -#include "mpi.h" -#include "../cipher/random.h" +/* Constants for OpenPGP. */ -#define CIPHER_ALGO_NONE 0 -#define CIPHER_ALGO_IDEA 1 -#define CIPHER_ALGO_3DES 2 -#define CIPHER_ALGO_CAST5 3 -#define CIPHER_ALGO_BLOWFISH 4 /* blowfish 128 bit key */ +#define CIPHER_ALGO_NONE /* 0 */ GCRY_CIPHER_NONE +#define CIPHER_ALGO_IDEA /* 1 */ GCRY_CIPHER_IDEA +#define CIPHER_ALGO_3DES /* 2 */ GCRY_CIPHER_3DES +#define CIPHER_ALGO_CAST5 /* 3 */ GCRY_CIPHER_CAST5 +#define CIPHER_ALGO_BLOWFISH /* 4 */ GCRY_CIPHER_BLOWFISH /* 128 bit */ /* 5 & 6 are reserved */ -#define CIPHER_ALGO_AES 7 -#define CIPHER_ALGO_AES192 8 -#define CIPHER_ALGO_AES256 9 -#define CIPHER_ALGO_TWOFISH 10 /* twofish 256 bit */ -#define CIPHER_ALGO_DUMMY 110 /* no encryption at all */ +#define CIPHER_ALGO_AES /* 7 */ GCRY_CIPHER_AES +#define CIPHER_ALGO_AES192 /* 8 */ GCRY_CIPHER_AES192 +#define CIPHER_ALGO_AES256 /* 9 */ GCRY_CIPHER_AES256 +#define CIPHER_ALGO_RIJNDAEL CIPHER_ALGO_AES +#define CIPHER_ALGO_RIJNDAEL192 CIPHER_ALGO_AES192 +#define CIPHER_ALGO_RIJNDAEL256 CIPHER_ALGO_AES256 +#define CIPHER_ALGO_TWOFISH /* 10 */ GCRY_CIPHER_TWOFISH /* 256 bit */ +#define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */ -#define PUBKEY_ALGO_RSA 1 -#define PUBKEY_ALGO_RSA_E 2 /* RSA encrypt only */ -#define PUBKEY_ALGO_RSA_S 3 /* RSA sign only */ -#define PUBKEY_ALGO_ELGAMAL_E 16 /* encrypt only ElGamal (but not for v3)*/ -#define PUBKEY_ALGO_DSA 17 -#define PUBKEY_ALGO_ELGAMAL 20 /* sign and encrypt elgamal */ +#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA +#define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */ +#define PUBKEY_ALGO_RSA_S /* 3 */ GCRY_PK_RSA_S /* RSA sign only. */ +#define PUBKEY_ALGO_ELGAMAL_E /* 16 */ GCRY_PK_ELG_E /* Elgamal encr only */ +#define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA +#define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */ -#define PUBKEY_USAGE_SIG 1 /* key is good for signatures */ -#define PUBKEY_USAGE_ENC 2 /* key is good for encryption */ -#define PUBKEY_USAGE_CERT 4 /* key is also good to certify other keys*/ -#define PUBKEY_USAGE_AUTH 8 /* key is good for authentication */ -#define PUBKEY_USAGE_UNKNOWN 128 /* key has an unknown usage bit */ +#define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */ +#define PUBKEY_USAGE_ENC GCRY_PK_USAGE_ENCR /* Good for encryption. */ +#define PUBKEY_USAGE_CERT GCRY_PK_USAGE_CERT /* Also good to certify keys. */ +#define PUBKEY_USAGE_AUTH GCRY_PK_USAGE_AUTH /* Good for authentication. */ +#define PUBKEY_USAGE_UNKNOWN GCRY_PK_USAGE_UNKN /* Unknown usage flag. */ -#define DIGEST_ALGO_MD5 1 -#define DIGEST_ALGO_SHA1 2 -#define DIGEST_ALGO_RMD160 3 +#define DIGEST_ALGO_MD5 /* 1 */ GCRY_MD_MD5 +#define DIGEST_ALGO_SHA1 /* 2 */ GCRY_MD_SHA1 +#define DIGEST_ALGO_RMD160 /* 3 */ GCRY_MD_RMD160 /* 4, 5, 6, and 7 are reserved */ -#define DIGEST_ALGO_SHA256 8 -#define DIGEST_ALGO_SHA384 9 -#define DIGEST_ALGO_SHA512 10 -#define DIGEST_ALGO_SHA224 11 +#define DIGEST_ALGO_SHA256 /* 8 */ GCRY_MD_SHA256 +#define DIGEST_ALGO_SHA384 /* 9 */ GCRY_MD_SHA384 +#define DIGEST_ALGO_SHA512 /* 10 */ GCRY_MD_SHA512 +/* SHA224 is as of now only defined in the libgcrypt SVN; thus we + can't use that macro. */ +#define DIGEST_ALGO_SHA224 /* 11 */ 11 /* GCRY_MD_SHA224 */ -#define COMPRESS_ALGO_NONE 0 -#define COMPRESS_ALGO_ZIP 1 -#define COMPRESS_ALGO_ZLIB 2 +#define COMPRESS_ALGO_NONE 0 +#define COMPRESS_ALGO_ZIP 1 +#define COMPRESS_ALGO_ZLIB 2 #define COMPRESS_ALGO_BZIP2 3 #define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \ @@ -72,138 +82,23 @@ #define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL_E) #define is_DSA(a) ((a)==PUBKEY_ALGO_DSA) -typedef struct +/* The data encryption key object. */ +typedef struct { int algo; int keylen; int algo_info_printed; int use_mdc; int symmetric; - byte key[32]; /* this is the largest used keylen (256 bit) */ + byte key[32]; /* This is the largest used keylen (256 bit). */ } DEK; -struct cipher_handle_s; -typedef struct cipher_handle_s *CIPHER_HANDLE; - - -#define CIPHER_MODE_ECB 1 -#define CIPHER_MODE_CFB 2 -#define CIPHER_MODE_PHILS_CFB 3 -#define CIPHER_MODE_AUTO_CFB 4 -#define CIPHER_MODE_DUMMY 5 /* used with algo DUMMY for no encryption */ -#define CIPHER_MODE_CBC 6 - -struct md_digest_list_s; - -struct gcry_md_context { - int secure; - FILE *debug; - int finalized; - struct md_digest_list_s *list; - int bufcount; - int bufsize; - byte buffer[1]; -}; - -typedef struct gcry_md_context *MD_HANDLE; - -#ifndef EXTERN_UNLESS_MAIN_MODULE -#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE) -#define EXTERN_UNLESS_MAIN_MODULE extern -#else -#define EXTERN_UNLESS_MAIN_MODULE -#endif -#endif -EXTERN_UNLESS_MAIN_MODULE int g10c_debug_mode; -EXTERN_UNLESS_MAIN_MODULE int g10_opt_verbose; -EXTERN_UNLESS_MAIN_MODULE const char *g10_opt_homedir; -/*-- dynload.c --*/ -void register_cipher_extension( const char *mainpgm, const char *fname ); - -/*-- md.c --*/ -int string_to_digest_algo( const char *string ); -const char * digest_algo_to_string( int algo ); -int check_digest_algo( int algo ); -MD_HANDLE md_open( int algo, int secure ); -void md_enable( MD_HANDLE hd, int algo ); -MD_HANDLE md_copy( MD_HANDLE a ); -void md_reset( MD_HANDLE a ); -void md_close(MD_HANDLE a); -void md_write( MD_HANDLE a, const byte *inbuf, size_t inlen); -void md_final(MD_HANDLE a); -byte *md_read( MD_HANDLE a, int algo ); -int md_digest( MD_HANDLE a, int algo, byte *buffer, int buflen ); -int md_get_algo( MD_HANDLE a ); -int md_algo_present( MD_HANDLE a, int algo ); -int md_digest_length( int algo ); -const byte *md_asn_oid( int algo, size_t *asnlen, size_t *mdlen ); -void md_start_debug( MD_HANDLE a, const char *suffix ); -void md_stop_debug( MD_HANDLE a ); -#define md_is_secure(a) ((a)->secure) -#define md_putc(h,c) \ - do { \ - if( (h)->bufcount == (h)->bufsize ) \ - md_write( (h), NULL, 0 ); \ - (h)->buffer[(h)->bufcount++] = (c) & 0xff; \ - } while(0) - -void rmd160_hash_buffer (char *outbuf, const char *buffer, size_t length); - - -/*-- cipher.c --*/ -int string_to_cipher_algo( const char *string ); -const char * cipher_algo_to_string( int algo ); -void disable_cipher_algo( int algo ); -int check_cipher_algo( int algo ); -unsigned cipher_get_keylen( int algo ); -unsigned cipher_get_blocksize( int algo ); -CIPHER_HANDLE cipher_open( int algo, int mode, int secure ); -void cipher_close( CIPHER_HANDLE c ); -int cipher_setkey( CIPHER_HANDLE c, byte *key, unsigned keylen ); -void cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen ); -void cipher_encrypt( CIPHER_HANDLE c, byte *out, byte *in, unsigned nbytes ); -void cipher_decrypt( CIPHER_HANDLE c, byte *out, byte *in, unsigned nbytes ); -void cipher_sync( CIPHER_HANDLE c ); - -/*-- pubkey.c --*/ +/* Constants to allocate static MPI arrays. */ #define PUBKEY_MAX_NPKEY 4 #define PUBKEY_MAX_NSKEY 6 #define PUBKEY_MAX_NSIG 2 #define PUBKEY_MAX_NENC 2 -int string_to_pubkey_algo( const char *string ); -const char * pubkey_algo_to_string( int algo ); -void disable_pubkey_algo( int algo ); -int check_pubkey_algo( int algo ); -int check_pubkey_algo2( int algo, unsigned use ); -int pubkey_get_npkey( int algo ); -int pubkey_get_nskey( int algo ); -int pubkey_get_nsig( int algo ); -int pubkey_get_nenc( int algo ); -unsigned pubkey_nbits( int algo, MPI *pkey ); -int pubkey_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); -int dsa2_generate( int algo, unsigned nbits, unsigned qbits, - MPI *skey, MPI **retfactors ); -int pubkey_check_secret_key( int algo, MPI *skey ); -int pubkey_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ); -int pubkey_decrypt( int algo, MPI *result, MPI *data, MPI *skey ); -int pubkey_sign( int algo, MPI *resarr, MPI hash, MPI *skey ); -int pubkey_verify( int algo, MPI hash, MPI *data, MPI *pkey ); - -/*-- smallprime.c --*/ -extern ushort small_prime_numbers[]; - -/*-- primegen.c --*/ -void register_primegen_progress ( void (*cb)( void *, int), void *cb_data ); -MPI generate_secret_prime( unsigned nbits ); -MPI generate_public_prime( unsigned nbits ); -MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits, - MPI g, MPI **factors ); - -/*-- elsewhere --*/ -void register_pk_dsa_progress ( void (*cb)( void *, int), void *cb_data ); -void register_pk_elg_progress ( void (*cb)( void *, int), void *cb_data ); - #endif /*G10_CIPHER_H*/ diff --git a/include/distfiles b/include/distfiles index 1295adefe..b11749d78 100644 --- a/include/distfiles +++ b/include/distfiles @@ -1,9 +1,7 @@ cipher.h errors.h -iobuf.h memory.h mpi.h -ttyio.h types.h util.h i18n.h @@ -11,7 +9,5 @@ host2net.h http.h keyserver.h _regex.h -dynload.h -assuan.h ChangeLog diff --git a/include/dynload.h b/include/dynload.h deleted file mode 100644 index acdf5c879..000000000 --- a/include/dynload.h +++ /dev/null @@ -1,72 +0,0 @@ -/* dlfcn.h - W32 functions for run-time dynamic loading - * Copyright (C) 2003 Free Software Foundation, Inc. - * - * This file is part of GnuPG. - * - * GnuPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GnuPG is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -#ifndef GNUPG_DYNLOAD_H -#define GNUPG_DYNLOAD_H -#if defined (ENABLE_CARD_SUPPORT) || defined(_WIN32) -#ifndef _WIN32 -#include <dlfcn.h> -#else -#include <windows.h> - -#define RTLD_LAZY 0 - -static __inline__ void * -dlopen (const char * name, int flag) -{ - void * hd = LoadLibrary (name); - return hd; -} - -static __inline__ void * -dlsym (void * hd, const char * sym) -{ - if (hd && sym) - { - void * fnc = GetProcAddress (hd, sym); - if (!fnc) - return NULL; - return fnc; - } - return NULL; -} - - -static __inline__ const char * -dlerror (void) -{ - return w32_strerror (0); -} - - -static __inline__ int -dlclose (void * hd) -{ - if (hd) - { - FreeLibrary (hd); - return 0; - } - return -1; -} -#endif /*_WIN32*/ -#endif /*ENABLE_CARD_SUPPORT||_WIN32*/ -#endif /*GNUPG_DYNLOAD_H*/ diff --git a/include/errors.h b/include/errors.h index 177353b7e..f3269ce5b 100644 --- a/include/errors.h +++ b/include/errors.h @@ -1,4 +1,4 @@ -/* errors.h - erro code +/* errors.h - error code * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of GNUPG. @@ -18,9 +18,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. */ -#ifndef G10_ERRORS_H -#define G10_ERRORS_H +#ifndef GNUPG_INCLUDE_ERRORS_H +#define GNUPG_INCLUDE_ERRORS_H +#if 0 +#error Remove this file after replacing all error codes with those +#error from libgpg-error. The numerical values are identical, though. +#endif + + +#if 0 /* Not used anymore. */ #define G10ERR_GENERAL 1 #define G10ERR_UNKNOWN_PACKET 2 #define G10ERR_UNKNOWN_VERSION 3 /* Unknown version (in packet) */ @@ -76,16 +83,20 @@ #define G10ERR_UNU_PUBKEY 53 #define G10ERR_UNU_SECKEY 54 #define G10ERR_KEYSERVER 55 -#define G10ERR_CANCELED 56 -#define G10ERR_NO_CARD 57 -#define G10ERR_NO_DATA 58 +#endif #ifndef HAVE_STRERROR -char *strerror (int n); +char *strerror( int n ); #endif -#ifdef _WIN32 -const char * w32_strerror (int w32_errno); -#endif +#endif /*GNUPG_INCLUDE_ERRORS_H*/ + + + + + + + + + -#endif /*G10_ERRORS_H*/ diff --git a/include/host2net.h b/include/host2net.h index d72b828d0..e378bfb29 100644 --- a/include/host2net.h +++ b/include/host2net.h @@ -1,14 +1,14 @@ /* host2net.h - Some macros * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * - * This file is part of GNUPG. + * This file is part of GnuPG. * - * GNUPG is free software; you can redistribute it and/or modify + * GnuPG is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * GNUPG is distributed in the hope that it will be useful, + * GnuPG 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. diff --git a/include/http.h b/include/http.h index 060b5b8fc..b9ce5b130 100644 --- a/include/http.h +++ b/include/http.h @@ -23,7 +23,7 @@ #ifndef G10_HTTP_H #define G10_HTTP_H 1 -#include "iobuf.h" +#include "../common/iobuf.h" struct uri_tuple { struct uri_tuple *next; @@ -65,8 +65,8 @@ struct http_context { unsigned int status_code; int sock; int in_data; - IOBUF fp_read; - IOBUF fp_write; + iobuf_t fp_read; + iobuf_t fp_write; int is_http_0_9; PARSED_URI uri; HTTP_REQ_TYPE req_type; diff --git a/include/iobuf.h b/include/iobuf.h deleted file mode 100644 index 0e3584c18..000000000 --- a/include/iobuf.h +++ /dev/null @@ -1,162 +0,0 @@ -/* iobuf.h - I/O buffer - * Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc. - * - * This file is part of GNUPG. - * - * GNUPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GNUPG is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ - -#ifndef G10_IOBUF_H -#define G10_IOBUF_H - -#include "types.h" - - -#define DBG_IOBUF iobuf_debug_mode - -#define IOBUFCTRL_INIT 1 -#define IOBUFCTRL_FREE 2 -#define IOBUFCTRL_UNDERFLOW 3 -#define IOBUFCTRL_FLUSH 4 -#define IOBUFCTRL_DESC 5 -#define IOBUFCTRL_CANCEL 6 -#define IOBUFCTRL_USER 16 - -typedef struct iobuf_struct *IOBUF; - -/* fixme: we should hide most of this stuff */ -struct iobuf_struct { - int use; /* 1 input , 2 output, 3 temp */ - off_t nlimit; - off_t nbytes; /* used together with nlimit */ - off_t ntotal; /* total bytes read (position of stream) */ - int nofast; /* used by the iobuf_get() */ - void *directfp; - struct { - size_t size; /* allocated size */ - size_t start; /* number of invalid bytes at the begin of the buffer */ - size_t len; /* currently filled to this size */ - byte *buf; - } d; - int filter_eof; - int error; - int (*filter)( void *opaque, int control, - IOBUF chain, byte *buf, size_t *len); - void *filter_ov; /* value for opaque */ - int filter_ov_owner; - char *real_fname; - IOBUF chain; /* next iobuf used for i/o if any (passed to filter) */ - int no, subno; - const char *desc; - void *opaque; /* can be used to hold any information */ - /* this value is copied to all instances */ - struct { - size_t size; /* allocated size */ - size_t start; /* number of invalid bytes at the begin of the buffer */ - size_t len; /* currently filled to this size */ - byte *buf; - } unget; -}; - -#ifndef EXTERN_UNLESS_MAIN_MODULE -#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE) -#define EXTERN_UNLESS_MAIN_MODULE extern -#else -#define EXTERN_UNLESS_MAIN_MODULE -#endif -#endif -EXTERN_UNLESS_MAIN_MODULE int iobuf_debug_mode; - -void iobuf_enable_special_filenames ( int yes ); -int iobuf_is_pipe_filename (const char *fname); -IOBUF iobuf_alloc(int use, size_t bufsize); -IOBUF iobuf_temp(void); -IOBUF iobuf_temp_with_content( const char *buffer, size_t length ); -IOBUF iobuf_open( const char *fname ); -IOBUF iobuf_fdopen( int fd, const char *mode ); -IOBUF iobuf_sockopen( int fd, const char *mode ); -IOBUF iobuf_create( const char *fname ); -IOBUF iobuf_append( const char *fname ); -IOBUF iobuf_openrw( const char *fname ); -int iobuf_ioctl ( IOBUF a, int cmd, int intval, void *ptrval ); -int iobuf_close( IOBUF iobuf ); -int iobuf_cancel( IOBUF iobuf ); - -int iobuf_push_filter( IOBUF a, int (*f)(void *opaque, int control, - IOBUF chain, byte *buf, size_t *len), void *ov ); -int iobuf_push_filter2( IOBUF a, - int (*f)(void *opaque, int control, - IOBUF chain, byte *buf, size_t *len), - void *ov, int rel_ov ); -int iobuf_flush(IOBUF a); -void iobuf_clear_eof(IOBUF a); -#define iobuf_set_error(a) do { (a)->error = 1; } while(0) -#define iobuf_error(a) ((a)->error) - -void iobuf_set_limit( IOBUF a, off_t nlimit ); - -off_t iobuf_tell( IOBUF a ); -int iobuf_seek( IOBUF a, off_t newpos ); - -int iobuf_readbyte(IOBUF a); -int iobuf_read(IOBUF a, byte *buf, unsigned buflen ); -unsigned iobuf_read_line( IOBUF a, byte **addr_of_buffer, - unsigned *length_of_buffer, unsigned *max_length ); -int iobuf_peek(IOBUF a, byte *buf, unsigned buflen ); -int iobuf_writebyte(IOBUF a, unsigned c); -int iobuf_write(IOBUF a, byte *buf, unsigned buflen ); -int iobuf_writestr(IOBUF a, const char *buf ); - -void iobuf_flush_temp( IOBUF temp ); -int iobuf_write_temp( IOBUF a, IOBUF temp ); -size_t iobuf_temp_to_buffer( IOBUF a, byte *buffer, size_t buflen ); -void iobuf_unget_and_close_temp( IOBUF a, IOBUF temp ); - -int iobuf_get_fd (IOBUF a); -off_t iobuf_get_filelength (IOBUF a, int *overflow); -#define IOBUF_FILELENGTH_LIMIT 0xffffffff -const char *iobuf_get_real_fname( IOBUF a ); -const char *iobuf_get_fname( IOBUF a ); - -void iobuf_set_partial_block_mode( IOBUF a, size_t len ); - -int iobuf_translate_file_handle ( int fd, int for_write ); - -/* Get a byte form the iobuf; must check for eof prior to this function. - * This function returns values in the range 0 .. 255 or -1 to indicate EOF - * iobuf_get_noeof() does not return -1 to indicate EOF, but masks the - * returned value to be in the range 0..255. - */ -#define iobuf_get(a) \ - ( ((a)->nofast || (a)->d.start >= (a)->d.len )? \ - iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) ) -#define iobuf_get_noeof(a) (iobuf_get((a))&0xff) - -/* write a byte to the iobuf and return true on write error - * This macro does only write the low order byte - */ -#define iobuf_put(a,c) iobuf_writebyte(a,c) - -#define iobuf_where(a) "[don't know]" -#define iobuf_id(a) ((a)->no) - -#define iobuf_get_temp_buffer(a) ( (a)->d.buf ) -#define iobuf_get_temp_length(a) ( (a)->d.len ) -#define iobuf_is_temp(a) ( (a)->use == 3 ) - -void iobuf_skip_rest (IOBUF a, unsigned long n, int partial); - -#endif /*G10_IOBUF_H*/ diff --git a/include/keyserver.h b/include/keyserver.h index 8900dbe6e..7bd12625e 100644 --- a/include/keyserver.h +++ b/include/keyserver.h @@ -1,14 +1,14 @@ /* keyserver.h - * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * - * This file is part of GNUPG. + * This file is part of GnuPG. * - * GNUPG is free software; you can redistribute it and/or modify + * GnuPG is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * GNUPG is distributed in the hope that it will be useful, + * GnuPG 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. diff --git a/include/memory.h b/include/memory.h index 895d8a771..2e2f8fdce 100644 --- a/include/memory.h +++ b/include/memory.h @@ -1,5 +1,5 @@ /* memory.h - memory allocation - * Copyright (C) 1998, 1999, 2000, 2001, 2005 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -22,6 +22,8 @@ #ifndef G10_MEMORY_H #define G10_MEMORY_H +#error this file should not be used anymore + #ifdef M_DEBUG #ifndef STR #define STR(v) #v @@ -31,15 +33,15 @@ #else /* __riscos__ */ #define M_DBGINFO(a) "["__FILE__ ":" STR(a) "]" #endif /* __riscos__ */ -#define xmalloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) ) -#define xmalloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) ) -#define xmalloc_secure(n) m_debug_alloc_secure(n), M_DBGINFO(__LINE__) ) -#define xmalloc_secure_clear(n) m_debug_alloc_secure_clear((n), M_DBGINFO(__LINE__) ) -#define xrealloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) ) -#define xfree(n) m_debug_free((n), M_DBGINFO(__LINE__) ) +#define m_alloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) ) +#define m_alloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) ) +#define m_alloc_secure(n) m_debug_alloc((n), M_DBGINFO(__LINE__) ) +#define m_alloc_secure_clear(n) m_debug_alloc_secure_clear((n), M_DBGINFO(__LINE__) ) +#define m_realloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) ) +#define m_free(n) m_debug_free((n), M_DBGINFO(__LINE__) ) #define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) ) /*#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )*/ -#define xstrdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) ) +#define m_strdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) ) void *m_debug_alloc( size_t n, const char *info ); void *m_debug_alloc_clear( size_t n, const char *info ); @@ -52,30 +54,25 @@ void m_debug_check( const void *a, const char *info ); char *m_debug_strdup( const char *a, const char *info ); #else -void *xmalloc( size_t n ); -void *xmalloc_clear( size_t n ); -void *xmalloc_secure( size_t n ); -void *xmalloc_secure_clear( size_t n ); -void *xrealloc( void *a, size_t n ); -void xfree( void *p ); +void *m_alloc( size_t n ); +void *m_alloc_clear( size_t n ); +void *m_alloc_secure( size_t n ); +void *m_alloc_secure_clear( size_t n ); +void *m_realloc( void *a, size_t n ); +void m_free( void *p ); void m_check( const void *a ); /*void *m_copy( const void *a );*/ -char *xstrdup( const char * a); +char *m_strdup( const char * a); #endif size_t m_size( const void *a ); void m_print_stats(const char *prefix); -/* The follwing functions should be preferred over xmalloc_clear. */ -void *xcalloc (size_t n, size_t m); -void *xcalloc_secure (size_t n, size_t m); - - /*-- secmem.c --*/ -int secmem_init( size_t npool ); +void secmem_init( size_t npool ); void secmem_term( void ); void *secmem_malloc( size_t size ); -void *secmexrealloc( void *a, size_t newsize ); +void *secmem_realloc( void *a, size_t newsize ); void secmem_free( void *a ); int m_is_secure( const void *p ); void secmem_dump_stats(void); @@ -96,6 +93,4 @@ unsigned secmem_get_flags(void); EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode; EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode; - - #endif /*G10_MEMORY_H*/ diff --git a/include/mpi.h b/include/mpi.h index bec37ce6c..7402ef6d3 100644 --- a/include/mpi.h +++ b/include/mpi.h @@ -31,6 +31,13 @@ #ifndef G10_MPI_H #define G10_MPI_H +#error this file should not be used anymore + +#include <gcrypt.h> + +#if 0 + + #include <config.h> #include <stdio.h> #include "iobuf.h" @@ -69,11 +76,11 @@ EXTERN_UNLESS_MAIN_MODULE int mpi_debug_mode; struct gcry_mpi { int alloced; /* array size (# of allocated limbs) */ int nlimbs; /* number of valid limbs */ - unsigned int nbits; /* the real number of valid bits (info only) */ + int nbits; /* the real number of valid bits (info only) */ int sign; /* indicates a negative number */ unsigned flags; /* bit 0: array must be allocated in secure memory space */ /* bit 1: not used */ - /* bit 2: the limb is a pointer to some xmalloced data */ + /* bit 2: the limb is a pointer to some m_alloced data */ mpi_limb_t *d; /* array with the limbs */ }; @@ -108,8 +115,8 @@ void mpi_resize( MPI a, unsigned nlimbs ); MPI mpi_copy( MPI a ); #endif #define mpi_is_opaque(a) ((a) && ((a)->flags&4)) -MPI mpi_set_opaque( MPI a, void *p, unsigned int len ); -void *mpi_get_opaque( MPI a, unsigned int *len ); +MPI mpi_set_opaque( MPI a, void *p, int len ); +void *mpi_get_opaque( MPI a, int *len ); #define mpi_is_secure(a) ((a) && ((a)->flags&1)) void mpi_set_secure( MPI a ); void mpi_clear( MPI a ); @@ -167,7 +174,7 @@ int mpi_gcd( MPI g, MPI a, MPI b ); /*-- mpi-pow.c --*/ void mpi_pow( MPI w, MPI u, MPI v); -void mpi_powm( MPI res, MPI base, MPI exponent, MPI mod); +void mpi_powm( MPI res, MPI base, MPI exp, MPI mod); /*-- mpi-mpow.c --*/ void mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI mod); @@ -193,5 +200,5 @@ void mpi_rshift( MPI x, MPI a, unsigned n ); /*-- mpi-inv.c --*/ void mpi_invm( MPI x, MPI u, MPI v ); - +#endif #endif /*G10_MPI_H*/ diff --git a/include/ttyio.h b/include/ttyio.h deleted file mode 100644 index 2c52fc3e9..000000000 --- a/include/ttyio.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ttyio.h - * Copyright (C) 1998, 1999, 2000, 2001, 2005 Free Software Foundation, Inc. - * - * This file is part of GNUPG. - * - * GNUPG is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GNUPG is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - */ -#ifndef G10_TTYIO_H -#define G10_TTYIO_H - -#ifdef HAVE_LIBREADLINE -#include <stdio.h> -#include <readline/readline.h> -#endif - -const char *tty_get_ttyname (void); -int tty_batchmode( int onoff ); -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) - void tty_printf (const char *fmt, ... ) __attribute__ ((format (printf,1,2))); - void tty_fprintf (FILE *fp, const char *fmt, ... ) - __attribute__ ((format (printf,2,3))); -#else - void tty_printf (const char *fmt, ... ); - void tty_fprintf (FILE *fp, const char *fmt, ... ); -#endif -void tty_print_string( const byte *p, size_t n ); -void tty_print_utf8_string( const byte *p, size_t n ); -void tty_print_utf8_string2( const byte *p, size_t n, size_t max_n ); -char *tty_get( const char *prompt ); -char *tty_get_hidden( const char *prompt ); -void tty_kill_prompt(void); -int tty_get_answer_is_yes( const char *prompt ); -int tty_no_terminal(int onoff); - -#ifdef HAVE_LIBREADLINE -void tty_enable_completion(rl_completion_func_t *completer); -void tty_disable_completion(void); -#else -/* Use a macro to stub out these functions since a macro has no need - to typedef a "rl_completion_func_t" which would be undefined - without readline. */ -#define tty_enable_completion(x) -#define tty_disable_completion() -#endif - -#endif /*G10_TTYIO_H*/ diff --git a/include/types.h b/include/types.h index 3b85b10e1..6abd500e3 100644 --- a/include/types.h +++ b/include/types.h @@ -1,14 +1,14 @@ /* types.h - some common typedefs * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * - * This file is part of GNUPG. + * This file is part of GnuPG. * - * GNUPG is free software; you can redistribute it and/or modify + * GnuPG is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * GNUPG is distributed in the hope that it will be useful, + * GnuPG 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. @@ -133,10 +133,4 @@ typedef union { double g; } PROPERLY_ALIGNED_TYPE; -typedef struct string_list { - struct string_list *next; - unsigned int flags; - char d[1]; -} *STRLIST; - #endif /*G10_TYPES_H*/ diff --git a/include/util.h b/include/util.h index ee25be12e..1d6d01366 100644 --- a/include/util.h +++ b/include/util.h @@ -1,6 +1,5 @@ /* util.h - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -22,7 +21,10 @@ #ifndef G10_UTIL_H #define G10_UTIL_H -#if defined (_WIN32) || defined (__CYGWIN32__) +#error this file should not be used anymore +#if 0 /* Dont use it anymore */ + +#if defined (__MINGW32__) || defined (__CYGWIN32__) #include <stdarg.h> #endif @@ -86,6 +88,14 @@ void g10_log_hexdump( const char *text, const char *buf, size_t len ); void g10_log_info( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); void g10_log_warning( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); void g10_log_debug( const char *fmt, ... ) __attribute__ ((format (printf,1,2))); + void g10_log_fatal_f( const char *fname, const char *fmt, ... ) + __attribute__ ((noreturn, format (printf,2,3))); + void g10_log_error_f( const char *fname, const char *fmt, ... ) + __attribute__ ((format (printf,2,3))); + void g10_log_info_f( const char *fname, const char *fmt, ... ) + __attribute__ ((format (printf,2,3))); + void g10_log_debug_f( const char *fname, const char *fmt, ... ) + __attribute__ ((format (printf,2,3))); #ifndef __riscos__ #define BUG() g10_log_bug0( __FILE__ , __LINE__, __FUNCTION__ ) #else @@ -99,6 +109,10 @@ void g10_log_hexdump( const char *text, const char *buf, size_t len ); void g10_log_info( const char *fmt, ... ); void g10_log_warning( const char *fmt, ... ); void g10_log_debug( const char *fmt, ... ); + void g10_log_fatal_f( const char *fname, const char *fmt, ... ); + void g10_log_error_f( const char *fname, const char *fmt, ... ); + void g10_log_info_f( const char *fname, const char *fmt, ... ); + void g10_log_debug_f( const char *fname, const char *fmt, ... ); #define BUG() g10_log_bug0( __FILE__ , __LINE__ ) #endif @@ -110,11 +124,12 @@ void g10_log_hexdump( const char *text, const char *buf, size_t len ); #define log_info g10_log_info #define log_warning g10_log_warning #define log_debug g10_log_debug +#define log_fatal_f g10_log_fatal_f +#define log_error_f g10_log_error_f +#define log_info_f g10_log_info_f +#define log_debug_f g10_log_debug_f -/*-- errors.c --*/ -const char * g10_errstr( int no ); - /*-- argparse.c --*/ int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts); int optfile_parse( FILE *fp, const char *filename, unsigned *lineno, @@ -133,7 +148,6 @@ typedef struct dotlock_handle *DOTLOCK; void disable_dotlock(void); DOTLOCK create_dotlock( const char *file_to_lock ); -void destroy_dotlock ( DOTLOCK h ); int make_dotlock( DOTLOCK h, long timeout ); int release_dotlock( DOTLOCK h ); void remove_lockfiles (void); @@ -145,37 +159,28 @@ char *make_filename( const char *first_part, ... ); int compare_filenames( const char *a, const char *b ); const char *print_fname_stdin( const char *s ); const char *print_fname_stdout( const char *s ); -int is_file_compressed(const char *s, int *r_status); +int is_file_compressed(const char *s, int *r_status); + /*-- miscutil.c --*/ u32 make_timestamp(void); u32 scan_isodatestr( const char *string ); +u32 add_days_to_timestamp( u32 stamp, u16 days ); const char *strtimevalue( u32 stamp ); const char *strtimestamp( u32 stamp ); /* GMT */ -const char *isotimestamp( u32 stamp ); /* GMT with hh:mm:ss */ const char *asctimestamp( u32 stamp ); /* localized */ void print_string( FILE *fp, const byte *p, size_t n, int delim ); -void print_string2( FILE *fp, const byte *p, size_t n, int delim, int delim2 ); void print_utf8_string( FILE *fp, const byte *p, size_t n ); void print_utf8_string2( FILE *fp, const byte *p, size_t n, int delim); char *make_printable_string( const byte *p, size_t n, int delim ); int answer_is_yes_no_default( const char *s, int def_answer ); int answer_is_yes( const char *s ); int answer_is_yes_no_quit( const char *s ); -int answer_is_okay_cancel (const char *s, int def_answer); -int match_multistr(const char *multistr,const char *match); -int hextobyte( const char *s ); /*-- strgutil.c --*/ -void free_strlist( STRLIST sl ); -#define FREE_STRLIST(a) do { free_strlist((a)); (a) = NULL ; } while(0) -STRLIST add_to_strlist( STRLIST *list, const char *string ); -STRLIST add_to_strlist2( STRLIST *list, const char *string, int is_utf8 ); -STRLIST append_to_strlist( STRLIST *list, const char *string ); -STRLIST append_to_strlist2( STRLIST *list, const char *string, int is_utf8 ); -STRLIST strlist_prev( STRLIST head, STRLIST node ); -STRLIST strlist_last( STRLIST node ); -char *pop_strlist( STRLIST *list ); + +#include "../jnlib/strlist.h" + const char *memistr( const char *buf, size_t buflen, const char *sub ); const char *ascii_memistr( const char *buf, size_t buflen, const char *sub ); char *mem2str( char *, const void *, size_t); @@ -223,25 +228,7 @@ int strncasecmp (const char *, const char *b, size_t n); #define memmove(d, s, n) bcopy((s), (d), (n)) #endif -/*-- membuf.c --*/ -/* The definition of the structure is private, we only need it here, - so it can be allocated on the stack. */ -struct private_membuf_s { - size_t len; - size_t size; - char *buf; - int out_of_core; -}; - -typedef struct private_membuf_s membuf_t; - -void init_membuf (membuf_t *mb, int initiallen); -void put_membuf (membuf_t *mb, const void *buf, size_t len); -void *get_membuf (membuf_t *mb, size_t *len); - - - -#if defined (_WIN32) +#if defined (__MINGW32__) /*-- w32reg.c --*/ char *read_w32_registry_string( const char *root, const char *dir, const char *name ); @@ -249,16 +236,8 @@ int write_w32_registry_string(const char *root, const char *dir, const char *name, const char *value); /*-- strgutil.c --*/ -int vasprintf (char **result, const char *format, va_list args); -int asprintf (char **buf, const char *fmt, ...); -#endif /*_WIN32*/ - -/*-- pka.c --*/ -char *get_pka_info (const char *address, unsigned char *fpr); - -/*-- cert.c --*/ -int get_cert(const char *name,size_t max_size,IOBUF *iobuf, - unsigned char **fpr,size_t *fpr_len,char **url); +int vasprintf ( char **result, const char *format, va_list args); +#endif /**** other missing stuff ****/ #ifndef HAVE_ATEXIT /* For SunOS */ @@ -269,10 +248,6 @@ int get_cert(const char *name,size_t max_size,IOBUF *iobuf, #define raise(a) kill(getpid(), (a)) #endif -/*-- Replacement functions from funcname.c --*/ - - - /******** some macros ************/ #ifndef STR #define STR(v) #v @@ -284,26 +259,16 @@ int get_cert(const char *name,size_t max_size,IOBUF *iobuf, #define wipememory2(_ptr,_set,_len) do { volatile char *_vptr=(volatile char *)(_ptr); size_t _vlen=(_len); while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } } while(0) #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) -/*-- macros to replace ctype ones and avoid locale problems --*/ -#define spacep(p) (*(p) == ' ' || *(p) == '\t') -#define digitp(p) (*(p) >= '0' && *(p) <= '9') -#define hexdigitp(a) (digitp (a) \ - || (*(a) >= 'A' && *(a) <= 'F') \ - || (*(a) >= 'a' && *(a) <= 'f')) -/* the atoi macros assume that the buffer has only valid digits */ -#define atoi_1(p) (*(p) - '0' ) -#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) -#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2)) -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) - -/* Note this isn't identical to a C locale isspace() without \f and - \v, but works for the purposes used here. */ -#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t') - /******* RISC OS stuff ***********/ #ifdef __riscos__ +/* needed for strcasecmp() */ +#include <strings.h> +/* needed for filename munging */ +#include <unixlib/local.h> +/* needed for image file system feature */ +#include <unixlib/features.h> +void riscos_global_defaults(void); +#define RISCOS_GLOBAL_STATICS(a) const char *__dynamic_da_name = (a); int riscos_load_module(const char *name, const char * const path[], int fatal); int riscos_get_filetype_from_string(const char *string, int len); int riscos_get_filetype(const char *filename); @@ -331,4 +296,6 @@ void riscos_list_openfiles(void); #endif /* !__RISCOS__C__ */ #endif /* __riscos__ */ +#endif + #endif /*G10_UTIL_H*/ |
