diff options
author | Werner Koch <wk@gnupg.org> | 2007-10-31 10:48:01 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2007-10-31 10:48:01 +0000 |
commit | 68a0d855c92cb6cd7030abc7e191d1c513ad2a62 (patch) | |
tree | 549e9edd57faa05b22fa15392ba051c098fc2c4e /mpi | |
parent | f9c80d236b62c5f2ac4c4d096e4adbd40b10d3a2 (diff) | |
download | libgcrypt-68a0d855c92cb6cd7030abc7e191d1c513ad2a62.tar.gz |
Reorganizatiosn to support the visibility attribute.
This can be improved by using fucntion aliases instead
of wrapper functions.
Diffstat (limited to 'mpi')
-rw-r--r-- | mpi/ChangeLog | 13 | ||||
-rw-r--r-- | mpi/mpi-inv.c | 16 | ||||
-rw-r--r-- | mpi/mpi-mod.c | 8 | ||||
-rw-r--r-- | mpi/mpi-mul.c | 9 | ||||
-rw-r--r-- | mpi/mpiutil.c | 112 |
5 files changed, 54 insertions, 104 deletions
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 ) |