summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-12-08 12:20:46 +0000
committerWerner Koch <wk@gnupg.org>1998-12-08 12:20:46 +0000
commit8eaa4dbe47feeda8e128405804f99024bc068634 (patch)
tree03a2963e75b365b3f991a88331b52a97cbee0932
parent0b9ccc4150f5f6c5310267f54649612b905487b2 (diff)
downloadlibgcrypt-8eaa4dbe47feeda8e128405804f99024bc068634.tar.gz
See ChangeLog: Tue Dec 8 13:15:16 CET 1998 Werner Koch
-rw-r--r--THANKS3
-rw-r--r--configure.in1
-rw-r--r--mpi/ChangeLog5
-rw-r--r--mpi/config.links12
-rw-r--r--mpi/mpiutil.c4
-rw-r--r--mpi/powerpc32/mpih-add1.S6
-rw-r--r--mpi/powerpc32/mpih-lshift.S4
-rw-r--r--mpi/powerpc32/mpih-mul1.S4
-rw-r--r--mpi/powerpc32/mpih-mul2.S4
-rw-r--r--mpi/powerpc32/mpih-mul3.S4
-rw-r--r--mpi/powerpc32/mpih-rshift.S4
-rw-r--r--mpi/powerpc32/mpih-sub1.S6
-rw-r--r--mpi/powerpc32/syntax.h22
-rw-r--r--src/ChangeLog5
-rw-r--r--src/gcrypt.h220
-rw-r--r--src/mpiapi.c69
16 files changed, 337 insertions, 36 deletions
diff --git a/THANKS b/THANKS
index e80e278b..4631aca7 100644
--- a/THANKS
+++ b/THANKS
@@ -1,4 +1,4 @@
-GNUPG was originally written by Werner Koch. Other people contributed by
+GnuPG was originally written by Werner Koch. Other people contributed by
reporting problems, suggesting various improvements or submitting actual
code. Here is a list of those people. Help me keep it complete and free of
errors.
@@ -24,6 +24,7 @@ Frank Heckenbach heckenb@mi.uni-erlangen.de
Gaël Quéri gqueri@mail.dotcom.fr
Greg Louis glouis@dynamicro.on.ca
Gregory Steuck steuck@iname.com
+Geoff Keating geoffk@ozemail.com.au
Hendrik Buschkamp buschkamp@rheumanet.org
Holger Schurig holger@d.om.org
Hugh Daniel hugh@toad.com
diff --git a/configure.in b/configure.in
index 26a3ed6a..8a7cb12e 100644
--- a/configure.in
+++ b/configure.in
@@ -300,3 +300,4 @@ zlib/Makefile
checks/Makefile
])
+dnl *-*wedit:notab*-* Please keep this as the last line.
diff --git a/mpi/ChangeLog b/mpi/ChangeLog
index c5e67c47..2b0d99ec 100644
--- a/mpi/ChangeLog
+++ b/mpi/ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * config.links: Moved the case for powerpc*linux
+ * powerpcp32/*.S: Removed some underscores.
+
Thu Nov 26 07:27:52 1998 Werner Koch <werner.koch@guug.de>
* config.links: Support for ppc with ELF
diff --git a/mpi/config.links b/mpi/config.links
index 5de21ef5..7e3e865f 100644
--- a/mpi/config.links
+++ b/mpi/config.links
@@ -124,6 +124,12 @@ case "${target}" in
path="m68k/mc68020 m68k"
;;
+ powerpc*-*-linux*)
+ echo '/* configured for powerpc/ELF */' >>./mpi/asm-syntax.h
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h
+ path="powerpc32"
+ ;;
rs6000-*-aix[456789]* | rs6000-*-aix3.2.[456789])
mpi_sflags="-Wa,-mpwr"
path="power"
@@ -146,12 +152,6 @@ case "${target}" in
mpi_sflags="-Wa,-mppc"
path="powerpc64"
;;
- powerpc*-*-linux*)
- echo '/* configured for powerpc/ELF */' >>./mpi/asm-syntax.h
- echo '#define ELF_SYNTAX' >>asm-syntax.h
- cat $srcdir/powerpc32/syntax.h >>./mpi/asm-syntax.h
- path="powerpc32"
- ;;
*)
echo '/* No assembler modules configured */' >>./mpi/asm-syntax.h
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index a94cbb49..18af9e04 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -1,4 +1,4 @@
-/* mpiutilac - Utility functions for MPI
+/* mpiutil.ac - Utility functions for MPI
* Copyright (C) 1998 Free Software Foundation, Inc.
*
* This file is part of GNUPG.
@@ -367,7 +367,7 @@ mpi_alloc_set_ui( unsigned long u)
void
mpi_swap( MPI a, MPI b)
{
- struct mpi_struct tmp;
+ struct gcry_mpi tmp;
tmp = *a; *a = *b; *b = tmp;
}
diff --git a/mpi/powerpc32/mpih-add1.S b/mpi/powerpc32/mpih-add1.S
index bbc51315..a26de52a 100644
--- a/mpi/powerpc32/mpih-add1.S
+++ b/mpi/powerpc32/mpih-add1.S
@@ -48,7 +48,7 @@ mpihelp_add_n:
mtctr 6 # copy size into CTR
lwz 8,0(4) # load least significant s1 limb
lwz 0,0(5) # load least significant s2 limb
- addi 3,3,-4 # offset res_ptr, it's updated before used
+ addi 3,3,-4 # offset res_ptr, it is updated before used
addc 7,0,8 # add least significant limbs, set cy
bdz Lend # If done, skip loop
Loop: lwzu 8,4(4) # load s1 limb and update s1_ptr
@@ -93,7 +93,7 @@ Lend: stw 7,4(3) # store ultimate result limb
possible 2-unrolled inner loop will not be. Also, watch out for the
alignment... */
-EALIGN(_mpihelp_add_n,3,0)
+EALIGN(mpihelp_add_n,3,0)
/* Set up for loop below. */
mtcrf 0x01,%r6
srwi. %r7,%r6,1
@@ -131,6 +131,6 @@ EALIGN(_mpihelp_add_n,3,0)
/* Return the carry. */
1: addze %r3,%r10
blr
-END(_mpihelp_add_n)
+END(mpihelp_add_n)
#endif
diff --git a/mpi/powerpc32/mpih-lshift.S b/mpi/powerpc32/mpih-lshift.S
index d85fe211..683f799b 100644
--- a/mpi/powerpc32/mpih-lshift.S
+++ b/mpi/powerpc32/mpih-lshift.S
@@ -96,7 +96,7 @@ Lend2: slw 0,10,6
/* mp_limb_t mpn_lshift (mp_ptr wp, mp_srcptr up, mp_size_t usize,
unsigned int cnt) */
-EALIGN(_mpihelp_lshift,3,0)
+EALIGN(mpihelp_lshift,3,0)
mtctr %r5 # copy size into CTR
cmplwi %cr0,%r5,16 # is size < 16
slwi %r0,%r5,2
@@ -194,5 +194,5 @@ L(end2):slw %r0,%r10,%r6
DO_LSHIFT(30)
DO_LSHIFT(31)
-END(_mpihelp_lshift)
+END(mpihelp_lshift)
#endif
diff --git a/mpi/powerpc32/mpih-mul1.S b/mpi/powerpc32/mpih-mul1.S
index 35f94b1f..24193adb 100644
--- a/mpi/powerpc32/mpih-mul1.S
+++ b/mpi/powerpc32/mpih-mul1.S
@@ -95,7 +95,7 @@ Lend: stw 7,4(3)
mp_size_t s1_size, mp_limb_t s2_limb)
Calculate s1*s2 and put result in res_ptr; return carry. */
-ENTRY(_mpihelp_mul_1)
+ENTRY(mpihelp_mul_1)
mtctr %r5
lwz %r0,0(%r4)
@@ -115,5 +115,5 @@ ENTRY(_mpihelp_mul_1)
1: stw %r7,4(%r3)
addze %r3,%r10
blr
-END(_mpihelp_mul_1)
+END(mpihelp_mul_1)
#endif
diff --git a/mpi/powerpc32/mpih-mul2.S b/mpi/powerpc32/mpih-mul2.S
index 9577c282..185fed90 100644
--- a/mpi/powerpc32/mpih-mul2.S
+++ b/mpi/powerpc32/mpih-mul2.S
@@ -99,7 +99,7 @@ Lend: stw 8,4(3)
/* mp_limb_t mpn_addmul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr,
mp_size_t s1_size, mp_limb_t s2_limb)
Calculate res+s1*s2 and put result back in res; return carry. */
-ENTRY(_mpihelp_addmul_1)
+ENTRY(mpihelp_addmul_1)
mtctr %r5
lwz %r0,0(%r4)
@@ -123,5 +123,5 @@ ENTRY(_mpihelp_addmul_1)
1: stw %r8,4(%r3)
addze %r3,%r10
blr
-END(_mpihelp_addmul_1)
+END(mpihelp_addmul_1)
#endif
diff --git a/mpi/powerpc32/mpih-mul3.S b/mpi/powerpc32/mpih-mul3.S
index a4a4d163..e6b7cf5c 100644
--- a/mpi/powerpc32/mpih-mul3.S
+++ b/mpi/powerpc32/mpih-mul3.S
@@ -100,7 +100,7 @@ Lend: stw 8,4(3)
mp_size_t s1_size, mp_limb_t s2_limb)
Calculate res-s1*s2 and put result back in res; return carry. */
-ENTRY(_mpihelp_submul_1)
+ENTRY(mpihelp_submul_1)
mtctr %r5
lwz %r0,0(%r4)
@@ -126,5 +126,5 @@ ENTRY(_mpihelp_submul_1)
1: stw %r8,4(%r3)
addze %r3,%r10
blr
-END(_mpihelp_submul_1)
+END(mpihelp_submul_1)
#endif
diff --git a/mpi/powerpc32/mpih-rshift.S b/mpi/powerpc32/mpih-rshift.S
index 0dc54f26..78732b9e 100644
--- a/mpi/powerpc32/mpih-rshift.S
+++ b/mpi/powerpc32/mpih-rshift.S
@@ -99,7 +99,7 @@ Lend2: srw 0,10,6
size r5
cnt r6 */
-ENTRY(_mpihelp_rshift)
+ENTRY(mpihelp_rshift)
mtctr 5 # copy size into CTR
addi 7,3,-4 # move adjusted res_ptr to free return reg
subfic 8,6,32
@@ -127,5 +127,5 @@ ENTRY(_mpihelp_rshift)
2: srw 0,10,6
stw 0,4(7)
blr
-END(_mpihelp_rshift)
+END(mpihelp_rshift)
#endif
diff --git a/mpi/powerpc32/mpih-sub1.S b/mpi/powerpc32/mpih-sub1.S
index 1387650b..cb87cc70 100644
--- a/mpi/powerpc32/mpih-sub1.S
+++ b/mpi/powerpc32/mpih-sub1.S
@@ -49,7 +49,7 @@ mpihelp_sub_n:
mtctr 6 # copy size into CTR
lwz 8,0(4) # load least significant s1 limb
lwz 0,0(5) # load least significant s2 limb
- addi 3,3,-4 # offset res_ptr, it's updated before used
+ addi 3,3,-4 # offset res_ptr, it is updated before used
subfc 7,0,8 # add least significant limbs, set cy
bdz Lend # If done, skip loop
Loop: lwzu 8,4(4) # load s1 limb and update s1_ptr
@@ -90,7 +90,7 @@ Lend: stw 7,4(3) # store ultimate result limb
possible 2-unrolled inner loop will not be. Also, watch out for the
alignment... */
-EALIGN(_mpihelp_sub_n,3,1)
+EALIGN(mpihelp_sub_n,3,1)
/* Set up for loop below. */
mtcrf 0x01,%r6
srwi. %r7,%r6,1
@@ -128,5 +128,5 @@ EALIGN(_mpihelp_sub_n,3,1)
1: subfe %r3,%r3,%r3
neg %r3,%r3
blr
-END(_mpihelp_sub_n)
+END(mpihelp_sub_n)
#endif
diff --git a/mpi/powerpc32/syntax.h b/mpi/powerpc32/syntax.h
index 6abb9ebb..19f79727 100644
--- a/mpi/powerpc32/syntax.h
+++ b/mpi/powerpc32/syntax.h
@@ -44,11 +44,11 @@
/* No profiling of gmp's assembly for now... */
#define CALL_MCOUNT /* no profiling */
-#define ENTRY(name) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
- ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
- .align ALIGNARG(2); \
- C_LABEL(name) \
+#define ENTRY(name) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
CALL_MCOUNT
#define EALIGN_W_0 /* No words to insert. */
@@ -62,14 +62,14 @@
/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
past a 2^align boundary. */
-#define EALIGN(name, alignt, words) \
- ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
- ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
- .align ALIGNARG(alignt); \
- EALIGN_W_##words; \
+#define EALIGN(name, alignt, words) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
C_LABEL(name)
#undef END
-#define END(name) \
+#define END(name) \
ASM_SIZE_DIRECTIVE(name)
diff --git a/src/ChangeLog b/src/ChangeLog
new file mode 100644
index 00000000..ee0f83d2
--- /dev/null
+++ b/src/ChangeLog
@@ -0,0 +1,5 @@
+Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * gcrypt.h: New
+ * mpiapi.c: New
+
diff --git a/src/gcrypt.h b/src/gcrypt.h
new file mode 100644
index 00000000..53106271
--- /dev/null
+++ b/src/gcrypt.h
@@ -0,0 +1,220 @@
+/* gcrypt.h - GNU digital encryption libray interface
+ * Copyright (C) 1998 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#ifndef _GCRYPT_H
+#define _GCRYPT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*******************************************
+ * *
+ * error handling *
+ * *
+ *******************************************/
+
+enum gcry_error {
+ GCRYERR_SUCCESS = 0,
+ GCRYERR_INV_OP = 1, /* inavlid operation code */
+ GCRYERR_GENERAL = 2
+};
+
+/*******************************************
+ * *
+ * multi precision integer functions *
+ * *
+ *******************************************/
+
+enum gcry_mpi_opcode {
+ GCRYMPI_NOOP = 0,
+ GCRYMPI_NEW = 1, /* use gcry_mpi_new() */
+ GCRYMPI_SNEW = 2, /* use gcry_mpi_new() */
+ GCRYMPI_RELEASE = 3,
+ GCRYMPI_RESIZE = 4,
+ GCRYMPI_COPY = 5, /* use gcry_mpi_new() */
+ GCRYMPI_SWAP = 6,
+ GCRYMPI_SET = 7,
+ GCRYMPI_SET_UI = 8,
+ GCRYMPI_CMP = 9,
+ GCRYMPI_CMP_UI = 10
+};
+
+struct gcry_mpi;
+
+int gcry_mpi_api( enum gcry_mpi_opcode opcode, int n_args, ... );
+struct gcry_mpi *gcry_mpi_new( enum gcry_mpi_opcode opcode,
+ unsigned int size,
+ struct gcry_mpi *val
+ );
+
+#ifndef GCRYPT_NO_MPI_MACROS
+#define mpi_new( nbits ) gcry_mpi_new( GCRYMPI_NEW, (nbits), NULL )
+#define mpi_secure_new( nbits ) gcry_mpi_new( GCRYMPI_SNEW, (nbits), NULL )
+#define mpi_release( a ) do { gcry_mpi_api( GCRYMPI_RELEASE, 1, (a) );
+ (a) = NULL; } while(0)
+#define mpi_resize( a, n ) gcry_mpi_api( GCRYMPI_RESIZE, 2, (a), (n) )
+#define mpi_copy( a ) gcry_mpi_new( GCRYMPI_COPY, 0, (a) )
+#define mpi_swap( a, b ) gcyr_mpi_api( GCRYMPI_SWAP, 2, (a), (b) )
+/* void mpi_set( MPI w, MPI u ); */
+#define mpi_set( w, u) gcry_mpi_api( GCRYMPI_SET, 2, (w), (u) )
+/* void mpi_set_ui( MPI w, unsigned long u ); */
+#define mpi_set_ui( w, u) gcry_mpi_api( GCRYMPI_SET_UI, 2, (w), (u) )
+/* int mpi_cmp( MPI u, MPI v ); */
+#define mpi_cmp( u, v ) gcry_mpi_api( GCRYMPI_CMP, 2, (u), (v) )
+/* int mpi_cmp_ui( MPI u, unsigned long v ); */
+#define mpi_cmp_ui( u, v ) gcry_mpi_api( GCRYMPI_CMP_UI, 2, (u), (v) )
+
+
+void g10m_add(MPI w, MPI u, MPI v);
+void g10m_add_ui(MPI w, MPI u, unsigned long v );
+void g10m_sub( MPI w, MPI u, MPI v);
+void g10m_sub_ui(MPI w, MPI u, unsigned long v );
+
+void g10m_mul_ui(MPI w, MPI u, unsigned long v );
+void g10m_mul_2exp( MPI w, MPI u, unsigned long cnt);
+void g10m_mul( MPI w, MPI u, MPI v);
+void g10m_mulm( MPI w, MPI u, MPI v, MPI m);
+
+void g10m_fdiv_q( MPI quot, MPI dividend, MPI divisor );
+
+void g10m_powm( MPI res, MPI base, MPI exp, MPI mod);
+
+int g10m_gcd( MPI g, MPI a, MPI b );
+int g10m_invm( MPI x, MPI u, MPI v );
+
+unsigned g10m_get_nbits( MPI a );
+unsigned g10m_get_size( MPI a );
+
+void g10m_set_buffer( MPI a, const char *buffer, unsigned nbytes, int sign );
+
+
+#endif /* GCRYPT_NO_MPI_MACROS */
+
+/********************************************
+ ******* symmetric cipher functions *******
+ ********************************************/
+
+
+
+/*********************************************
+ ******* asymmetric cipher functions *******
+ *********************************************/
+
+
+
+
+/*********************************************
+ ******* cryptograhic hash functions *******
+ *********************************************/
+
+
+/*****************************************
+ ******* miscellaneous functions *******
+ *****************************************/
+
+#if 0
+const char *g10m_revision_string(int mode);
+const char *g10c_revision_string(int mode);
+const char *g10u_revision_string(int mode);
+
+MPI g10c_generate_secret_prime( unsigned nbits );
+char *g10c_get_random_bits( unsigned nbits, int level, int secure );
+
+
+void *g10_malloc( size_t n );
+void *g10_calloc( size_t n );
+void *g10_malloc_secure( size_t n );
+void *g10_calloc_secure( size_t n );
+void *g10_realloc( void *a, size_t n );
+void g10_free( void *p );
+char *g10_strdup( const char * a);
+
+void g10_log_bug( const char *fmt, ... );
+void g10_log_bug0( const char *, int );
+void g10_log_fatal( const char *fmt, ... );
+void g10_log_error( const char *fmt, ... );
+void g10_log_info( const char *fmt, ... );
+void g10_log_debug( const char *fmt, ... );
+void g10_log_hexdump( const char *text, char *buf, size_t len );
+void g10_log_mpidump( const char *text, MPI a );
+#endif
+
+/***************************
+ ******* constants *******
+ **************************/
+#if 0
+#define CIPHER_ALGO_NONE 0
+#define CIPHER_ALGO_IDEA 1
+#define CIPHER_ALGO_3DES 2
+#define CIPHER_ALGO_CAST5 3
+#define CIPHER_ALGO_BLOWFISH 4 /* blowfish 128 bit key */
+#define CIPHER_ALGO_SAFER_SK128 5
+#define CIPHER_ALGO_DES_SK 6
+#define CIPHER_ALGO_BLOWFISH160 42 /* blowfish 160 bit key (not in OpenPGP)*/
+#define CIPHER_ALGO_DUMMY 110 /* no encryption at all */
+
+#define PUBKEY_ALGO_RSA 1
+#define PUBKEY_ALGO_RSA_E 2 /* RSA encrypt only */
+#define PUBKEY_ALGO_RSA_S 3 /* RSA sign only */
+#define PUBKEY_ALGO_ELGAMAL_E 16 /* encrypt only ElGamal (but not vor v3)*/
+#define PUBKEY_ALGO_DSA 17
+#define PUBKEY_ALGO_ELGAMAL 20 /* sign and encrypt elgamal */
+
+#define DIGEST_ALGO_MD5 1
+#define DIGEST_ALGO_SHA1 2
+#define DIGEST_ALGO_RMD160 3
+#define DIGEST_ALGO_TIGER 6
+
+#define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
+ || (a)==PUBKEY_ALGO_RSA_S )
+#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL || (a)==PUBKEY_ALGO_ELGAMAL_E)
+
+#define G10ERR_GENERAL 1
+#define G10ERR_PUBKEY_ALGO 4
+#define G10ERR_DIGEST_ALGO 5
+#define G10ERR_BAD_PUBKEY 6
+#define G10ERR_BAD_SECKEY 7
+#define G10ERR_BAD_SIGN 8
+#define G10ERR_CIPHER_ALGO 12
+#define G10ERR_WRONG_SECKEY 18
+#define G10ERR_UNSUPPORTED 19
+#define G10ERR_NI_PUBKEY 27
+#define G10ERR_NI_CIPHER 28
+#define G10ERR_BAD_MPI 30
+#define G10ERR_WR_PUBKEY_ALGO 41
+#endif
+
+/***********************************************
+ * *
+ * Some very handy macros *
+ * *
+ ***********************************************/
+#ifndef GCRYPT_NO_MPI_MACROS
+
+typedef struct gcry_mpi *MPI;
+
+
+#endif /* GCRYPT_NO_MPI_MACROS */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _GCRYPT_H */
diff --git a/src/mpiapi.c b/src/mpiapi.c
new file mode 100644
index 00000000..974e5dbb
--- /dev/null
+++ b/src/mpiapi.c
@@ -0,0 +1,69 @@
+/* mpiapi.ac - MPI function interface
+ * Copyright (C) 1998 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#ifdef _GCRYPT_H
+ #error gcrypt.h already in libc
+#endif
+
+#define GCRYPT_NO_MPI_MACROS 1
+#include "gcrypt.h"
+#include "mpi.h"
+
+
+
+int
+gcry_mpi_api( enum gcry_mpi_opcode opcode, int n_args, ... )
+{
+ switch( opcode ) {
+ case GCRYMPI_NOOP:
+ return 0;
+
+ default:
+ return GCRYERR_INV_OP;
+ }
+}
+
+
+struct gcry_mpi *
+gcry_mpi_new( enum gcry_mpi_opcode opcode,
+ unsigned int nbits, struct gcry_mpi *val)
+{
+ switch( opcode ) {
+ case GCRYMPI_NEW:
+ return mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB );
+
+ case GCRYMPI_SNEW:
+ return mpi_alloc_secure( (nbits+BITS_PER_MPI_LIMB-1)
+ / BITS_PER_MPI_LIMB );
+ case GCRYMPI_COPY:
+ return mpi_copy( val );
+
+ default:
+ return NULL;
+ }
+}
+