summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-10-31 10:48:01 +0000
committerWerner Koch <wk@gnupg.org>2007-10-31 10:48:01 +0000
commit68a0d855c92cb6cd7030abc7e191d1c513ad2a62 (patch)
tree549e9edd57faa05b22fa15392ba051c098fc2c4e
parentf9c80d236b62c5f2ac4c4d096e4adbd40b10d3a2 (diff)
downloadlibgcrypt-68a0d855c92cb6cd7030abc7e191d1c513ad2a62.tar.gz
Reorganizatiosn to support the visibility attribute.
This can be improved by using fucntion aliases instead of wrapper functions.
-rw-r--r--ChangeLog4
-rw-r--r--NEWS2
-rw-r--r--TODO7
-rw-r--r--cipher/ChangeLog23
-rw-r--r--cipher/ac.c424
-rw-r--r--configure.ac87
-rw-r--r--doc/gcrypt.texi13
-rw-r--r--mpi/ChangeLog13
-rw-r--r--mpi/mpi-inv.c16
-rw-r--r--mpi/mpi-mod.c8
-rw-r--r--mpi/mpi-mul.c9
-rw-r--r--mpi/mpiutil.c112
-rw-r--r--src/ChangeLog21
-rw-r--r--src/Makefile.am4
-rw-r--r--src/g10lib.h39
-rw-r--r--src/gcrypt-module.h5
-rw-r--r--src/gcrypt.h.in28
-rw-r--r--src/global.c55
-rw-r--r--src/hwfeatures.c69
-rw-r--r--src/libgcrypt.def2
-rw-r--r--src/libgcrypt.vers5
-rw-r--r--src/mpi.h3
-rw-r--r--src/sexp.c18
-rw-r--r--src/versioninfo.rc.in3
-rw-r--r--src/visibility.c1287
-rw-r--r--src/visibility.h710
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/benchmark.c67
28 files changed, 2437 insertions, 601 deletions
diff --git a/ChangeLog b/ChangeLog
index 2515cbc7..66395685 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-10-30 Werner Koch <wk@g10code.com>
+
+ * configure.ac: Protect config.h against double inclusion.
+
2007-10-26 Werner Koch <wk@g10code.com>
Released 1.3.1.
diff --git a/NEWS b/NEWS
index 00749558..893e9eb5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
Noteworthy changes in version 1.3.2
------------------------------------------------
+ * Make use of the visibility attribute if supported.
+
Noteworthy changes in version 1.3.1 (2007-10-26)
------------------------------------------------
diff --git a/TODO b/TODO
index 6a2a3d53..cdaa8e2d 100644
--- a/TODO
+++ b/TODO
@@ -18,8 +18,6 @@ What's left to do -*- outline -*-
Write an autoconf test to check whether the linker supports a
version script.
-* Make use of the forthcoming visibility attribute.
-
* Add attributes to the MPI functions.
* In case the ac interface will be more popular than the pk interface,
@@ -83,9 +81,6 @@ What's left to do -*- outline -*-
* gcry_mpi_lshift is missing
-* Add internal versions of mpi functions
- Or make use of the visibility attribute.
-
* Add OAEP
* gcryptrnd.c
@@ -112,3 +107,5 @@ What's left to do -*- outline -*-
* /dev/urandom and Solaris
Make the configure check similar to GnuPG.
+
+* Use aliases for symbol instead of the wrappers in visibility.c.
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 89aa50ff..2fd4863f 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,23 @@
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * ac.c (gcry_ac_data_new): Remove due to the visibility wrapper.
+ (gcry_ac_data_destroy, gcry_ac_data_copy, gcry_ac_data_length)
+ (gcry_ac_data_set, gcry_ac_data_get_name, gcry_ac_data_get_index)
+ (gcry_ac_data_to_sexp, gcry_ac_data_from_sexp)
+ (gcry_ac_data_clear, gcry_ac_io_init, gcry_ac_open)
+ (gcry_ac_close, gcry_ac_key_init, gcry_ac_key_pair_generate)
+ (gcry_ac_key_pair_extract, gcry_ac_key_destroy)
+ (gcry_ac_key_pair_destroy, gcry_ac_key_data_get)
+ (gcry_ac_key_test, gcry_ac_key_get_nbits, gcry_ac_key_get_grip)
+ (gcry_ac_data_encrypt, gcry_ac_data_decrypt, gcry_ac_data_sign)
+ (gcry_ac_data_verify, gcry_ac_data_encode, gcry_ac_data_decode)
+ (gcry_ac_mpi_to_os, gcry_ac_mpi_to_os_alloc, gcry_ac_os_to_mpi)
+ (gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme)
+ (gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme)
+ (gcry_ac_io_init_va): Ditto.
+ (gcry_ac_id_to_name, gcry_ac_name_to_id): Remove as these
+ deprecated functions are now implemented by visibility.c.
+
2007-10-26 Werner Koch <wk@g10code.com>
* rndw32.c: Disable debug flag.
@@ -3391,7 +3411,8 @@ Mon Feb 16 10:08:47 1998 Werner Koch (wk@isil.d.shuttle.de)
(digest_algo_to_string): New.
- Copyright 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ Copyright 1998,1999,2000,2001,2002,2003,2004,2005,2006
+ 2007 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
diff --git a/cipher/ac.c b/cipher/ac.c
index 8a2ae104..a245fa3b 100644
--- a/cipher/ac.c
+++ b/cipher/ac.c
@@ -1,5 +1,6 @@
/* ac.c - Alternative interface for asymmetric cryptography.
- Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006
+ 2007 Free Software Foundation, Inc.
This file is part of Libgcrypt.
@@ -14,9 +15,8 @@
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
#include <config.h>
#include <errno.h>
@@ -144,16 +144,6 @@ _gcry_ac_data_new (gcry_ac_data_t *data)
return err;
}
-gcry_error_t
-gcry_ac_data_new (gcry_ac_data_t *data)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_new (data);
-
- return gcry_error (err);
-}
-
/* Destroys all the entries in DATA, but not DATA itself. */
static void
ac_data_values_destroy (gcry_ac_data_t data)
@@ -180,12 +170,6 @@ _gcry_ac_data_destroy (gcry_ac_data_t data)
}
}
-void
-gcry_ac_data_destroy (gcry_ac_data_t data)
-{
- return _gcry_ac_data_destroy (data);
-}
-
/* This function creates a copy of the array of named MPIs DATA_MPIS,
which is of length DATA_MPIS_N; the copy is stored in
DATA_MPIS_CP. */
@@ -280,12 +264,6 @@ _gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
return err;
}
-gcry_error_t
-gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
-{
- return gcry_error (_gcry_ac_data_copy (data_cp, data));
-}
-
/* Returns the number of named MPI values inside of the data set
DATA. */
unsigned int
@@ -294,11 +272,6 @@ _gcry_ac_data_length (gcry_ac_data_t data)
return data->data_n;
}
-unsigned int
-gcry_ac_data_length (gcry_ac_data_t data)
-{
- return _gcry_ac_data_length (data);
-}
/* Add the value MPI to DATA with the label NAME. If FLAGS contains
GCRY_AC_FLAG_COPY, the data set will contain copies of NAME
@@ -385,13 +358,6 @@ _gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
return err;
}
-gcry_error_t
-gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
- const char *name, gcry_mpi_t mpi)
-{
- return gcry_error (_gcry_ac_data_set (data, flags, name, mpi));
-}
-
/* Stores the value labelled with NAME found in the data set DATA in
MPI. The returned MPI value will be released in case
gcry_ac_data_set is used to associate the label NAME with a
@@ -439,13 +405,6 @@ _gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
return err;
}
-gcry_error_t
-gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
- const char *name, gcry_mpi_t *mpi)
-{
- return gcry_error (_gcry_ac_data_get_name (data, flags, name, mpi));
-}
-
/* Stores in NAME and MPI the named MPI value contained in the data
set DATA with the index IDX. NAME or MPI may be NULL. The
returned MPI value will be released in case gcry_ac_data_set is
@@ -514,13 +473,6 @@ _gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
return err;
}
-gcry_error_t
-gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
- unsigned int idx, const char **name, gcry_mpi_t *mpi)
-{
- return gcry_error (_gcry_ac_data_get_index (data, flags, idx, name, mpi));
-}
-
/* Convert the data set DATA into a new S-Expression, which is to be
stored in SEXP, according to the identifiers contained in
IDENTIFIERS. */
@@ -648,17 +600,6 @@ _gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
return err;
}
-gcry_error_t
-gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
- const char **identifiers)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_to_sexp (data, sexp, identifiers);
-
- return gcry_error (err);
-}
-
/* Create a new data set, which is to be stored in DATA_SET, from the
S-Expression SEXP, according to the identifiers contained in
IDENTIFIERS. */
@@ -839,16 +780,6 @@ _gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp,
return err;
}
-gcry_error_t
-gcry_ac_data_from_sexp (gcry_ac_data_t *data_set, gcry_sexp_t sexp,
- const char **identifiers)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_from_sexp (data_set, sexp, identifiers);
-
- return gcry_error (err);
-}
static void
_gcry_ac_data_dump (const char *prefix, gcry_ac_data_t data)
@@ -913,12 +844,6 @@ _gcry_ac_data_clear (gcry_ac_data_t data)
data->data_n = 0;
}
-void
-gcry_ac_data_clear (gcry_ac_data_t data)
-{
- return _gcry_ac_data_clear (data);
-}
-
/*
@@ -928,7 +853,7 @@ gcry_ac_data_clear (gcry_ac_data_t data)
/* Initialize AC_IO according to MODE, TYPE and the variable list of
arguments AP. The list of variable arguments to specify depends on
the given TYPE. */
-static void
+void
_gcry_ac_io_init_va (gcry_ac_io_t *ac_io,
gcry_ac_io_mode_t mode, gcry_ac_io_type_t type, va_list ap)
{
@@ -973,17 +898,10 @@ _gcry_ac_io_init_va (gcry_ac_io_t *ac_io,
}
}
-void
-gcry_ac_io_init_va (gcry_ac_io_t *ac_io,
- gcry_ac_io_mode_t mode, gcry_ac_io_type_t type, va_list ap)
-{
- _gcry_ac_io_init_va (ac_io, mode, type, ap);
-}
-
/* Initialize AC_IO according to MODE, TYPE and the variable list of
arguments. The list of variable arguments to specify depends on
the given TYPE. */
-static void
+void
_gcry_ac_io_init (gcry_ac_io_t *ac_io,
gcry_ac_io_mode_t mode, gcry_ac_io_type_t type, ...)
{
@@ -995,17 +913,6 @@ _gcry_ac_io_init (gcry_ac_io_t *ac_io,
}
-void
-gcry_ac_io_init (gcry_ac_io_t *ac_io,
- gcry_ac_io_mode_t mode, gcry_ac_io_type_t type, ...)
-{
- va_list ap;
-
- va_start (ap, type);
- _gcry_ac_io_init_va (ac_io, mode, type, ap);
- va_end (ap);
-}
-
/* Write to the IO object AC_IO BUFFER_N bytes from BUFFER. Return
zero on success or error code. */
static gcry_error_t
@@ -1492,16 +1399,6 @@ _gcry_ac_open (gcry_ac_handle_t *handle,
return err;
}
-gcry_error_t
-gcry_ac_open (gcry_ac_handle_t *handle,
- gcry_ac_id_t algorithm, unsigned int flags)
-{
- gcry_error_t err;
-
- err = _gcry_ac_open (handle, algorithm, flags);
-
- return gcry_error (err);
-}
/* Destroys the handle HANDLE. */
void
@@ -1515,14 +1412,8 @@ _gcry_ac_close (gcry_ac_handle_t handle)
}
}
-void
-gcry_ac_close (gcry_ac_handle_t handle)
-{
- _gcry_ac_close (handle);
-}
-
/*
* Key management.
*/
@@ -1567,16 +1458,6 @@ _gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
- gcry_ac_key_type_t type, gcry_ac_data_t data)
-{
- gcry_error_t err;
-
- err = _gcry_ac_key_init (key, handle, type, data);
-
- return gcry_error (err);
-}
/* Generates a new key pair via the handle HANDLE of NBITS bits and
stores it in KEY_PAIR. In case non-standard settings are wanted, a
@@ -1762,20 +1643,10 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits,
return err;
}
-gcry_error_t
-gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits, void *key_spec,
- gcry_ac_key_pair_t *key_pair, gcry_mpi_t **misc_data)
-{
- gcry_error_t err;
-
- err = _gcry_ac_key_pair_generate (handle, nbits, key_spec, key_pair, misc_data);
-
- return gcry_error (err);
-}
-
/* Returns the key of type WHICH out of the key pair KEY_PAIR. */
gcry_ac_key_t
-_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair, gcry_ac_key_type_t which)
+_gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair,
+ gcry_ac_key_type_t which)
{
gcry_ac_key_t key;
@@ -1797,16 +1668,6 @@ _gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair, gcry_ac_key_type_t which
return key;
}
-gcry_ac_key_t
-gcry_ac_key_pair_extract (gcry_ac_key_pair_t key_pair, gcry_ac_key_type_t which)
-{
- gcry_ac_key_t key;
-
- key = _gcry_ac_key_pair_extract (key_pair, which);
-
- return key;
-}
-
/* Destroys the key KEY. */
void
_gcry_ac_key_destroy (gcry_ac_key_t key)
@@ -1826,12 +1687,6 @@ _gcry_ac_key_destroy (gcry_ac_key_t key)
}
}
-void
-gcry_ac_key_destroy (gcry_ac_key_t key)
-{
- _gcry_ac_key_destroy (key);
-}
-
/* Destroys the key pair KEY_PAIR. */
void
_gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
@@ -1844,12 +1699,6 @@ _gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
}
}
-void
-gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
-{
- _gcry_ac_key_pair_destroy (key_pair);
-}
-
/* Returns the data set contained in the key KEY. */
gcry_ac_data_t
_gcry_ac_key_data_get (gcry_ac_key_t key)
@@ -1857,16 +1706,6 @@ _gcry_ac_key_data_get (gcry_ac_key_t key)
return key->data;
}
-gcry_ac_data_t
-gcry_ac_key_data_get (gcry_ac_key_t key)
-{
- gcry_ac_data_t data;
-
- data = _gcry_ac_key_data_get (key);
-
- return data;
-}
-
/* Verifies that the key KEY is sane via HANDLE. */
gcry_error_t
_gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
@@ -1889,16 +1728,6 @@ _gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
return gcry_error (err);
}
-gcry_error_t
-gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
-{
- gcry_error_t err;
-
- err = _gcry_ac_key_test (handle, key);
-
- return gcry_error (err);
-}
-
/* Stores the number of bits of the key KEY in NBITS via HANDLE. */
gcry_error_t
_gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
@@ -1931,17 +1760,6 @@ _gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
- gcry_ac_key_t key, unsigned int *nbits)
-{
- gcry_error_t err;
-
- err = _gcry_ac_key_get_nbits (handle, key, nbits);
-
- return gcry_error (err);
-}
-
/* Writes the 20 byte long key grip of the key KEY to KEY_GRIP via
HANDLE. */
gcry_error_t
@@ -1974,17 +1792,6 @@ _gcry_ac_key_get_grip (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_key_get_grip (gcry_ac_handle_t handle,
- gcry_ac_key_t key, unsigned char *key_grip)
-{
- gcry_error_t err;
-
- err = _gcry_ac_key_get_grip (handle, key, key_grip);
-
- return gcry_error (err);
-}
-
@@ -2065,20 +1872,6 @@ _gcry_ac_data_encrypt (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_data_encrypt (gcry_ac_handle_t handle,
- unsigned int flags,
- gcry_ac_key_t key,
- gcry_mpi_t data_plain,
- gcry_ac_data_t *data_encrypted)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_encrypt (handle, flags, key, data_plain, data_encrypted);
-
- return gcry_error (err);
-}
-
/* Decrypts the encrypted data contained in the data set
DATA_ENCRYPTED with the secret key KEY under the control of the
flags FLAGS and stores the resulting plain text MPI value in
@@ -2154,20 +1947,6 @@ _gcry_ac_data_decrypt (gcry_ac_handle_t handle,
}
-gcry_error_t
-gcry_ac_data_decrypt (gcry_ac_handle_t handle,
- unsigned int flags,
- gcry_ac_key_t key,
- gcry_mpi_t *data_plain,
- gcry_ac_data_t data_encrypted)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_decrypt (handle, flags, key, data_plain, data_encrypted);
-
- return gcry_error (err);
-}
-
/* Signs the data contained in DATA with the secret key KEY and stores
the resulting signature data set in DATA_SIGNATURE. */
gcry_error_t
@@ -2237,19 +2016,6 @@ _gcry_ac_data_sign (gcry_ac_handle_t handle,
return gcry_error (err);
}
-gcry_error_t
-gcry_ac_data_sign (gcry_ac_handle_t handle,
- gcry_ac_key_t key,
- gcry_mpi_t data,
- gcry_ac_data_t *data_signature)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_sign (handle, key, data, data_signature);
-
- return gcry_error (err);
-}
-
/* Verifies that the signature contained in the data set
DATA_SIGNATURE is indeed the result of signing the data contained
@@ -2314,22 +2080,9 @@ _gcry_ac_data_verify (gcry_ac_handle_t handle,
return gcry_error (err);
}
-gcry_error_t
-gcry_ac_data_verify (gcry_ac_handle_t handle,
- gcry_ac_key_t key,
- gcry_mpi_t data,
- gcry_ac_data_t data_signature)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_verify (handle, key, data, data_signature);
- return gcry_error (err);
-}
-
-
/*
* Implementation of encoding methods (em).
*/
@@ -2766,34 +2519,6 @@ _gcry_ac_data_decode (gcry_ac_em_t method,
ac_io_read, ac_io_write);
}
-gcry_error_t
-gcry_ac_data_encode (gcry_ac_em_t method,
- unsigned int flags, void *options,
- gcry_ac_io_t *ac_io_read,
- gcry_ac_io_t *ac_io_write)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_encode (method, flags, options,
- ac_io_read, ac_io_write);
-
- return gcry_error (err);
-}
-
-gcry_error_t
-gcry_ac_data_decode (gcry_ac_em_t method,
- unsigned int flags, void *options,
- gcry_ac_io_t *ac_io_read,
- gcry_ac_io_t *ac_io_write)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_decode (method, flags, options,
- ac_io_read, ac_io_write);
-
- return gcry_error (err);
-}
-
/* Convert an MPI into an octet string. */
void
_gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
@@ -2834,13 +2559,6 @@ _gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
gcry_mpi_release (m);
}
-/* Convert an MPI into an octet string (I2OSP). */
-void
-gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
-{
- _gcry_ac_mpi_to_os (mpi, os, os_n);
-}
-
/* Convert an MPI into an newly allocated octet string. */
gcry_error_t
_gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, size_t *os_n)
@@ -2869,15 +2587,6 @@ _gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, size_t *os_n)
return err;
}
-gcry_error_t
-gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os, size_t *os_n)
-{
- gcry_error_t err;
-
- err = _gcry_ac_mpi_to_os_alloc (mpi, os, os_n);
-
- return gcry_error (err);
-}
/* Convert an octet string into an MPI. */
void
@@ -2908,14 +2617,8 @@ _gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
gcry_mpi_release (x); /* FIXME: correct? */
}
-void
-gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n)
-{
- _gcry_ac_os_to_mpi (mpi, os, os_n);
-}
-
/*
* Implementation of Encryption Schemes (ES) and Signature Schemes
* with Appendix (SSA).
@@ -3173,22 +2876,6 @@ _gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
- gcry_ac_scheme_t scheme_id,
- unsigned int flags, void *opts,
- gcry_ac_key_t key,
- gcry_ac_io_t *io_message,
- gcry_ac_io_t *io_cipher)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_encrypt_scheme (handle, scheme_id, flags, opts, key,
- io_message, io_cipher);
-
- return gcry_error (err);
-}
-
/* Decryptes the cipher message contained in C, which is of size C_N,
with the secret key KEY_SECRET according to the Encryption Scheme
SCHEME_ID. Handle is used for accessing the low-level
@@ -3301,21 +2988,6 @@ _gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
- gcry_ac_scheme_t scheme_id,
- unsigned int flags, void *opts,
- gcry_ac_key_t key,
- gcry_ac_io_t *io_cipher,
- gcry_ac_io_t *io_message)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_decrypt_scheme (handle, scheme_id, flags, opts, key,
- io_cipher, io_message);
-
- return gcry_error (err);
-}
/* Signs the message contained in M, which is of size M_N, with the
secret key KEY according to the Signature Scheme SCHEME_ID. Handle
@@ -3407,23 +3079,6 @@ _gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
- gcry_ac_scheme_t scheme_id,
- unsigned int flags,
- void *opts,
- gcry_ac_key_t key,
- gcry_ac_io_t *io_message,
- gcry_ac_io_t *io_signature)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_sign_scheme (handle, scheme_id, flags, opts, key,
- io_message, io_signature);
-
- return gcry_error (err);
-}
-
/* Verifies that the signature contained in S, which is of length S_N,
is indeed the result of signing the message contained in M, which
is of size M_N, with the secret key belonging to the public key
@@ -3536,74 +3191,11 @@ _gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
return err;
}
-gcry_error_t
-gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
- gcry_ac_scheme_t scheme_id,
- unsigned int flags, void *opts,
- gcry_ac_key_t key,
- gcry_ac_io_t *io_message,
- gcry_ac_io_t *io_signature)
-{
- gcry_error_t err;
-
- err = _gcry_ac_data_verify_scheme (handle, scheme_id, flags, opts, key,
- io_message, io_signature);
-
- return gcry_error (err);
-}
-
-
/*
* General functions.
*/
-/* Stores the textual representation of the algorithm whose id is
- given in ALGORITHM in NAME. */
-gcry_error_t
-gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name)
-{
- gcry_error_t err;
- const char *n;
-
- n = gcry_pk_algo_name (algorithm);
- if (! *n)
- {
- err = gcry_error (GPG_ERR_PUBKEY_ALGO);
- goto out;
- }
-
- *name = n;
- err = 0;
-
- out:
-
- return gcry_error (err);
-}
-
-/* Stores the numeric ID of the algorithm whose textual representation
- is contained in NAME in ALGORITHM. */
-gcry_error_t
-gcry_ac_name_to_id (const char *name, gcry_ac_id_t *algorithm)
-{
- gcry_error_t err;
- int algo;
-
- algo = gcry_pk_map_name (name);
- if (! algo)
- {
- err = gcry_error (GPG_ERR_PUBKEY_ALGO);
- goto out;
- }
-
- *algorithm = algo;
- err = 0;
-
- out:
-
- return gcry_error (err);
-}
-
gcry_err_code_t
_gcry_ac_init (void)
{
diff --git a/configure.ac b/configure.ac
index 994bf286..d5083826 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,8 @@ AC_CANONICAL_HOST
AM_MAINTAINER_MODE
AH_TOP([
+#ifndef _GCRYPT_CONFIG_H_INCLUDED
+#define _GCRYPT_CONFIG_H_INCLUDED
/* need this, because some autoconf tests rely on this (e.g. stpcpy)
* and it should be used for new programs */
#define _GNU_SOURCE 1
@@ -79,6 +81,7 @@ AH_BOTTOM([
# endif
#endif /*DISABLED_ENDIAN_CHECK*/
+#endif /*_GCRYPT_CONFIG_H_INCLUDED*/
])
AH_VERBATIM([_REENTRANT],
@@ -572,7 +575,89 @@ case "${host}" in
fi
esac
AC_SUBST(FALLBACK_SOCKLEN_T)
-
+
+#
+# Check for ELF visibility support.
+#
+AC_CACHE_CHECK(whether the visibility attribute is supported,
+ gcry_cv_visibility_attribute,
+ [gcry_cv_visibility_attribute=no
+ AC_LANG_CONFTEST([AC_LANG_SOURCE(
+ [[int foo __attribute__ ((visibility ("hidden"))) = 1;
+ int bar __attribute__ ((visibility ("protected"))) = 1;
+ ]])])
+
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s \
+ 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+ if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
+ if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
+ gcry_cv_visibility_attribute=yes
+ fi
+ fi
+ fi
+ ])
+if test "$gcry_cv_visibility_attribute" = "yes"; then
+ AC_CACHE_CHECK(for broken visibility attribute,
+ gcry_cv_broken_visibility_attribute,
+ [gcry_cv_broken_visibility_attribute=yes
+ AC_LANG_CONFTEST([AC_LANG_SOURCE(
+ [[int foo (int x);
+ int bar (int x) __asm__ ("foo")
+ __attribute__ ((visibility ("hidden")));
+ int bar (int x) { return x; }
+ ]])])
+
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s \
+ 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+ if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
+ then
+ gcry_cv_broken_visibility_attribute=no
+ fi
+ fi
+ ])
+fi
+if test "$gcry_cv_visibility_attribute" = "yes"; then
+ AC_CACHE_CHECK(for broken alias attribute,
+ gcry_cv_broken_alias_attribute,
+ [gcry_cv_broken_alias_attribute=yes
+ AC_LANG_CONFTEST([AC_LANG_SOURCE(
+ [[extern int foo (int x) __asm ("xyzzy");
+ int bar (int x) { return x; }
+ extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
+ extern int dfoo;
+ extern __typeof (dfoo) dfoo __asm ("abccb");
+ int dfoo = 1;
+ ]])])
+
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s \
+ 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+ if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
+ grep 'abccb' conftest.s >/dev/null 2>&1; then
+ gcry_cv_broken_alias_attribute=no
+ fi
+ fi
+ ])
+fi
+if test "$gcry_cv_visibility_attribute" = "yes"; then
+ AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
+ gcry_cv_gcc_has_f_visibility,
+ [gcry_cv_gcc_has_f_visibility=no
+ _gcc_cflags_save=$CFLAGS
+ CFLAGS="-fvisibility=hidden"
+ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
+ gcry_cv_gcc_has_f_visibility=yes)
+ CFLAGS=$_gcc_cflags_save;
+ ])
+fi
+if test "$gcry_cv_visibility_attribute" = "yes" \
+ && test "$gcry_cv_broken_visibility_attribute" != "yes" \
+ && test "$gcry_cv_broken_alias_attribute" != "yes" \
+ && test "$gcry_cv_gcc_has_f_visibility" = "yes"
+ then
+ AC_DEFINE(GCRY_USE_VISIBILITY, 1,
+ [Define to use the GNU C visibility attribute])
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+fi
#######################################
diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi
index 19b6c1f2..ad745f36 100644
--- a/doc/gcrypt.texi
+++ b/doc/gcrypt.texi
@@ -271,7 +271,7 @@ of the library are verified.
@section Header
All interfaces (data types and functions) of the library are defined
-in the header file `gcrypt.h'. You must include this in all source
+in the header file @file{gcrypt.h}. You must include this in all source
files using the library, either directly or through some other header
file, like this:
@@ -287,6 +287,17 @@ Libgcrypt uses libgpg-error, which uses @code{gpg_*} as
name space for function and type names and @code{GPG_*} for other
symbols, including all the error codes.
+@noindent
+Certain parts of gcrypt.h may be excluded by defining these macros:
+
+@table @code
+@item GCRYPT_NO_MPI_MACROS
+Do not define the shorthand macros @code{mpi_*} for @code{gcry_mpi_*}.
+
+@item GCRYPT_NO_DEPRECATED
+Do not include defintions for deprecated features.
+@end table
+
@node Building sources
@section Building sources
diff --git a/mpi/ChangeLog b/mpi/ChangeLog
index e5aedf2d..32da0e34 100644
--- a/mpi/ChangeLog
+++ b/mpi/ChangeLog
@@ -1,3 +1,16 @@
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * mpi-mod.c (gcry_mpi_mod): Remove
+ * mpi-inv.c (_gcry_mpi_invm): Remove _ prefix.
+ * mpiutil.c (_gcry_mpi_swap): Remove.
+ (_gcry_mpi_new): Remove.
+ (_gcry_mpi_snew): Remove.
+ (gcry_mpi_invm): Remove.
+ (gcry_mpi_copy): Remove and rename _version to this.
+ (gcry_mpi_set, gcry_mpi_set_ui): Merge with _ version.
+ * mpi-inv.c (gcry_mpi_invm): Remove _ prefix and return 1.
+ * mpi-mul.c (gcry_mpi_mul_2exp): Remove and rename _ version to this.
+
2007-10-29 Werner Koch <wk@g10code.com>
* config.links: No Candadian Cross here, thus use $host instead of
diff --git a/mpi/mpi-inv.c b/mpi/mpi-inv.c
index 2e737b8f..5d269466 100644
--- a/mpi/mpi-inv.c
+++ b/mpi/mpi-inv.c
@@ -14,8 +14,7 @@
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
@@ -29,8 +28,8 @@
* That is: Find the solution x for
* 1 = (a*x) mod n
*/
-void
-_gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n )
+int
+gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n )
{
#if 0
gcry_mpi_t u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3;
@@ -264,12 +263,5 @@ _gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n )
mpi_free(u);
mpi_free(v);
#endif
-}
-
-
-int
-gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n)
-{
- _gcry_mpi_invm (x, a, n);
- return 1;
+ return 1;
}
diff --git a/mpi/mpi-mod.c b/mpi/mpi-mod.c
index 72eeea04..9f38a0a9 100644
--- a/mpi/mpi-mod.c
+++ b/mpi/mpi-mod.c
@@ -51,14 +51,6 @@ _gcry_mpi_mod (gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor)
rem->sign = 0;
}
-void
-gcry_mpi_mod (gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor)
-{
- _gcry_mpi_fdiv_r (rem, dividend, divisor);
- rem->sign = 0;
-}
-
-
/* This function returns a new context for Barrett based operations on
the modulus M. This context needs to be released using
diff --git a/mpi/mpi-mul.c b/mpi/mpi-mul.c
index 23beee0b..25aeaa0a 100644
--- a/mpi/mpi-mul.c
+++ b/mpi/mpi-mul.c
@@ -61,7 +61,7 @@ gcry_mpi_mul_ui( gcry_mpi_t prod, gcry_mpi_t mult, unsigned long small_mult )
void
-_gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
+gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
{
mpi_size_t usize, wsize, limb_cnt;
mpi_ptr_t wp;
@@ -107,13 +107,6 @@ _gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
void
-gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
-{
- _gcry_mpi_mul_2exp (w, u, cnt);
-}
-
-
-void
gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
{
mpi_size_t usize, vsize, wsize;
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index ee690261..bafc5de1 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -1,5 +1,6 @@
/* mpiutil.ac - Utility functions for MPI
- * Copyright (C) 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 2000, 2001, 2002, 2003,
+ * 2007 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -14,8 +15,7 @@
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
@@ -242,7 +242,7 @@ gcry_mpi_get_opaque( gcry_mpi_t a, unsigned int *nbits )
* but copy it transparently.
*/
gcry_mpi_t
-_gcry_mpi_copy( gcry_mpi_t a )
+gcry_mpi_copy( gcry_mpi_t a )
{
int i;
gcry_mpi_t b;
@@ -298,33 +298,39 @@ _gcry_mpi_alloc_like( gcry_mpi_t a )
}
-void
-_gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u)
+gcry_mpi_t
+gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u)
{
- mpi_ptr_t wp, up;
- mpi_size_t usize = u->nlimbs;
- int usign = u->sign;
-
- RESIZE_IF_NEEDED(w, usize);
- wp = w->d;
- up = u->d;
- MPN_COPY( wp, up, usize );
- w->nlimbs = usize;
- w->flags = u->flags;
- w->sign = usign;
+ mpi_ptr_t wp, up;
+ mpi_size_t usize = u->nlimbs;
+ int usign = u->sign;
+
+ if (!w)
+ w = _gcry_mpi_alloc( mpi_get_nlimbs(u) );
+ RESIZE_IF_NEEDED(w, usize);
+ wp = w->d;
+ up = u->d;
+ MPN_COPY( wp, up, usize );
+ w->nlimbs = usize;
+ w->flags = u->flags;
+ w->sign = usign;
+ return w;
}
-void
-_gcry_mpi_set_ui( gcry_mpi_t w, unsigned long u)
+gcry_mpi_t
+gcry_mpi_set_ui( gcry_mpi_t w, unsigned long u)
{
- /* FIXME: If U is 0 tehre is no ned to resize and thus possible
+ if (!w)
+ w = _gcry_mpi_alloc (1);
+ /* FIXME: If U is 0 we have no need to resize and thus possible
allocating the the limbs. */
- RESIZE_IF_NEEDED(w, 1);
- w->d[0] = u;
- w->nlimbs = u? 1:0;
- w->sign = 0;
- w->flags = 0;
+ RESIZE_IF_NEEDED(w, 1);
+ w->d[0] = u;
+ w->nlimbs = u? 1:0;
+ w->sign = 0;
+ w->flags = 0;
+ return w;
}
gcry_err_code_t
@@ -366,49 +372,28 @@ _gcry_mpi_alloc_set_ui( unsigned long u)
return w;
}
-
void
-_gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b)
+gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b)
{
struct gcry_mpi tmp;
tmp = *a; *a = *b; *b = tmp;
}
-void
-gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b)
-{
- _gcry_mpi_swap (a, b);
-}
-
-
-/* Internal version of mpi_new. */
-gcry_mpi_t
-_gcry_mpi_new( unsigned int nbits )
-{
- return _gcry_mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
-}
-/* External version of mpi_new. */
gcry_mpi_t
gcry_mpi_new( unsigned int nbits )
{
- return _gcry_mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
+ return _gcry_mpi_alloc ( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
}
-/* Internal version of mpi_snew. */
-gcry_mpi_t
-_gcry_mpi_snew( unsigned int nbits )
-{
- return _gcry_mpi_alloc_secure( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
-}
-
-/* External version of mpi_snew. */
gcry_mpi_t
gcry_mpi_snew( unsigned int nbits )
{
- return _gcry_mpi_alloc_secure( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
+ return _gcry_mpi_alloc_secure ( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
}
void
@@ -417,31 +402,6 @@ gcry_mpi_release( gcry_mpi_t a )
_gcry_mpi_free( a );
}
-gcry_mpi_t
-gcry_mpi_copy( const gcry_mpi_t a )
-{
- return _gcry_mpi_copy( (gcry_mpi_t)a );
-}
-
-gcry_mpi_t
-gcry_mpi_set( gcry_mpi_t w, const gcry_mpi_t u )
-{
- if( !w )
- w = _gcry_mpi_alloc( mpi_get_nlimbs(u) );
- _gcry_mpi_set( w, (gcry_mpi_t)u );
- return w;
-}
-
-gcry_mpi_t
-gcry_mpi_set_ui( gcry_mpi_t w, unsigned long u )
-{
- if( !w )
- w = _gcry_mpi_alloc(1);
- _gcry_mpi_set_ui( w, u );
- return w;
-}
-
-
void
gcry_mpi_randomize( gcry_mpi_t w,
unsigned int nbits, enum gcry_random_level level )
diff --git a/src/ChangeLog b/src/ChangeLog
index 3cae0f0b..05300224 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,24 @@
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * global.c (gcry_control): Factor most code out to ..
+ (_gcry_vcontrol): .. new.
+ * sexp.c (_gcry_sexp_vbuild): New.
+ * mpi.h (_gcry_mpi_set, _gcry_mpi_set_ui, _gcry_mpi_invm): Remove
+ prototypes as they are already in gcrypt.h.
+
+2007-10-30 Werner Koch <wk@g10code.com>
+
+ * sexp.c (gcry_sexp_nth_string): Replace by _gcry_sexp_nth_string.
+
+ * visibility.h, visibility.c: New.
+ * g10lib.h: Include visibility.h instead of gcrypt.h.
+ * globals.c (_gcry_malloc): Rename to ..
+ (do_malloc): .. this.
+
+ * hwfeatures.c: New.
+ * global.c (global_init): Detect features.
+ (print_config): Print them.
+
2007-08-22 Werner Koch <wk@g10code.com>
* dumpsexp.c: New.
diff --git a/src/Makefile.am b/src/Makefile.am
index 8b203f18..e2e27fe8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,8 +42,8 @@ else
endif
libgcrypt_la_CFLAGS = @GPG_ERROR_CFLAGS@
-libgcrypt_la_SOURCES = g10lib.h types.h cipher.h \
- misc.c global.c sexp.c \
+libgcrypt_la_SOURCES = g10lib.h visibility.c visibility.h types.h cipher.h \
+ misc.c global.c sexp.c hwfeatures.c \
stdmem.c stdmem.h secmem.c secmem.h \
mpi.h missing-string.c module.c \
ath.h ath.c
diff --git a/src/g10lib.h b/src/g10lib.h
index 7d2f3515..a3303553 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -1,10 +1,6 @@
-/* g10lib.h - internal defintions for libgcrypt
- * Copyright (C) 1998, 1999, 2000, 2001, 2002,
- * 2003, 2005 Free Software Foundation, Inc.
- *
- * This header is to be used inside of libgcrypt in place of gcrypt.h.
- * This way we can better distinguish between internal and external
- * usage of gcrypt.h
+/* g10lib.h - Internal definitions for libgcrypt
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
+ * 2007 Free Software Foundation, Inc.
*
* This file is part of Libgcrypt.
*
@@ -19,10 +15,13 @@
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * License along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+/* This header is to be used inside of libgcrypt in place of gcrypt.h.
+ This way we can better distinguish between internal and external
+ usage of gcrypt.h. */
+
#ifndef G10LIB_H
#define G10LIB_H 1
@@ -35,8 +34,9 @@
#endif
#include <stdio.h>
+#include <stdarg.h>
-#include <gcrypt.h>
+#include "visibility.h"
#include "types.h"
@@ -64,12 +64,13 @@
+/*-- src/global.c -*/
+gcry_error_t _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr);
void _gcry_check_heap (const void *a);
-
int _gcry_get_debug_flag (unsigned int mask);
-/*-- gcrypt/misc.c --*/
+/*-- src/misc.c --*/
#ifdef JNLIB_GCC_M_FUNCTION
void _gcry_bug (const char *file, int line,
@@ -108,6 +109,15 @@ int _gcry_log_verbosity( int level );
#define log_printf _gcry_log_printf
+/*-- src/hwfeatures.c --*/
+#define HWF_PADLOCK_RNG 1
+#define HWF_PADLOCK_AES 2
+#define HWF_PADLOCK_SHA 4
+#define HWF_PADLOCK_MMUL 8
+
+unsigned int _gcry_get_hw_features (void);
+void _gcry_detect_hw_features (void);
+
/*-- mpi/mpiutil.c --*/
const char *_gcry_mpi_get_hw_config (void);
@@ -245,13 +255,12 @@ void _gcry_pk_module_release (gcry_module_t module);
gcry_err_code_t _gcry_pk_get_elements (int algo, char **enc, char **sig);
/* Memory management. */
-
-gcry_err_code_t _gcry_malloc (size_t n, unsigned int flags, void **mem);
-
#define GCRY_ALLOC_FLAG_SECURE (1 << 0)
/*-- sexp.c --*/
+gcry_error_t _gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, va_list arg_ptr);
char *_gcry_sexp_nth_string (const gcry_sexp_t list, int number);
diff --git a/src/gcrypt-module.h b/src/gcrypt-module.h
index 5cb298bf..5d0a9ae0 100644
--- a/src/gcrypt-module.h
+++ b/src/gcrypt-module.h
@@ -14,9 +14,8 @@
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. */
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
/*
This file contains the necessary declarations/definitions for
diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in
index f5881047..63f61f10 100644
--- a/src/gcrypt.h.in
+++ b/src/gcrypt.h.in
@@ -1,6 +1,6 @@
/* gcrypt.h - GNU Cryptographic Library Interface -*- c -*-
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
+ 2007 Free Software Foundation, Inc.
This file is part of Libgcrypt.
@@ -15,9 +15,7 @@
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.
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
File: @configure_input@ */
@@ -323,8 +321,10 @@ static struct gcry_thread_cbs gcry_threads_pthread = \
struct gcry_mpi;
typedef struct gcry_mpi *gcry_mpi_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
@@ -401,8 +401,10 @@ gcry_error_t gcry_control (enum gcry_ctl_cmds CMD, ...);
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
@@ -767,8 +769,10 @@ int gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag);
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. */
@@ -1070,8 +1074,10 @@ typedef struct gcry_md_handle
} *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
@@ -1183,6 +1189,7 @@ void gcry_md_debug (gcry_md_hd_t hd, const char *suffix);
/* Enable debugging for digest object A; i.e. create files named
dbgmd-<n>.<string> while hashing. B is a string used as the suffix
for the filename. This macro is deprecated, use gcry_md_debug. */
+#ifndef GCRYPT_NO_DEPRECATED
#define gcry_md_start_debug(a,b) \
gcry_md_ctl( (a), GCRYCTL_START_DUMP, (b), 0 )
@@ -1190,6 +1197,7 @@ void gcry_md_debug (gcry_md_hd_t hd, const char *suffix);
gcry_md_debug. */
#define gcry_md_stop_debug(a,b) \
gcry_md_ctl( (a), GCRYCTL_STOP_DUMP, (b), 0 )
+#endif
/* Get a list consisting of the IDs of the loaded message digest
modules. If LIST is zero, write the number of loaded message
@@ -1561,15 +1569,17 @@ gcry_error_t gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
/* Store the textual representation of the algorithm whose id is given
in ALGORITHM in NAME. This function is deprecated; use
gcry_pk_algo_name. */
+#ifndef GCRYPT_NO_DEPRECATED
gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t algorithm,
- const char **name) _GCRY_GCC_ATTR_DEPRECATED;
+ const char **name)
+ /* */ _GCRY_GCC_ATTR_DEPRECATED;
/* Store the numeric ID of the algorithm whose textual representation
is contained in NAME in ALGORITHM. This function is deprecated;
use gcry_pk_map_name. */
gcry_error_t gcry_ac_name_to_id (const char *name,
- gcry_ac_id_t *algorithm
- ) _GCRY_GCC_ATTR_DEPRECATED;;
-
+ gcry_ac_id_t *algorithm)
+ /* */ _GCRY_GCC_ATTR_DEPRECATED;
+#endif
/************************************
diff --git a/src/global.c b/src/global.c
index 2e65e360..abbc0927 100644
--- a/src/global.c
+++ b/src/global.c
@@ -75,6 +75,11 @@ global_init (void)
err = ath_init ();
if (err)
goto fail;
+
+ /* Before we do any other initialization we need to test available
+ hardware features. */
+ _gcry_detect_hw_features ();
+
err = _gcry_cipher_init ();
if (err)
goto fail;
@@ -201,6 +206,18 @@ gcry_check_version( const char *req_version )
static void
print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp)
{
+ unsigned int hwf;
+ struct {
+ unsigned int flag;
+ const char *desc;
+ } hwflist[] = {
+ { HWF_PADLOCK_RNG, "padlock-rng" },
+ { HWF_PADLOCK_AES, "padlock-aes" },
+ { HWF_PADLOCK_SHA, "padlock-sha" },
+ { 0, NULL}
+ };
+ int i;
+
fnc (fp, "version:%s:\n", VERSION);
fnc (fp, "ciphers:%s:\n", LIBGCRYPT_CIPHERS);
fnc (fp, "pubkeys:%s:\n", LIBGCRYPT_PUBKEY_CIPHERS);
@@ -220,6 +237,12 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp)
#endif
"\n");
fnc (fp, "mpi-asm:%s:\n", _gcry_mpi_get_hw_config ());
+ hwf = _gcry_get_hw_features ();
+ fnc (fp, "hwflist:");
+ for (i=0; hwflist[i].desc; i++)
+ if ( (hwf & hwflist[i].flag) )
+ fnc (fp, "%s:", hwflist[i].desc);
+ fnc (fp, "\n");
}
@@ -228,13 +251,11 @@ print_config ( int (*fnc)(FILE *fp, const char *format, ...), FILE *fp)
/* Command dispatcher function, acting as general control
function. */
gcry_error_t
-gcry_control (enum gcry_ctl_cmds cmd, ...)
+_gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
{
- gcry_err_code_t err = GPG_ERR_NO_ERROR;
static int init_finished = 0;
- va_list arg_ptr;
+ gcry_err_code_t err = 0;
- va_start (arg_ptr, cmd);
switch (cmd)
{
case GCRYCTL_ENABLE_M_GUARD:
@@ -403,10 +424,26 @@ gcry_control (enum gcry_ctl_cmds cmd, ...)
err = GPG_ERR_INV_OP;
}
- va_end(arg_ptr);
return gcry_error (err);
}
+
+/* Command dispatcher function, acting as general control
+ function. */
+gcry_error_t
+gcry_control (enum gcry_ctl_cmds cmd, ...)
+{
+ gcry_error_t err;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, cmd);
+ err = _gcry_vcontrol (cmd, arg_ptr);
+ va_end(arg_ptr);
+ return err;
+}
+
+
+
/* Return a pointer to a string containing a description of the error
code in the error value ERR. */
const char *
@@ -502,8 +539,8 @@ gcry_set_outofcore_handler( int (*f)( void*, size_t, unsigned int ),
outofcore_handler_value = value;
}
-gcry_err_code_t
-_gcry_malloc (size_t n, unsigned int flags, void **mem)
+static gcry_err_code_t
+do_malloc (size_t n, unsigned int flags, void **mem)
{
gcry_err_code_t err = 0;
void *m;
@@ -542,7 +579,7 @@ gcry_malloc (size_t n)
{
void *mem = NULL;
- _gcry_malloc (n, 0, &mem);
+ do_malloc (n, 0, &mem);
return mem;
}
@@ -552,7 +589,7 @@ gcry_malloc_secure (size_t n)
{
void *mem = NULL;
- _gcry_malloc (n, GCRY_ALLOC_FLAG_SECURE, &mem);
+ do_malloc (n, GCRY_ALLOC_FLAG_SECURE, &mem);
return mem;
}
diff --git a/src/hwfeatures.c b/src/hwfeatures.c
new file mode 100644
index 00000000..3594c0b3
--- /dev/null
+++ b/src/hwfeatures.c
@@ -0,0 +1,69 @@
+/* hwfeatures.c - Detect hardware features.
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#include "g10lib.h"
+
+/* A bit vector describing the hardware features currently
+ available. */
+static unsigned int hw_features;
+
+
+/* Return a bit vector describing the available hardware features.
+ The HWF_ constants are used to test for them. */
+unsigned int
+_gcry_get_hw_features (void)
+{
+ return hw_features;
+}
+
+
+#if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && defined (__GNUC__)
+static void
+detect_ia32_gnuc (void)
+{
+
+
+
+}
+#endif /* __i386__ && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ */
+
+
+
+/* Detect the available hardware features. This fucntion is called
+ once right at startup and we assume that no other threads are
+ running. */
+void
+_gcry_detect_hw_features (void)
+{
+#if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4
+#ifdef __GNUC__
+ detect_ia32_gnuc ();
+#endif
+#elif defined (__i386__) && SIZEOF_UNSIGNED_LONG == 8
+#ifdef __GNUC__
+#endif
+#endif
+}
diff --git a/src/libgcrypt.def b/src/libgcrypt.def
index 12dc5b19..6b4821ba 100644
--- a/src/libgcrypt.def
+++ b/src/libgcrypt.def
@@ -19,7 +19,7 @@
;;
;; Note: This file should be updated manually and the ordinals shall
-;; never be changed.
+;; never be changed. Also check libgcrypt.vers and visibility.h.
EXPORTS
diff --git a/src/libgcrypt.vers b/src/libgcrypt.vers
index 227f669d..6bac4626 100644
--- a/src/libgcrypt.vers
+++ b/src/libgcrypt.vers
@@ -1,4 +1,4 @@
-# libgcrypt.vers - What symbols to export
+# libgcrypt.vers - What symbols to export -*- std -*-
# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of Libgcrypt.
@@ -17,6 +17,9 @@
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+# NOTE: When adding new functions, please make sure to add them to
+# visibility.h and libgcrypt.def as well.
+
GCRYPT_1.2 {
global:
gcry_check_version; gcry_control;
diff --git a/src/mpi.h b/src/mpi.h
index 6e2ae88c..81a5a0c7 100644
--- a/src/mpi.h
+++ b/src/mpi.h
@@ -118,8 +118,6 @@ struct gcry_mpi
void _gcry_mpi_clear( gcry_mpi_t a );
gcry_mpi_t _gcry_mpi_alloc_like( gcry_mpi_t a );
-void _gcry_mpi_set( gcry_mpi_t w, gcry_mpi_t u);
-void _gcry_mpi_set_ui( gcry_mpi_t w, ulong u);
gcry_mpi_t _gcry_mpi_alloc_set_ui( unsigned long u);
gcry_err_code_t _gcry_mpi_get_ui (gcry_mpi_t w, ulong *u);
void _gcry_mpi_m_check( gcry_mpi_t a );
@@ -226,7 +224,6 @@ void _gcry_mpi_normalize( gcry_mpi_t a );
/*-- mpi-inv.c --*/
#define mpi_invm(a,b,c) _gcry_mpi_invm ((a),(b),(c))
-void _gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t u, gcry_mpi_t v );
/*-- ec.c --*/
diff --git a/src/sexp.c b/src/sexp.c
index e88d12c1..721069ea 100644
--- a/src/sexp.c
+++ b/src/sexp.c
@@ -654,7 +654,7 @@ gcry_sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen )
/* Get a string from the car. The returned value is a malloced string
and needs to be freed by the caller. */
char *
-_gcry_sexp_nth_string (const gcry_sexp_t list, int number)
+gcry_sexp_nth_string (const gcry_sexp_t list, int number)
{
const char *s;
size_t n;
@@ -671,13 +671,6 @@ _gcry_sexp_nth_string (const gcry_sexp_t list, int number)
return buf;
}
-/* Public version of _gcry_sexp_nth_string. */
-char *
-gcry_sexp_nth_string (const gcry_sexp_t list, int number)
-{
- return _gcry_sexp_nth_string (list, number);
-}
-
/*
* Get a MPI from the car
*/
@@ -1471,6 +1464,15 @@ gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, const char *format, ...)
return rc;
}
+
+gcry_error_t
+_gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, va_list arg_ptr)
+{
+ return sexp_sscan (retsexp, erroff, format, strlen(format), 1,
+ arg_ptr, NULL);
+}
+
/* Like gcry_sexp_build, but uses an array instead of variable
function arguments. */
gcry_error_t
diff --git a/src/versioninfo.rc.in b/src/versioninfo.rc.in
index 7a6d82ca..e167eaf0 100644
--- a/src/versioninfo.rc.in
+++ b/src/versioninfo.rc.in
@@ -34,8 +34,7 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
- /* Note that the Windows version falls under the GPL. */
- VALUE "Comments", "Provided under the terms of the GNU General Public License.\0"
+ VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License (LGPLv2.1+).\0"
VALUE "CompanyName", "g10 Code GmbH\0"
VALUE "FileDescription", "Libgcrypt - The GNU Crypto Library\0"
VALUE "FileVersion", "@LIBGCRYPT_LT_CURRENT@.@LIBGCRYPT_LT_AGE@.@LIBGCRYPT_LT_REVISION@.@BUILD_REVISION@\0"
diff --git a/src/visibility.c b/src/visibility.c
new file mode 100644
index 00000000..f54851e2
--- /dev/null
+++ b/src/visibility.c
@@ -0,0 +1,1287 @@
+/* visibility.c - Wrapper for all public functions.
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdarg.h>
+
+#define _GCRY_INCLUDED_BY_VISIBILITY_C
+#include "g10lib.h"
+
+
+const char *
+gcry_strerror (gcry_error_t err)
+{
+ return _gcry_strerror (err);
+}
+
+const char *
+gcry_strsource (gcry_error_t err)
+{
+ return _gcry_strsource (err);
+}
+
+gcry_err_code_t
+gcry_err_code_from_errno (int err)
+{
+ return _gcry_err_code_from_errno (err);
+}
+
+int
+gcry_err_code_to_errno (gcry_err_code_t code)
+{
+ return _gcry_err_code_to_errno (code);
+}
+
+gcry_error_t
+gcry_err_make_from_errno (gcry_err_source_t source, int err)
+{
+ return _gcry_err_make_from_errno (source, err);
+}
+
+gcry_err_code_t
+gcry_error_from_errno (int err)
+{
+ return _gcry_error_from_errno (err);
+}
+
+const char *
+gcry_check_version (const char *req_version)
+{
+ return _gcry_check_version (req_version);
+}
+
+gcry_error_t
+gcry_control (enum gcry_ctl_cmds cmd, ...)
+{
+ gcry_error_t err;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, cmd);
+ err = _gcry_vcontrol (cmd, arg_ptr);
+ va_end(arg_ptr);
+ return err;
+}
+
+gcry_error_t
+gcry_sexp_new (gcry_sexp_t *retsexp,
+ const void *buffer, size_t length,
+ int autodetect)
+{
+ return _gcry_sexp_new (retsexp, buffer, length, autodetect);
+}
+
+gcry_error_t
+gcry_sexp_create (gcry_sexp_t *retsexp,
+ void *buffer, size_t length,
+ int autodetect, void (*freefnc) (void *))
+{
+ return _gcry_sexp_create (retsexp, buffer, length,
+ autodetect, freefnc);
+}
+
+gcry_error_t
+gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *buffer, size_t length)
+{
+ return _gcry_sexp_sscan (retsexp, erroff, buffer, length);
+}
+
+gcry_error_t
+gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, ...)
+{
+ gcry_error_t err;
+ va_list arg_ptr;
+
+ va_start (arg_ptr, format);
+ err = _gcry_sexp_vbuild (retsexp, erroff, format, arg_ptr);
+ va_end (arg_ptr);
+ return err;
+}
+
+gcry_error_t
+gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff,
+ const char *format, void **arg_list)
+{
+ return _gcry_sexp_build_array (retsexp, erroff, format, arg_list);
+}
+
+void
+gcry_sexp_release (gcry_sexp_t sexp)
+{
+ _gcry_sexp_release (sexp);
+}
+
+size_t
+gcry_sexp_canon_len (const unsigned char *buffer, size_t length,
+ size_t *erroff, gcry_error_t *errcode)
+{
+ return _gcry_sexp_canon_len (buffer, length, erroff, errcode);
+}
+
+size_t
+gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, size_t maxlength)
+{
+ return _gcry_sexp_sprint (sexp, mode, buffer, maxlength);
+}
+
+void
+gcry_sexp_dump (const gcry_sexp_t a)
+{
+ _gcry_sexp_dump (a);
+}
+
+gcry_sexp_t
+gcry_sexp_cons (const gcry_sexp_t a, const gcry_sexp_t b)
+{
+ return _gcry_sexp_cons (a, b);
+}
+
+gcry_sexp_t
+gcry_sexp_alist (const gcry_sexp_t *array)
+{
+ return _gcry_sexp_alist (array);
+}
+
+gcry_sexp_t
+gcry_sexp_vlist (const gcry_sexp_t a, ...)
+{
+ /* This is not yet implemented in sexp.c. */
+ (void)a;
+ BUG ();
+ return NULL;
+}
+
+gcry_sexp_t
+gcry_sexp_append (const gcry_sexp_t a, const gcry_sexp_t n)
+{
+ return _gcry_sexp_append (a, n);
+}
+
+gcry_sexp_t
+gcry_sexp_prepend (const gcry_sexp_t a, const gcry_sexp_t n)
+{
+ return _gcry_sexp_prepend (a, n);
+}
+
+
+gcry_sexp_t
+gcry_sexp_find_token (gcry_sexp_t list, const char *tok, size_t toklen)
+{
+ return _gcry_sexp_find_token (list, tok, toklen);
+}
+
+int
+gcry_sexp_length (const gcry_sexp_t list)
+{
+ return _gcry_sexp_length (list);
+}
+
+gcry_sexp_t
+gcry_sexp_nth (const gcry_sexp_t list, int number)
+{
+ return _gcry_sexp_nth (list, number);
+}
+
+gcry_sexp_t
+gcry_sexp_car (const gcry_sexp_t list)
+{
+ return _gcry_sexp_car (list);
+}
+
+gcry_sexp_t
+gcry_sexp_cdr (const gcry_sexp_t list)
+{
+ return _gcry_sexp_cdr (list);
+}
+
+gcry_sexp_t
+gcry_sexp_cadr (const gcry_sexp_t list)
+{
+ return _gcry_sexp_cadr (list);
+}
+
+const char *
+gcry_sexp_nth_data (const gcry_sexp_t list, int number, size_t *datalen)
+{
+ return _gcry_sexp_nth_data (list, number, datalen);
+}
+
+char *
+gcry_sexp_nth_string (gcry_sexp_t list, int number)
+{
+ return _gcry_sexp_nth_string (list, number);
+}
+
+gcry_mpi_t
+gcry_sexp_nth_mpi (gcry_sexp_t list, int number, int mpifmt)
+{
+ return _gcry_sexp_nth_mpi (list, number, mpifmt);
+}
+
+gcry_mpi_t
+gcry_mpi_new (unsigned int nbits)
+{
+ return _gcry_mpi_new (nbits);
+}
+
+gcry_mpi_t
+gcry_mpi_snew (unsigned int nbits)
+{
+ return _gcry_mpi_snew (nbits);
+}
+
+void
+gcry_mpi_release (gcry_mpi_t a)
+{
+ _gcry_mpi_release (a);
+}
+
+gcry_mpi_t
+gcry_mpi_copy (const gcry_mpi_t a)
+{
+ return _gcry_mpi_copy (a);
+}
+
+gcry_mpi_t
+gcry_mpi_set (gcry_mpi_t w, const gcry_mpi_t u)
+{
+ return _gcry_mpi_set (w, u);
+}
+
+gcry_mpi_t
+gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u)
+{
+ return _gcry_mpi_set_ui (w, u);
+}
+
+void
+gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b)
+{
+ _gcry_mpi_swap (a, b);
+}
+
+int
+gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v)
+{
+ return _gcry_mpi_cmp (u, v);
+}
+
+int
+gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v)
+{
+ return _gcry_mpi_cmp_ui (u, v);
+}
+
+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)
+{
+ return _gcry_mpi_scan (ret_mpi, format, buffer, buflen, nscanned);
+}
+
+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)
+{
+ return _gcry_mpi_print (format, buffer, buflen, nwritten, a);
+}
+
+gcry_error_t
+gcry_mpi_aprint (enum gcry_mpi_format format,
+ unsigned char **buffer, size_t *nwritten,
+ const gcry_mpi_t a)
+{
+ return _gcry_mpi_aprint (format, buffer, nwritten, a);
+}
+
+void
+gcry_mpi_dump (const gcry_mpi_t a)
+{
+ _gcry_mpi_dump (a);
+}
+
+void
+gcry_mpi_add (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ _gcry_mpi_add (w, u, v);
+}
+
+void
+gcry_mpi_add_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v)
+{
+ _gcry_mpi_add_ui (w, u, v);
+}
+
+void
+gcry_mpi_addm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ _gcry_mpi_addm (w, u, v, m);
+}
+
+void
+gcry_mpi_sub (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ _gcry_mpi_sub (w, u, v);
+}
+
+void
+gcry_mpi_sub_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ _gcry_mpi_sub_ui (w, u, v);
+}
+
+void
+gcry_mpi_subm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ _gcry_mpi_subm (w, u, v, m);
+}
+
+void
+gcry_mpi_mul (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v)
+{
+ _gcry_mpi_mul (w, u, v);
+}
+
+void
+gcry_mpi_mul_ui (gcry_mpi_t w, gcry_mpi_t u, unsigned long v )
+{
+ _gcry_mpi_mul_ui (w, u, v);
+}
+
+void
+gcry_mpi_mulm (gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m)
+{
+ _gcry_mpi_mulm (w, u, v, m);
+}
+
+void
+gcry_mpi_mul_2exp (gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt)
+{
+ _gcry_mpi_mul_2exp (w, u, cnt);
+}
+
+void
+gcry_mpi_div (gcry_mpi_t q, gcry_mpi_t r,
+ gcry_mpi_t dividend, gcry_mpi_t divisor, int round)
+{
+ _gcry_mpi_div (q, r, dividend, divisor, round);
+}
+
+void
+gcry_mpi_mod (gcry_mpi_t r, gcry_mpi_t dividend, gcry_mpi_t divisor)
+{
+ _gcry_mpi_mod (r, dividend, divisor);
+}
+
+void
+gcry_mpi_powm (gcry_mpi_t w, const gcry_mpi_t b, const gcry_mpi_t e,
+ const gcry_mpi_t m)
+{
+ _gcry_mpi_powm (w, b, e, m);
+}
+
+int
+gcry_mpi_gcd (gcry_mpi_t g, gcry_mpi_t a, gcry_mpi_t b)
+{
+ return _gcry_mpi_gcd (g, a, b);
+}
+
+int
+gcry_mpi_invm (gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t m)
+{
+ return _gcry_mpi_invm (x, a, m);
+}
+
+
+unsigned int
+gcry_mpi_get_nbits (gcry_mpi_t a)
+{
+ return _gcry_mpi_get_nbits (a);
+}
+
+int
+gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n)
+{
+ return _gcry_mpi_test_bit (a, n);
+}
+
+void
+gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_set_bit (a, n);
+}
+
+void
+gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_clear_bit (a, n);
+}
+
+void
+gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_set_highbit (a, n);
+}
+
+void
+gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_clear_highbit (a, n);
+}
+
+void
+gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n)
+{
+ _gcry_mpi_rshift (x, a, n);
+}
+
+gcry_mpi_t
+gcry_mpi_set_opaque (gcry_mpi_t a, void *p, unsigned int nbits)
+{
+ return _gcry_mpi_set_opaque (a, p, nbits);
+}
+
+void *
+gcry_mpi_get_opaque (gcry_mpi_t a, unsigned int *nbits)
+{
+ return _gcry_mpi_get_opaque (a, nbits);
+}
+
+void
+gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
+{
+ _gcry_mpi_set_flag (a, flag);
+}
+
+void
+gcry_mpi_clear_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
+{
+ _gcry_mpi_clear_flag (a, flag);
+}
+
+int
+gcry_mpi_get_flag (gcry_mpi_t a, enum gcry_mpi_flag flag)
+{
+ return _gcry_mpi_get_flag (a, flag);
+}
+
+gcry_error_t
+gcry_cipher_open (gcry_cipher_hd_t *handle,
+ int algo, int mode, unsigned int flags)
+{
+ return _gcry_cipher_open (handle, algo, mode, flags);
+}
+
+void
+gcry_cipher_close (gcry_cipher_hd_t h)
+{
+ _gcry_cipher_close (h);
+}
+
+gcry_error_t
+gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen)
+{
+ return _gcry_cipher_ctl (h, cmd, buffer, buflen);
+}
+
+gcry_error_t
+gcry_cipher_info (gcry_cipher_hd_t h, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_cipher_info (h, what, buffer, nbytes);
+}
+
+gcry_error_t
+gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_cipher_algo_info (algo, what, buffer, nbytes);
+}
+
+const char *
+gcry_cipher_algo_name (int algorithm)
+{
+ return _gcry_cipher_algo_name (algorithm);
+}
+
+int
+gcry_cipher_map_name (const char *name)
+{
+ return _gcry_cipher_map_name (name);
+}
+
+int
+gcry_cipher_mode_from_oid (const char *string)
+{
+ return _gcry_cipher_mode_from_oid (string);
+}
+
+gcry_error_t
+gcry_cipher_encrypt (gcry_cipher_hd_t h,
+ void *out, size_t outsize,
+ const void *in, size_t inlen)
+{
+ return _gcry_cipher_encrypt (h, out, outsize, in, inlen);
+}
+
+gcry_error_t
+gcry_cipher_decrypt (gcry_cipher_hd_t h,
+ void *out, size_t outsize,
+ const void *in, size_t inlen)
+{
+ return _gcry_cipher_decrypt (h, out, outsize, in, inlen);
+
+}
+
+size_t
+gcry_cipher_get_algo_keylen (int algo)
+{
+ return _gcry_cipher_get_algo_keylen (algo);
+}
+
+size_t
+gcry_cipher_get_algo_blklen (int algo)
+{
+ return _gcry_cipher_get_algo_blklen (algo);
+}
+
+gcry_error_t
+gcry_cipher_list (int *list, int *list_length)
+{
+ return _gcry_cipher_list (list, list_length);
+}
+
+gcry_error_t
+gcry_pk_encrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t pkey)
+{
+ return _gcry_pk_encrypt (result, data, pkey);
+}
+
+gcry_error_t
+gcry_pk_decrypt (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
+{
+ return _gcry_pk_decrypt (result, data, skey);
+}
+
+gcry_error_t
+gcry_pk_sign (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t skey)
+{
+ return _gcry_pk_sign (result, data, skey);
+}
+
+gcry_error_t
+gcry_pk_verify (gcry_sexp_t sigval, gcry_sexp_t data, gcry_sexp_t pkey)
+{
+ return _gcry_pk_verify (sigval, data, pkey);
+}
+
+gcry_error_t
+gcry_pk_testkey (gcry_sexp_t key)
+{
+ return _gcry_pk_testkey (key);
+}
+
+gcry_error_t
+gcry_pk_genkey (gcry_sexp_t *r_key, gcry_sexp_t s_parms)
+{
+ return _gcry_pk_genkey (r_key, s_parms);
+}
+
+gcry_error_t
+gcry_pk_ctl (int cmd, void *buffer, size_t buflen)
+{
+ return _gcry_pk_ctl (cmd, buffer, buflen);
+}
+
+gcry_error_t
+gcry_pk_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_pk_algo_info (algo, what, buffer, nbytes);
+}
+
+const char *
+gcry_pk_algo_name (int algorithm)
+{
+ return _gcry_pk_algo_name (algorithm);
+}
+
+int
+gcry_pk_map_name (const char *name)
+{
+ return _gcry_pk_map_name (name);
+}
+
+unsigned int
+gcry_pk_get_nbits (gcry_sexp_t key)
+{
+ return _gcry_pk_get_nbits (key);
+}
+
+unsigned char *
+gcry_pk_get_keygrip (gcry_sexp_t key, unsigned char *array)
+{
+ return _gcry_pk_get_keygrip (key, array);
+}
+
+gcry_error_t
+gcry_pk_list (int *list, int *list_length)
+{
+ return _gcry_pk_list (list, list_length);
+}
+
+gcry_error_t
+gcry_md_open (gcry_md_hd_t *h, int algo, unsigned int flags)
+{
+ return _gcry_md_open (h, algo, flags);
+}
+
+void
+gcry_md_close (gcry_md_hd_t hd)
+{
+ _gcry_md_close (hd);
+}
+
+gcry_error_t
+gcry_md_enable (gcry_md_hd_t hd, int algo)
+{
+ return _gcry_md_enable (hd, algo);
+}
+
+gcry_error_t
+gcry_md_copy (gcry_md_hd_t *bhd, gcry_md_hd_t ahd)
+{
+ return _gcry_md_copy (bhd, ahd);
+}
+
+void
+gcry_md_reset (gcry_md_hd_t hd)
+{
+ _gcry_md_reset (hd);
+}
+
+gcry_error_t
+gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen)
+{
+ return _gcry_md_ctl (hd, cmd, buffer, buflen);
+}
+
+void
+gcry_md_write (gcry_md_hd_t hd, const void *buffer, size_t length)
+{
+ _gcry_md_write (hd, buffer, length);
+}
+
+unsigned char *
+gcry_md_read (gcry_md_hd_t hd, int algo)
+{
+ return _gcry_md_read (hd, algo);
+}
+
+void
+gcry_md_hash_buffer (int algo, void *digest,
+ const void *buffer, size_t length)
+{
+ return _gcry_md_hash_buffer (algo, digest, buffer, length);
+}
+
+int
+gcry_md_get_algo (gcry_md_hd_t hd)
+{
+ return _gcry_md_get_algo (hd);
+}
+
+unsigned int
+gcry_md_get_algo_dlen (int algo)
+{
+ return _gcry_md_get_algo_dlen (algo);
+}
+
+int
+gcry_md_is_enabled (gcry_md_hd_t a, int algo)
+{
+ return _gcry_md_is_enabled (a, algo);
+}
+
+int
+gcry_md_is_secure (gcry_md_hd_t a)
+{
+ return _gcry_md_is_secure (a);
+}
+
+gcry_error_t
+gcry_md_info (gcry_md_hd_t h, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_md_info (h, what, buffer, nbytes);
+}
+
+gcry_error_t
+gcry_md_algo_info (int algo, int what, void *buffer, size_t *nbytes)
+{
+ return _gcry_md_algo_info (algo, what, buffer, nbytes);
+}
+
+const char *
+gcry_md_algo_name (int algo)
+{
+ return _gcry_md_algo_name (algo);
+}
+
+int
+gcry_md_map_name (const char* name)
+{
+ return _gcry_md_map_name (name);
+}
+
+gcry_error_t
+gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen)
+{
+ return _gcry_md_setkey (hd, key, keylen);
+}
+
+void
+gcry_md_debug (gcry_md_hd_t hd, const char *suffix)
+{
+ _gcry_md_debug (hd, suffix);
+}
+
+gcry_error_t
+gcry_md_list (int *list, int *list_length)
+{
+ return _gcry_md_list (list, list_length);
+}
+
+gcry_error_t
+gcry_ac_data_new (gcry_ac_data_t *data)
+{
+ return _gcry_ac_data_new (data);
+}
+
+void
+gcry_ac_data_destroy (gcry_ac_data_t data)
+{
+ _gcry_ac_data_destroy (data);
+}
+
+gcry_error_t
+gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
+{
+ return _gcry_ac_data_copy (data_cp, data);
+}
+
+unsigned int
+gcry_ac_data_length (gcry_ac_data_t data)
+{
+ return _gcry_ac_data_length (data);
+}
+
+void
+gcry_ac_data_clear (gcry_ac_data_t data)
+{
+ _gcry_ac_data_clear (data);
+}
+
+gcry_error_t
+gcry_ac_data_set (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t mpi)
+{
+ return _gcry_ac_data_set (data, flags, name, mpi);
+}
+
+gcry_error_t
+gcry_ac_data_get_name (gcry_ac_data_t data, unsigned int flags,
+ const char *name, gcry_mpi_t *mpi)
+{
+ return _gcry_ac_data_get_name (data, flags, name, mpi);
+}
+
+gcry_error_t
+gcry_ac_data_get_index (gcry_ac_data_t data, unsigned int flags,
+ unsigned int idx, const char **name, gcry_mpi_t *mpi)
+{
+ return _gcry_ac_data_get_index (data, flags, idx, name, mpi);
+}
+
+gcry_error_t
+gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
+ const char **identifiers)
+{
+ return _gcry_ac_data_to_sexp (data, sexp, identifiers);
+}
+
+gcry_error_t
+gcry_ac_data_from_sexp (gcry_ac_data_t *data, gcry_sexp_t sexp,
+ const char **identifiers)
+{
+ return _gcry_ac_data_from_sexp (data, sexp, identifiers);
+}
+
+void
+gcry_ac_io_init (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, ...)
+{
+ va_list arg_ptr;
+
+ va_start (arg_ptr, type);
+ _gcry_ac_io_init_va (ac_io, mode, type, arg_ptr);
+ va_end (arg_ptr);
+}
+
+void
+gcry_ac_io_init_va (gcry_ac_io_t *ac_io, gcry_ac_io_mode_t mode,
+ gcry_ac_io_type_t type, va_list ap)
+{
+ return _gcry_ac_io_init_va (ac_io, mode, type, ap);
+}
+
+gcry_error_t
+gcry_ac_open (gcry_ac_handle_t *handle,
+ gcry_ac_id_t algorithm, unsigned int flags)
+{
+ return _gcry_ac_open (handle, algorithm, flags);
+}
+
+void
+gcry_ac_close (gcry_ac_handle_t handle)
+{
+ _gcry_ac_close (handle);
+}
+
+gcry_error_t
+gcry_ac_key_init (gcry_ac_key_t *key, gcry_ac_handle_t handle,
+ gcry_ac_key_type_t type, gcry_ac_data_t data)
+{
+ return _gcry_ac_key_init (key, handle, type, data);
+}
+
+gcry_error_t
+gcry_ac_key_pair_generate (gcry_ac_handle_t handle,
+ unsigned int nbits, void *spec,
+ gcry_ac_key_pair_t *key_pair,
+ gcry_mpi_t **miscdata)
+{
+ return _gcry_ac_key_pair_generate ( handle, nbits, spec, key_pair, miscdata);
+}
+
+gcry_ac_key_t
+gcry_ac_key_pair_extract (gcry_ac_key_pair_t keypair, gcry_ac_key_type_t which)
+{
+ return _gcry_ac_key_pair_extract (keypair, which);
+}
+
+gcry_ac_data_t
+gcry_ac_key_data_get (gcry_ac_key_t key)
+{
+ return _gcry_ac_key_data_get (key);
+}
+
+gcry_error_t
+gcry_ac_key_test (gcry_ac_handle_t handle, gcry_ac_key_t key)
+{
+ return _gcry_ac_key_test (handle, key);
+}
+
+gcry_error_t
+gcry_ac_key_get_nbits (gcry_ac_handle_t handle,
+ gcry_ac_key_t key, unsigned int *nbits)
+{
+ return _gcry_ac_key_get_nbits (handle, key, nbits);
+}
+
+gcry_error_t
+gcry_ac_key_get_grip (gcry_ac_handle_t handle, gcry_ac_key_t key,
+ unsigned char *key_grip)
+{
+ return _gcry_ac_key_get_grip (handle, key, key_grip);
+}
+
+void
+gcry_ac_key_destroy (gcry_ac_key_t key)
+{
+ _gcry_ac_key_destroy (key);
+}
+
+void
+gcry_ac_key_pair_destroy (gcry_ac_key_pair_t key_pair)
+{
+ _gcry_ac_key_pair_destroy (key_pair);
+}
+
+gcry_error_t
+gcry_ac_data_encode (gcry_ac_em_t method, unsigned int flags, void *options,
+ gcry_ac_io_t *io_read, gcry_ac_io_t *io_write)
+{
+ return _gcry_ac_data_encode (method, flags, options, io_read, io_write);
+}
+
+gcry_error_t
+gcry_ac_data_decode (gcry_ac_em_t method, unsigned int flags, void *options,
+ gcry_ac_io_t *io_read, gcry_ac_io_t *io_write)
+{
+ return _gcry_ac_data_decode (method, flags, options, io_read, io_write);
+}
+
+gcry_error_t
+gcry_ac_data_encrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t data_plain,
+ gcry_ac_data_t *data_encrypted)
+{
+ return _gcry_ac_data_encrypt (handle, flags, key,
+ data_plain, data_encrypted);
+}
+
+gcry_error_t
+gcry_ac_data_decrypt (gcry_ac_handle_t handle,
+ unsigned int flags,
+ gcry_ac_key_t key,
+ gcry_mpi_t *data_plain,
+ gcry_ac_data_t data_encrypted)
+{
+ return _gcry_ac_data_decrypt (handle, flags, key,
+ data_plain, data_encrypted);
+}
+
+gcry_error_t
+gcry_ac_data_sign (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t *data_signature)
+{
+ return _gcry_ac_data_sign (handle, key, data, data_signature);
+}
+
+gcry_error_t
+gcry_ac_data_verify (gcry_ac_handle_t handle,
+ gcry_ac_key_t key,
+ gcry_mpi_t data,
+ gcry_ac_data_t data_signature)
+{
+ return _gcry_ac_data_verify (handle, key, data, data_signature);
+}
+
+gcry_error_t
+gcry_ac_data_encrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_cipher)
+{
+ return _gcry_ac_data_encrypt_scheme (handle, scheme, flags, opts, key,
+ io_message, io_cipher);
+}
+
+gcry_error_t
+gcry_ac_data_decrypt_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_cipher,
+ gcry_ac_io_t *io_message)
+{
+ return _gcry_ac_data_decrypt_scheme (handle, scheme, flags, opts, key,
+ io_cipher, io_message);
+}
+
+gcry_error_t
+gcry_ac_data_sign_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+{
+ return _gcry_ac_data_sign_scheme (handle, scheme, flags, opts, key,
+ io_message, io_signature);
+}
+
+gcry_error_t
+gcry_ac_data_verify_scheme (gcry_ac_handle_t handle,
+ gcry_ac_scheme_t scheme,
+ unsigned int flags, void *opts,
+ gcry_ac_key_t key,
+ gcry_ac_io_t *io_message,
+ gcry_ac_io_t *io_signature)
+{
+ return _gcry_ac_data_verify_scheme (handle, scheme, flags, opts, key,
+ io_message, io_signature);
+}
+
+gcry_error_t
+gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name)
+{
+ /* This function is deprecated. We implement it in terms of the
+ suggested replacement. */
+ const char *tmp = _gcry_pk_algo_name (algorithm);
+ if (!*tmp)
+ return gcry_error (GPG_ERR_PUBKEY_ALGO);
+ *name = tmp;
+ return 0;
+}
+
+gcry_error_t
+gcry_ac_name_to_id (const char *name, gcry_ac_id_t *algorithm)
+{
+ /* This function is deprecated. We implement it in terms of the
+ suggested replacement. */
+ int algo = _gcry_pk_map_name (name);
+ if (!algo)
+ return gcry_error (GPG_ERR_PUBKEY_ALGO);
+ *algorithm = algo;
+ return 0;
+}
+
+void
+gcry_randomize (void *buffer, size_t length, enum gcry_random_level level)
+{
+ _gcry_randomize (buffer, length, level);
+}
+
+gcry_error_t
+gcry_random_add_bytes (const void *buffer, size_t length, int quality)
+{
+ return _gcry_random_add_bytes (buffer, length, quality);
+}
+
+void *
+gcry_random_bytes (size_t nbytes, enum gcry_random_level level)
+{
+ return _gcry_random_bytes (nbytes,level);
+}
+
+void *
+gcry_random_bytes_secure (size_t nbytes, enum gcry_random_level level)
+{
+ return _gcry_random_bytes_secure (nbytes, level);
+}
+
+void
+gcry_mpi_randomize (gcry_mpi_t w,
+ unsigned int nbits, enum gcry_random_level level)
+{
+ _gcry_mpi_randomize (w, nbits, level);
+}
+
+void
+gcry_create_nonce (void *buffer, size_t length)
+{
+ _gcry_create_nonce (buffer, length);
+}
+
+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)
+{
+ return _gcry_prime_generate (prime, prime_bits, factor_bits, factors,
+ cb_func, cb_arg, random_level, flags);
+}
+
+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)
+{
+ return _gcry_prime_group_generator (r_g, prime, factors, start_g);
+}
+
+void
+gcry_prime_release_factors (gcry_mpi_t *factors)
+{
+ _gcry_prime_release_factors (factors);
+}
+
+gcry_error_t
+gcry_prime_check (gcry_mpi_t x, unsigned int flags)
+{
+ return _gcry_prime_check (x, flags);
+}
+
+void
+gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data)
+{
+ _gcry_set_progress_handler (cb, cb_data);
+}
+
+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)
+{
+ _gcry_set_allocation_handler (func_alloc, func_alloc_secure,
+ func_secure_check, func_realloc, func_free);
+}
+
+void
+gcry_set_outofcore_handler (gcry_handler_no_mem_t h, void *opaque)
+{
+ _gcry_set_outofcore_handler (h, opaque);
+}
+
+void
+gcry_set_fatalerror_handler (gcry_handler_error_t fnc, void *opaque)
+{
+ _gcry_set_fatalerror_handler (fnc, opaque);
+}
+
+void
+gcry_set_log_handler (gcry_handler_log_t f, void *opaque)
+{
+ _gcry_set_log_handler (f, opaque);
+}
+
+void
+gcry_set_gettext_handler (const char *(*f)(const char*))
+{
+ _gcry_set_gettext_handler (f);
+}
+
+void *
+gcry_malloc (size_t n)
+{
+ return _gcry_malloc (n);
+}
+
+void *
+gcry_calloc (size_t n, size_t m)
+{
+ return _gcry_calloc (n, m);
+}
+
+void *
+gcry_malloc_secure (size_t n)
+{
+ return _gcry_malloc_secure (n);
+}
+
+void *
+gcry_calloc_secure (size_t n, size_t m)
+{
+ return _gcry_calloc_secure (n,m);
+}
+
+void *
+gcry_realloc (void *a, size_t n)
+{
+ return _gcry_realloc (a, n);
+}
+
+char *
+gcry_strdup (const char *string)
+{
+ return _gcry_strdup (string);
+}
+
+void *
+gcry_xmalloc (size_t n)
+{
+ return _gcry_xmalloc (n);
+}
+
+void *
+gcry_xcalloc (size_t n, size_t m)
+{
+ return _gcry_xcalloc (n, m);
+}
+
+void *
+gcry_xmalloc_secure (size_t n)
+{
+ return _gcry_xmalloc_secure (n);
+}
+
+void *
+gcry_xcalloc_secure (size_t n, size_t m)
+{
+ return _gcry_xcalloc_secure (n, m);
+}
+
+void *
+gcry_xrealloc (void *a, size_t n)
+{
+ return _gcry_xrealloc (a, n);
+}
+
+char *
+gcry_xstrdup (const char *a)
+{
+ return _gcry_xstrdup (a);
+}
+
+void
+gcry_free (void *a)
+{
+ _gcry_free (a);
+}
+
+int
+gcry_is_secure (const void *a)
+{
+ return _gcry_is_secure (a);
+}
+
+
+gcry_error_t
+gcry_cipher_register (gcry_cipher_spec_t *cipher, int *algorithm_id,
+ gcry_module_t *module)
+{
+ return _gcry_cipher_register (cipher, algorithm_id, module);
+}
+
+void
+gcry_cipher_unregister (gcry_module_t module)
+{
+ _gcry_cipher_unregister (module);
+}
+
+gcry_error_t
+gcry_pk_register (gcry_pk_spec_t *pubkey, unsigned int *algorithm_id,
+ gcry_module_t *module)
+{
+ return _gcry_pk_register (pubkey, algorithm_id, module);
+}
+
+void
+gcry_pk_unregister (gcry_module_t module)
+{
+ _gcry_pk_unregister (module);
+}
+
+gcry_error_t
+gcry_md_register (gcry_md_spec_t *digest, unsigned int *algorithm_id,
+ gcry_module_t *module)
+{
+ return _gcry_md_register (digest, algorithm_id, module);
+}
+
+void
+gcry_md_unregister (gcry_module_t module)
+{
+ _gcry_md_unregister (module);
+}
diff --git a/src/visibility.h b/src/visibility.h
new file mode 100644
index 00000000..f0350fa2
--- /dev/null
+++ b/src/visibility.h
@@ -0,0 +1,710 @@
+/* visibility.h - Set visibility attribute
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GCRY_VISIBILITY_H
+#define GCRY_VISIBILITY_H
+
+/* Redefine all public symbols with an underscore. */
+#define gcry_check_version _gcry_check_version
+#define gcry_control _gcry_control
+
+#define gcry_set_allocation_handler _gcry_set_allocation_handler
+#define gcry_set_fatalerror_handler _gcry_set_fatalerror_handler
+#define gcry_set_gettext_handler _gcry_set_gettext_handler
+#define gcry_set_log_handler _gcry_set_log_handler
+#define gcry_set_outofcore_handler _gcry_set_outofcore_handler
+#define gcry_set_progress_handler _gcry_set_progress_handler
+#define gcry_err_code_from_errno _gcry_err_code_from_errno
+#define gcry_err_code_to_errno _gcry_err_code_to_errno
+#define gcry_err_make_from_errno _gcry_err_make_from_errno
+#define gcry_error_from_errno _gcry_error_from_errno
+#define gcry_strerror _gcry_strerror
+#define gcry_strsource _gcry_strsource
+
+#define gcry_free _gcry_free
+#define gcry_malloc _gcry_malloc
+#define gcry_malloc_secure _gcry_malloc_secure
+#define gcry_calloc _gcry_calloc
+#define gcry_calloc_secure _gcry_calloc_secure
+#define gcry_realloc _gcry_realloc
+#define gcry_strdup _gcry_strdup
+#define gcry_is_secure _gcry_is_secure
+#define gcry_xcalloc _gcry_xcalloc
+#define gcry_xcalloc_secure _gcry_xcalloc_secure
+#define gcry_xmalloc _gcry_xmalloc
+#define gcry_xmalloc_secure _gcry_xmalloc_secure
+#define gcry_xrealloc _gcry_xrealloc
+#define gcry_xstrdup _gcry_xstrdup
+
+#define gcry_md_algo_info _gcry_md_algo_info
+#define gcry_md_algo_name _gcry_md_algo_name
+#define gcry_md_close _gcry_md_close
+#define gcry_md_copy _gcry_md_copy
+#define gcry_md_ctl _gcry_md_ctl
+#define gcry_md_enable _gcry_md_enable
+#define gcry_md_get _gcry_md_get
+#define gcry_md_get_algo _gcry_md_get_algo
+#define gcry_md_get_algo_dlen _gcry_md_get_algo_dlen
+#define gcry_md_hash_buffer _gcry_md_hash_buffer
+#define gcry_md_info _gcry_md_info
+#define gcry_md_is_enabled _gcry_md_is_enabled
+#define gcry_md_is_secure _gcry_md_is_secure
+#define gcry_md_list _gcry_md_list
+#define gcry_md_map_name _gcry_md_map_name
+#define gcry_md_open _gcry_md_open
+#define gcry_md_read _gcry_md_read
+#define gcry_md_register _gcry_md_register
+#define gcry_md_reset _gcry_md_reset
+#define gcry_md_setkey _gcry_md_setkey
+#define gcry_md_unregister _gcry_md_unregister
+#define gcry_md_write _gcry_md_write
+#define gcry_md_debug _gcry_md_debug
+
+#define gcry_cipher_algo_info _gcry_cipher_algo_info
+#define gcry_cipher_algo_name _gcry_cipher_algo_name
+#define gcry_cipher_close _gcry_cipher_close
+#define gcry_cipher_ctl _gcry_cipher_ctl
+#define gcry_cipher_decrypt _gcry_cipher_decrypt
+#define gcry_cipher_encrypt _gcry_cipher_encrypt
+#define gcry_cipher_get_algo_blklen _gcry_cipher_get_algo_blklen
+#define gcry_cipher_get_algo_keylen _gcry_cipher_get_algo_keylen
+#define gcry_cipher_info _gcry_cipher_info
+#define gcry_cipher_list _gcry_cipher_list
+#define gcry_cipher_map_name _gcry_cipher_map_name
+#define gcry_cipher_mode_from_oid _gcry_cipher_mode_from_oid
+#define gcry_cipher_open _gcry_cipher_open
+#define gcry_cipher_register _gcry_cipher_register
+#define gcry_cipher_unregister _gcry_cipher_unregister
+
+#define gcry_pk_algo_info _gcry_pk_algo_info
+#define gcry_pk_algo_name _gcry_pk_algo_name
+#define gcry_pk_ctl _gcry_pk_ctl
+#define gcry_pk_decrypt _gcry_pk_decrypt
+#define gcry_pk_encrypt _gcry_pk_encrypt
+#define gcry_pk_genkey _gcry_pk_genkey
+#define gcry_pk_get_keygrip _gcry_pk_get_keygrip
+#define gcry_pk_get_nbits _gcry_pk_get_nbits
+#define gcry_pk_list _gcry_pk_list
+#define gcry_pk_map_name _gcry_pk_map_name
+#define gcry_pk_register _gcry_pk_register
+#define gcry_pk_sign _gcry_pk_sign
+#define gcry_pk_testkey _gcry_pk_testkey
+#define gcry_pk_unregister _gcry_pk_unregister
+#define gcry_pk_verify _gcry_pk_verify
+
+#define gcry_ac_data_new _gcry_ac_data_new
+#define gcry_ac_data_destroy _gcry_ac_data_destroy
+#define gcry_ac_data_copy _gcry_ac_data_copy
+#define gcry_ac_data_length _gcry_ac_data_length
+#define gcry_ac_data_clear _gcry_ac_data_clear
+#define gcry_ac_data_set _gcry_ac_data_set
+#define gcry_ac_data_get_name _gcry_ac_data_get_name
+#define gcry_ac_data_get_index _gcry_ac_data_get_index
+#define gcry_ac_open _gcry_ac_open
+#define gcry_ac_close _gcry_ac_close
+#define gcry_ac_key_init _gcry_ac_key_init
+#define gcry_ac_key_pair_generate _gcry_ac_key_pair_generate
+#define gcry_ac_key_pair_extract _gcry_ac_key_pair_extract
+#define gcry_ac_key_data_get _gcry_ac_key_data_get
+#define gcry_ac_key_test _gcry_ac_key_test
+#define gcry_ac_key_get_nbits _gcry_ac_key_get_nbits
+#define gcry_ac_key_get_grip _gcry_ac_key_get_grip
+#define gcry_ac_key_destroy _gcry_ac_key_destroy
+#define gcry_ac_key_pair_destroy _gcry_ac_key_pair_destroy
+#define gcry_ac_data_encrypt _gcry_ac_data_encrypt
+#define gcry_ac_data_decrypt _gcry_ac_data_decrypt
+#define gcry_ac_data_sign _gcry_ac_data_sign
+#define gcry_ac_data_verify _gcry_ac_data_verify
+#define gcry_ac_id_to_name _gcry_ac_id_to_name
+#define gcry_ac_name_to_id _gcry_ac_name_to_id
+#define gcry_ac_data_encode _gcry_ac_data_encode
+#define gcry_ac_data_decode _gcry_ac_data_decode
+#define gcry_ac_mpi_to_os _gcry_ac_mpi_to_os
+#define gcry_ac_mpi_to_os_alloc _gcry_ac_mpi_to_os_alloc
+#define gcry_ac_os_to_mpi _gcry_ac_os_to_mpi
+#define gcry_ac_data_encrypt_scheme _gcry_ac_data_encrypt_scheme
+#define gcry_ac_data_decrypt_scheme _gcry_ac_data_decrypt_scheme
+#define gcry_ac_data_sign_scheme _gcry_ac_data_sign_scheme
+#define gcry_ac_data_verify_scheme _gcry_ac_data_verify_scheme
+#define gcry_ac_data_to_sexp _gcry_ac_data_to_sexp
+#define gcry_ac_data_from_sexp _gcry_ac_data_from_sexp
+#define gcry_ac_io_init _gcry_ac_io_init
+#define gcry_ac_io_init_va _gcry_ac_io_init_va
+
+#define gcry_prime_check _gcry_prime_check
+#define gcry_prime_generate _gcry_prime_generate
+#define gcry_prime_group_generator _gcry_prime_group_generator
+#define gcry_prime_release_factors _gcry_prime_release_factors
+
+#define gcry_random_add_bytes _gcry_random_add_bytes
+#define gcry_random_bytes _gcry_random_bytes
+#define gcry_random_bytes_secure _gcry_random_bytes_secure
+#define gcry_randomize _gcry_randomize
+#define gcry_create_nonce _gcry_create_nonce
+
+#define gcry_sexp_alist _gcry_sexp_alist
+#define gcry_sexp_append _gcry_sexp_append
+#define gcry_sexp_build _gcry_sexp_build
+#define gcry_sexp_build_array _gcry_sexp_build_array
+#define gcry_sexp_cadr _gcry_sexp_cadr
+#define gcry_sexp_canon_len _gcry_sexp_canon_len
+#define gcry_sexp_car _gcry_sexp_car
+#define gcry_sexp_cdr _gcry_sexp_cdr
+#define gcry_sexp_cons _gcry_sexp_cons
+#define gcry_sexp_create _gcry_sexp_create
+#define gcry_sexp_dump _gcry_sexp_dump
+#define gcry_sexp_find_token _gcry_sexp_find_token
+#define gcry_sexp_length _gcry_sexp_length
+#define gcry_sexp_new _gcry_sexp_new
+#define gcry_sexp_nth _gcry_sexp_nth
+#define gcry_sexp_nth_data _gcry_sexp_nth_data
+#define gcry_sexp_nth_mpi _gcry_sexp_nth_mpi
+#define gcry_sexp_prepend _gcry_sexp_prepend
+#define gcry_sexp_release _gcry_sexp_release
+#define gcry_sexp_sprint _gcry_sexp_sprint
+#define gcry_sexp_sscan _gcry_sexp_sscan
+#define gcry_sexp_vlist _gcry_sexp_vlist
+#define gcry_sexp_nth_string _gcry_sexp_nth_string
+
+#define gcry_mpi_add _gcry_mpi_add
+#define gcry_mpi_add_ui _gcry_mpi_add_ui
+#define gcry_mpi_addm _gcry_mpi_addm
+#define gcry_mpi_aprint _gcry_mpi_aprint
+#define gcry_mpi_clear_bit _gcry_mpi_clear_bit
+#define gcry_mpi_clear_flag _gcry_mpi_clear_flag
+#define gcry_mpi_clear_highbit _gcry_mpi_clear_highbit
+#define gcry_mpi_cmp _gcry_mpi_cmp
+#define gcry_mpi_cmp_ui _gcry_mpi_cmp_ui
+#define gcry_mpi_copy _gcry_mpi_copy
+#define gcry_mpi_div _gcry_mpi_div
+#define gcry_mpi_dump _gcry_mpi_dump
+#define gcry_mpi_gcd _gcry_mpi_gcd
+#define gcry_mpi_get_flag _gcry_mpi_get_flag
+#define gcry_mpi_get_nbits _gcry_mpi_get_nbits
+#define gcry_mpi_get_opaque _gcry_mpi_get_opaque
+#define gcry_mpi_invm _gcry_mpi_invm
+#define gcry_mpi_mod _gcry_mpi_mod
+#define gcry_mpi_mul _gcry_mpi_mul
+#define gcry_mpi_mul_2exp _gcry_mpi_mul_2exp
+#define gcry_mpi_mul_ui _gcry_mpi_mul_ui
+#define gcry_mpi_mulm _gcry_mpi_mulm
+#define gcry_mpi_new _gcry_mpi_new
+#define gcry_mpi_powm _gcry_mpi_powm
+#define gcry_mpi_print _gcry_mpi_print
+#define gcry_mpi_randomize _gcry_mpi_randomize
+#define gcry_mpi_release _gcry_mpi_release
+#define gcry_mpi_rshift _gcry_mpi_rshift
+#define gcry_mpi_scan _gcry_mpi_scan
+#define gcry_mpi_set _gcry_mpi_set
+#define gcry_mpi_set_bit _gcry_mpi_set_bit
+#define gcry_mpi_set_flag _gcry_mpi_set_flag
+#define gcry_mpi_set_highbit _gcry_mpi_set_highbit
+#define gcry_mpi_set_opaque _gcry_mpi_set_opaque
+#define gcry_mpi_set_ui _gcry_mpi_set_ui
+#define gcry_mpi_snew _gcry_mpi_snew
+#define gcry_mpi_sub _gcry_mpi_sub
+#define gcry_mpi_sub_ui _gcry_mpi_sub_ui
+#define gcry_mpi_subm _gcry_mpi_subm
+#define gcry_mpi_swap _gcry_mpi_swap
+#define gcry_mpi_test_bit _gcry_mpi_test_bit
+
+#define gcry_cipher_register _gcry_cipher_register
+#define gcry_cipher_unregister _gcry_cipher_unregister
+#define gcry_pk_register _gcry_pk_register
+#define gcry_pk_unregister _gcry_pk_unregister
+#define gcry_md_register _gcry_md_register
+#define gcry_md_unregister _gcry_md_unregister
+
+
+/* Include the main header here so that public symbols are mapped to
+ the internal underscored ones. */
+#ifdef _GCRY_INCLUDED_BY_VISIBILITY_C
+ /* We need to redeclare the deprecated functions without the
+ deprecated attribute. */
+# define GCRYPT_NO_DEPRECATED
+# include "gcrypt.h"
+ gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t algorithm, const char **name);
+ gcry_error_t gcry_ac_name_to_id (const char *name, gcry_ac_id_t *algorithm);
+#else
+# include "gcrypt.h"
+#endif
+
+/* Prototypes of functions exported but not ready for use. */
+gcry_err_code_t gcry_md_get (gcry_md_hd_t hd, int algo,
+ unsigned char *buffer, int buflen);
+void gcry_ac_mpi_to_os (gcry_mpi_t mpi, unsigned char *os, size_t os_n);
+gcry_error_t gcry_ac_mpi_to_os_alloc (gcry_mpi_t mpi, unsigned char **os,
+ size_t *os_n);
+void gcry_ac_os_to_mpi (gcry_mpi_t mpi, unsigned char *os, size_t os_n);
+
+
+
+/* Our use of the ELF visibility feature works by passing
+ -fvisibiliy=hidden on the command line and by explicitly marking
+ all exported functions as visible.
+
+ NOTE: When adding new functions, please make sure to add them to
+ libgcrypt.vers and libgcrypt.def as well. */
+
+#ifdef _GCRY_INCLUDED_BY_VISIBILITY_C
+
+/* A macro to flag a function as visible. Note that we take the
+ defintion from the mapped name. */
+#ifdef GCRY_USE_VISIBILITY
+# define MARK_VISIBLE(name) \
+ extern __typeof__ (_##name) name __attribute__ ((visibility("default")));
+#else
+# define MARK_VISIBLE(name) /* */
+#endif
+
+
+/* First undef all redefined symbols so that we set the attribute on
+ the correct version name. */
+#undef gcry_check_version
+#undef gcry_control
+
+#undef gcry_set_allocation_handler
+#undef gcry_set_fatalerror_handler
+#undef gcry_set_gettext_handler
+#undef gcry_set_log_handler
+#undef gcry_set_outofcore_handler
+#undef gcry_set_progress_handler
+#undef gcry_err_code_from_errno
+#undef gcry_err_code_to_errno
+#undef gcry_err_make_from_errno
+#undef gcry_error_from_errno
+#undef gcry_strerror
+#undef gcry_strsource
+
+#undef gcry_free
+#undef gcry_malloc
+#undef gcry_malloc_secure
+#undef gcry_calloc
+#undef gcry_calloc_secure
+#undef gcry_realloc
+#undef gcry_strdup
+#undef gcry_is_secure
+#undef gcry_xcalloc
+#undef gcry_xcalloc_secure
+#undef gcry_xmalloc
+#undef gcry_xmalloc_secure
+#undef gcry_xrealloc
+#undef gcry_xstrdup
+
+#undef gcry_md_algo_info
+#undef gcry_md_algo_name
+#undef gcry_md_close
+#undef gcry_md_copy
+#undef gcry_md_ctl
+#undef gcry_md_enable
+#undef gcry_md_get
+#undef gcry_md_get_algo
+#undef gcry_md_get_algo_dlen
+#undef gcry_md_hash_buffer
+#undef gcry_md_info
+#undef gcry_md_is_enabled
+#undef gcry_md_is_secure
+#undef gcry_md_list
+#undef gcry_md_map_name
+#undef gcry_md_open
+#undef gcry_md_read
+#undef gcry_md_register
+#undef gcry_md_reset
+#undef gcry_md_setkey
+#undef gcry_md_unregister
+#undef gcry_md_write
+#undef gcry_md_debug
+
+#undef gcry_cipher_algo_info
+#undef gcry_cipher_algo_name
+#undef gcry_cipher_close
+#undef gcry_cipher_ctl
+#undef gcry_cipher_decrypt
+#undef gcry_cipher_encrypt
+#undef gcry_cipher_get_algo_blklen
+#undef gcry_cipher_get_algo_keylen
+#undef gcry_cipher_info
+#undef gcry_cipher_list
+#undef gcry_cipher_map_name
+#undef gcry_cipher_mode_from_oid
+#undef gcry_cipher_open
+#undef gcry_cipher_register
+#undef gcry_cipher_unregister
+
+#undef gcry_pk_algo_info
+#undef gcry_pk_algo_name
+#undef gcry_pk_ctl
+#undef gcry_pk_decrypt
+#undef gcry_pk_encrypt
+#undef gcry_pk_genkey
+#undef gcry_pk_get_keygrip
+#undef gcry_pk_get_nbits
+#undef gcry_pk_list
+#undef gcry_pk_map_name
+#undef gcry_pk_register
+#undef gcry_pk_sign
+#undef gcry_pk_testkey
+#undef gcry_pk_unregister
+#undef gcry_pk_verify
+
+#undef gcry_ac_data_new
+#undef gcry_ac_data_destroy
+#undef gcry_ac_data_copy
+#undef gcry_ac_data_length
+#undef gcry_ac_data_clear
+#undef gcry_ac_data_set
+#undef gcry_ac_data_get_name
+#undef gcry_ac_data_get_index
+#undef gcry_ac_open
+#undef gcry_ac_close
+#undef gcry_ac_key_init
+#undef gcry_ac_key_pair_generate
+#undef gcry_ac_key_pair_extract
+#undef gcry_ac_key_data_get
+#undef gcry_ac_key_test
+#undef gcry_ac_key_get_nbits
+#undef gcry_ac_key_get_grip
+#undef gcry_ac_key_destroy
+#undef gcry_ac_key_pair_destroy
+#undef gcry_ac_data_encrypt
+#undef gcry_ac_data_decrypt
+#undef gcry_ac_data_sign
+#undef gcry_ac_data_verify
+#undef gcry_ac_id_to_name
+#undef gcry_ac_name_to_id
+#undef gcry_ac_data_encode
+#undef gcry_ac_data_decode
+#undef gcry_ac_mpi_to_os
+#undef gcry_ac_mpi_to_os_alloc
+#undef gcry_ac_os_to_mpi
+#undef gcry_ac_data_encrypt_scheme
+#undef gcry_ac_data_decrypt_scheme
+#undef gcry_ac_data_sign_scheme
+#undef gcry_ac_data_verify_scheme
+#undef gcry_ac_data_to_sexp
+#undef gcry_ac_data_from_sexp
+#undef gcry_ac_io_init
+#undef gcry_ac_io_init_va
+
+#undef gcry_prime_check
+#undef gcry_prime_generate
+#undef gcry_prime_group_generator
+#undef gcry_prime_release_factors
+
+#undef gcry_random_add_bytes
+#undef gcry_random_bytes
+#undef gcry_random_bytes_secure
+#undef gcry_randomize
+#undef gcry_create_nonce
+
+#undef gcry_sexp_alist
+#undef gcry_sexp_append
+#undef gcry_sexp_build
+#undef gcry_sexp_build_array
+#undef gcry_sexp_cadr
+#undef gcry_sexp_canon_len
+#undef gcry_sexp_car
+#undef gcry_sexp_cdr
+#undef gcry_sexp_cons
+#undef gcry_sexp_create
+#undef gcry_sexp_dump
+#undef gcry_sexp_find_token
+#undef gcry_sexp_length
+#undef gcry_sexp_new
+#undef gcry_sexp_nth
+#undef gcry_sexp_nth_data
+#undef gcry_sexp_nth_mpi
+#undef gcry_sexp_prepend
+#undef gcry_sexp_release
+#undef gcry_sexp_sprint
+#undef gcry_sexp_sscan
+#undef gcry_sexp_vlist
+#undef gcry_sexp_nth_string
+
+#undef gcry_mpi_add
+#undef gcry_mpi_add_ui
+#undef gcry_mpi_addm
+#undef gcry_mpi_aprint
+#undef gcry_mpi_clear_bit
+#undef gcry_mpi_clear_flag
+#undef gcry_mpi_clear_highbit
+#undef gcry_mpi_cmp
+#undef gcry_mpi_cmp_ui
+#undef gcry_mpi_copy
+#undef gcry_mpi_div
+#undef gcry_mpi_dump
+#undef gcry_mpi_gcd
+#undef gcry_mpi_get_flag
+#undef gcry_mpi_get_nbits
+#undef gcry_mpi_get_opaque
+#undef gcry_mpi_invm
+#undef gcry_mpi_mod
+#undef gcry_mpi_mul
+#undef gcry_mpi_mul_2exp
+#undef gcry_mpi_mul_ui
+#undef gcry_mpi_mulm
+#undef gcry_mpi_new
+#undef gcry_mpi_powm
+#undef gcry_mpi_print
+#undef gcry_mpi_randomize
+#undef gcry_mpi_release
+#undef gcry_mpi_rshift
+#undef gcry_mpi_scan
+#undef gcry_mpi_set
+#undef gcry_mpi_set_bit
+#undef gcry_mpi_set_flag
+#undef gcry_mpi_set_highbit
+#undef gcry_mpi_set_opaque
+#undef gcry_mpi_set_ui
+#undef gcry_mpi_snew
+#undef gcry_mpi_sub
+#undef gcry_mpi_sub_ui
+#undef gcry_mpi_subm
+#undef gcry_mpi_swap
+#undef gcry_mpi_test_bit
+
+#undef gcry_cipher_register
+#undef gcry_cipher_unregister
+#undef gcry_pk_register
+#undef gcry_pk_unregister
+#undef gcry_md_register
+#undef gcry_md_unregister
+
+
+
+/* Now mark all symbols. */
+
+MARK_VISIBLE (gcry_check_version)
+MARK_VISIBLE (gcry_control)
+
+MARK_VISIBLE (gcry_set_allocation_handler)
+MARK_VISIBLE (gcry_set_fatalerror_handler)
+MARK_VISIBLE (gcry_set_gettext_handler)
+MARK_VISIBLE (gcry_set_log_handler)
+MARK_VISIBLE (gcry_set_outofcore_handler)
+MARK_VISIBLE (gcry_set_progress_handler)
+MARK_VISIBLE (gcry_err_code_from_errno)
+MARK_VISIBLE (gcry_err_code_to_errno)
+MARK_VISIBLE (gcry_err_make_from_errno)
+MARK_VISIBLE (gcry_error_from_errno)
+MARK_VISIBLE (gcry_strerror)
+MARK_VISIBLE (gcry_strsource)
+
+MARK_VISIBLE (gcry_free)
+MARK_VISIBLE (gcry_malloc)
+MARK_VISIBLE (gcry_malloc_secure)
+MARK_VISIBLE (gcry_calloc)
+MARK_VISIBLE (gcry_calloc_secure)
+MARK_VISIBLE (gcry_realloc)
+MARK_VISIBLE (gcry_strdup)
+MARK_VISIBLE (gcry_is_secure)
+MARK_VISIBLE (gcry_xcalloc)
+MARK_VISIBLE (gcry_xcalloc_secure)
+MARK_VISIBLE (gcry_xmalloc)
+MARK_VISIBLE (gcry_xmalloc_secure)
+MARK_VISIBLE (gcry_xrealloc)
+MARK_VISIBLE (gcry_xstrdup)
+
+MARK_VISIBLE (gcry_md_algo_info)
+MARK_VISIBLE (gcry_md_algo_name)
+MARK_VISIBLE (gcry_md_close)
+MARK_VISIBLE (gcry_md_copy)
+MARK_VISIBLE (gcry_md_ctl)
+MARK_VISIBLE (gcry_md_enable)
+MARK_VISIBLE (gcry_md_get)
+MARK_VISIBLE (gcry_md_get_algo)
+MARK_VISIBLE (gcry_md_get_algo_dlen)
+MARK_VISIBLE (gcry_md_hash_buffer)
+MARK_VISIBLE (gcry_md_info)
+MARK_VISIBLE (gcry_md_is_enabled)
+MARK_VISIBLE (gcry_md_is_secure)
+MARK_VISIBLE (gcry_md_list)
+MARK_VISIBLE (gcry_md_map_name)
+MARK_VISIBLE (gcry_md_open)
+MARK_VISIBLE (gcry_md_read)
+MARK_VISIBLE (gcry_md_register)
+MARK_VISIBLE (gcry_md_reset)
+MARK_VISIBLE (gcry_md_setkey)
+MARK_VISIBLE (gcry_md_unregister)
+MARK_VISIBLE (gcry_md_write)
+MARK_VISIBLE (gcry_md_debug)
+
+MARK_VISIBLE (gcry_cipher_algo_info)
+MARK_VISIBLE (gcry_cipher_algo_name)
+MARK_VISIBLE (gcry_cipher_close)
+MARK_VISIBLE (gcry_cipher_ctl)
+MARK_VISIBLE (gcry_cipher_decrypt)
+MARK_VISIBLE (gcry_cipher_encrypt)
+MARK_VISIBLE (gcry_cipher_get_algo_blklen)
+MARK_VISIBLE (gcry_cipher_get_algo_keylen)
+MARK_VISIBLE (gcry_cipher_info)
+MARK_VISIBLE (gcry_cipher_list)
+MARK_VISIBLE (gcry_cipher_map_name)
+MARK_VISIBLE (gcry_cipher_mode_from_oid)
+MARK_VISIBLE (gcry_cipher_open)
+MARK_VISIBLE (gcry_cipher_register)
+MARK_VISIBLE (gcry_cipher_unregister)
+
+MARK_VISIBLE (gcry_pk_algo_info)
+MARK_VISIBLE (gcry_pk_algo_name)
+MARK_VISIBLE (gcry_pk_ctl)
+MARK_VISIBLE (gcry_pk_decrypt)
+MARK_VISIBLE (gcry_pk_encrypt)
+MARK_VISIBLE (gcry_pk_genkey)
+MARK_VISIBLE (gcry_pk_get_keygrip)
+MARK_VISIBLE (gcry_pk_get_nbits)
+MARK_VISIBLE (gcry_pk_list)
+MARK_VISIBLE (gcry_pk_map_name)
+MARK_VISIBLE (gcry_pk_register)
+MARK_VISIBLE (gcry_pk_sign)
+MARK_VISIBLE (gcry_pk_testkey)
+MARK_VISIBLE (gcry_pk_unregister)
+MARK_VISIBLE (gcry_pk_verify)
+
+MARK_VISIBLE (gcry_ac_data_new)
+MARK_VISIBLE (gcry_ac_data_destroy)
+MARK_VISIBLE (gcry_ac_data_copy)
+MARK_VISIBLE (gcry_ac_data_length)
+MARK_VISIBLE (gcry_ac_data_clear)
+MARK_VISIBLE (gcry_ac_data_set)
+MARK_VISIBLE (gcry_ac_data_get_name)
+MARK_VISIBLE (gcry_ac_data_get_index)
+MARK_VISIBLE (gcry_ac_open)
+MARK_VISIBLE (gcry_ac_close)
+MARK_VISIBLE (gcry_ac_key_init)
+MARK_VISIBLE (gcry_ac_key_pair_generate)
+MARK_VISIBLE (gcry_ac_key_pair_extract)
+MARK_VISIBLE (gcry_ac_key_data_get)
+MARK_VISIBLE (gcry_ac_key_test)
+MARK_VISIBLE (gcry_ac_key_get_nbits)
+MARK_VISIBLE (gcry_ac_key_get_grip)
+MARK_VISIBLE (gcry_ac_key_destroy)
+MARK_VISIBLE (gcry_ac_key_pair_destroy)
+MARK_VISIBLE (gcry_ac_data_encrypt)
+MARK_VISIBLE (gcry_ac_data_decrypt)
+MARK_VISIBLE (gcry_ac_data_sign)
+MARK_VISIBLE (gcry_ac_data_verify)
+MARK_VISIBLE (gcry_ac_id_to_name)
+MARK_VISIBLE (gcry_ac_name_to_id)
+/* MARK_VISIBLE (gcry_ac_list) Not defined although it is in
+ libgcrypt.vers. */
+MARK_VISIBLE (gcry_ac_data_encode)
+MARK_VISIBLE (gcry_ac_data_decode)
+MARK_VISIBLE (gcry_ac_mpi_to_os)
+MARK_VISIBLE (gcry_ac_mpi_to_os_alloc)
+MARK_VISIBLE (gcry_ac_os_to_mpi)
+MARK_VISIBLE (gcry_ac_data_encrypt_scheme)
+MARK_VISIBLE (gcry_ac_data_decrypt_scheme)
+MARK_VISIBLE (gcry_ac_data_sign_scheme)
+MARK_VISIBLE (gcry_ac_data_verify_scheme)
+MARK_VISIBLE (gcry_ac_data_to_sexp)
+MARK_VISIBLE (gcry_ac_data_from_sexp)
+MARK_VISIBLE (gcry_ac_io_init)
+MARK_VISIBLE (gcry_ac_io_init_va)
+
+MARK_VISIBLE (gcry_prime_check)
+MARK_VISIBLE (gcry_prime_generate)
+MARK_VISIBLE (gcry_prime_group_generator)
+MARK_VISIBLE (gcry_prime_release_factors)
+
+MARK_VISIBLE (gcry_random_add_bytes)
+MARK_VISIBLE (gcry_random_bytes)
+MARK_VISIBLE (gcry_random_bytes_secure)
+MARK_VISIBLE (gcry_randomize)
+MARK_VISIBLE (gcry_create_nonce)
+
+MARK_VISIBLE (gcry_sexp_alist)
+MARK_VISIBLE (gcry_sexp_append)
+MARK_VISIBLE (gcry_sexp_build)
+MARK_VISIBLE (gcry_sexp_build_array)
+MARK_VISIBLE (gcry_sexp_cadr)
+MARK_VISIBLE (gcry_sexp_canon_len)
+MARK_VISIBLE (gcry_sexp_car)
+MARK_VISIBLE (gcry_sexp_cdr)
+MARK_VISIBLE (gcry_sexp_cons)
+MARK_VISIBLE (gcry_sexp_create)
+MARK_VISIBLE (gcry_sexp_dump)
+MARK_VISIBLE (gcry_sexp_find_token)
+MARK_VISIBLE (gcry_sexp_length)
+MARK_VISIBLE (gcry_sexp_new)
+MARK_VISIBLE (gcry_sexp_nth)
+MARK_VISIBLE (gcry_sexp_nth_data)
+MARK_VISIBLE (gcry_sexp_nth_mpi)
+MARK_VISIBLE (gcry_sexp_prepend)
+MARK_VISIBLE (gcry_sexp_release)
+MARK_VISIBLE (gcry_sexp_sprint)
+MARK_VISIBLE (gcry_sexp_sscan)
+MARK_VISIBLE (gcry_sexp_vlist)
+MARK_VISIBLE (gcry_sexp_nth_string)
+
+MARK_VISIBLE (gcry_mpi_add)
+MARK_VISIBLE (gcry_mpi_add_ui)
+MARK_VISIBLE (gcry_mpi_addm)
+MARK_VISIBLE (gcry_mpi_aprint)
+MARK_VISIBLE (gcry_mpi_clear_bit)
+MARK_VISIBLE (gcry_mpi_clear_flag)
+MARK_VISIBLE (gcry_mpi_clear_highbit)
+MARK_VISIBLE (gcry_mpi_cmp)
+MARK_VISIBLE (gcry_mpi_cmp_ui)
+MARK_VISIBLE (gcry_mpi_copy)
+MARK_VISIBLE (gcry_mpi_div)
+MARK_VISIBLE (gcry_mpi_dump)
+MARK_VISIBLE (gcry_mpi_gcd)
+MARK_VISIBLE (gcry_mpi_get_flag)
+MARK_VISIBLE (gcry_mpi_get_nbits)
+MARK_VISIBLE (gcry_mpi_get_opaque)
+MARK_VISIBLE (gcry_mpi_invm)
+MARK_VISIBLE (gcry_mpi_mod)
+MARK_VISIBLE (gcry_mpi_mul)
+MARK_VISIBLE (gcry_mpi_mul_2exp)
+MARK_VISIBLE (gcry_mpi_mul_ui)
+MARK_VISIBLE (gcry_mpi_mulm)
+MARK_VISIBLE (gcry_mpi_new)
+MARK_VISIBLE (gcry_mpi_powm)
+MARK_VISIBLE (gcry_mpi_print)
+MARK_VISIBLE (gcry_mpi_randomize)
+MARK_VISIBLE (gcry_mpi_release)
+MARK_VISIBLE (gcry_mpi_rshift)
+MARK_VISIBLE (gcry_mpi_scan)
+MARK_VISIBLE (gcry_mpi_set)
+MARK_VISIBLE (gcry_mpi_set_bit)
+MARK_VISIBLE (gcry_mpi_set_flag)
+MARK_VISIBLE (gcry_mpi_set_highbit)
+MARK_VISIBLE (gcry_mpi_set_opaque)
+MARK_VISIBLE (gcry_mpi_set_ui)
+MARK_VISIBLE (gcry_mpi_snew)
+MARK_VISIBLE (gcry_mpi_sub)
+MARK_VISIBLE (gcry_mpi_sub_ui)
+MARK_VISIBLE (gcry_mpi_subm)
+MARK_VISIBLE (gcry_mpi_swap)
+MARK_VISIBLE (gcry_mpi_test_bit)
+
+MARK_VISIBLE (gcry_cipher_register)
+MARK_VISIBLE (gcry_cipher_unregister)
+MARK_VISIBLE (gcry_pk_register)
+MARK_VISIBLE (gcry_pk_unregister)
+MARK_VISIBLE (gcry_md_register)
+MARK_VISIBLE (gcry_md_unregister)
+
+
+
+#undef MARK_VISIBLE
+#endif /*_GCRY_INCLUDED_BY_VISIBILITY_C*/
+
+#endif /*GCRY_VISIBILITY_H*/
diff --git a/tests/ChangeLog b/tests/ChangeLog
index d3b9049e..928bb0a6 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2007-10-31 Werner Koch <wk@g10code.com>
+
+ * benchmark.c (start_timer, stop_timer, elapsed_time) [W32]: Fixed.
+
2007-06-20 Werner Koch <wk@g10code.com>
* benchmark.c (rsa_bench): New.
diff --git a/tests/benchmark.c b/tests/benchmark.c
index 3c0d5fa4..3b2e8f9f 100644
--- a/tests/benchmark.c
+++ b/tests/benchmark.c
@@ -25,7 +25,9 @@
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
-#ifndef _WIN32
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <sys/times.h>
#endif
#include <gcrypt.h>
@@ -226,8 +228,13 @@ static const char sample_public_dsa_key_3072[] =
/* Helper for the start and stop timer. */
+#ifdef _WIN32
+struct {
+ FILETIME creation_time, exit_time, kernel_time, user_time;
+} started_at, stopped_at;
+#else
static clock_t started_at, stopped_at;
-
+#endif
static void
die (const char *format, ...)
@@ -263,7 +270,10 @@ static void
start_timer (void)
{
#ifdef _WIN32
- started_at = stopped_at = clock ();
+ GetProcessTimes (GetCurrentProcess (),
+ &started_at.creation_time, &started_at.exit_time,
+ &started_at.kernel_time, &started_at.user_time);
+ stopped_at = started_at;
#else
struct tms tmp;
@@ -276,7 +286,9 @@ static void
stop_timer (void)
{
#ifdef _WIN32
- stopped_at = clock ();
+ GetProcessTimes (GetCurrentProcess (),
+ &stopped_at.creation_time, &stopped_at.exit_time,
+ &stopped_at.kernel_time, &stopped_at.user_time);
#else
struct tms tmp;
@@ -289,9 +301,23 @@ static const char *
elapsed_time (void)
{
static char buf[50];
-
- sprintf (buf, "%5.0fms",
- (((double) (stopped_at - started_at))/CLOCKS_PER_SEC)*10000000);
+#if _WIN32
+ unsigned long long t1, t2, t;
+
+ t1 = (((unsigned long long)started_at.kernel_time.dwHighDateTime << 32)
+ + started_at.kernel_time.dwLowDateTime);
+ t1 += (((unsigned long long)started_at.user_time.dwHighDateTime << 32)
+ + started_at.user_time.dwLowDateTime);
+ t2 = (((unsigned long long)stopped_at.kernel_time.dwHighDateTime << 32)
+ + stopped_at.kernel_time.dwLowDateTime);
+ t2 += (((unsigned long long)stopped_at.user_time.dwHighDateTime << 32)
+ + stopped_at.user_time.dwLowDateTime);
+ t = (t2 - t1)/10000;
+ snprintf (buf, sizeof buf, "%5lums", (unsigned long)t );
+#else
+ snprintf (buf, sizeof buf, "%5.0fms",
+ (((double) (stopped_at - started_at))/CLOCKS_PER_SEC)*10000000);
+#endif
return buf;
}
@@ -423,11 +449,11 @@ cipher_bench ( const char *algoname )
if (!header_printed)
{
- printf ("%-10s", "");
+ printf ("%-12s", "");
for (modeidx=0; modes[modeidx].mode; modeidx++)
printf (" %-15s", modes[modeidx].name );
putchar ('\n');
- printf ("%-10s", "");
+ printf ("%-12s", "");
for (modeidx=0; modes[modeidx].mode; modeidx++)
printf (" ---------------" );
putchar ('\n');
@@ -465,7 +491,7 @@ cipher_bench ( const char *algoname )
exit (1);
}
- printf ("%-10s", gcry_cipher_algo_name (algo));
+ printf ("%-12s", gcry_cipher_algo_name (algo));
fflush (stdout);
for (modeidx=0; modes[modeidx].mode; modeidx++)
@@ -558,8 +584,8 @@ rsa_bench (int iterations, int print_header)
int testno;
if (print_header)
- printf ("Algorithm generate %4d*sign %4d*verify\n"
- "----------------------------------------------\n",
+ printf ("Algorithm generate %4d*sign %4d*verify\n"
+ "------------------------------------------------\n",
iterations, iterations );
for (testno=0; testno < DIM (p_sizes); testno++)
{
@@ -569,7 +595,7 @@ rsa_bench (int iterations, int print_header)
gcry_sexp_t sig = NULL;
int count;
- printf ("RSA %3d bit ", p_sizes[testno]);
+ printf ("RSA %3d bit ", p_sizes[testno]);
fflush (stdout);
err = gcry_sexp_build (&key_spec, NULL,
@@ -677,8 +703,8 @@ dsa_bench (int iterations, int print_header)
}
if (print_header)
- printf ("Algorithm generate %4d*sign %4d*verify\n"
- "----------------------------------------------\n",
+ printf ("Algorithm generate %4d*sign %4d*verify\n"
+ "------------------------------------------------\n",
iterations, iterations );
for (i=0; i < DIM (q_sizes); i++)
{
@@ -695,7 +721,7 @@ dsa_bench (int iterations, int print_header)
exit (1);
}
- printf ("DSA %d/%d -", p_sizes[i], q_sizes[i]);
+ printf ("DSA %d/%d -", p_sizes[i], q_sizes[i]);
fflush (stdout);
start_timer ();
@@ -752,8 +778,8 @@ ecc_bench (int iterations, int print_header)
int testno;
if (print_header)
- printf ("Algorithm generate %4d*sign %4d*verify\n"
- "----------------------------------------------\n",
+ printf ("Algorithm generate %4d*sign %4d*verify\n"
+ "------------------------------------------------\n",
iterations, iterations );
for (testno=0; testno < DIM (p_sizes); testno++)
{
@@ -787,7 +813,7 @@ ecc_bench (int iterations, int print_header)
gcry_sexp_release (key_spec);
stop_timer ();
- printf (" %s", elapsed_time ());
+ printf (" %s", elapsed_time ());
fflush (stdout);
x = gcry_mpi_new (p_sizes[testno]);
@@ -926,7 +952,8 @@ main( int argc, char **argv )
putchar ('\n');
cipher_bench (NULL);
putchar ('\n');
- dsa_bench (100, 1);
+ rsa_bench (100, 1);
+ dsa_bench (100, 0);
ecc_bench (100, 0);
putchar ('\n');
mpi_bench ();