aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog9
-rw-r--r--include/cipher.h77
-rw-r--r--include/mpi.h181
-rw-r--r--include/util.h74
4 files changed, 14 insertions, 327 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index f118fb32d..ed7e47992 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,12 @@
+Wed Dec 8 21:58:32 CET 1999 Werner Koch <[email protected]>
+
+ * util.h: Moved argparse stuff to the argparse header. Move some
+ of the string stuff to the stringhelp header.
+
+ * mpi.h: Moved to ../gcrypt
+ * cipher.h: Moved to ../gcrypt
+ * g10lib.h: Moved to ../gcrypt
+
Tue Oct 26 14:10:21 CEST 1999 Werner Koch <[email protected]>
* g10lib.h: Moved from ../gcrypt to here.
diff --git a/include/cipher.h b/include/cipher.h
deleted file mode 100644
index aaab08d55..000000000
--- a/include/cipher.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* cipher.h
- * 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 G10_CIPHER_H
-#define G10_CIPHER_H
-
-#define DBG_CIPHER g10c_debug_mode
-
-#include "mpi.h"
-#include "../cipher/random.h"
-
-
-#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_TWOFISH 10 /* twofish 256 bit */
-#define CIPHER_ALGO_SKIPJACK 101 /* experimental: skipjack */
-#define CIPHER_ALGO_TWOFISH_OLD 102 /* experimental: twofish 128 bit */
-#define CIPHER_ALGO_DUMMY 110 /* no encryption at all */
-
-#define PUBKEY_ALGO_RSA 1
-#define PUBKEY_ALGO_RSA_E 2 /* RSA encrypt only */
-#define PUBKEY_ALGO_RSA_S 3 /* RSA sign only */
-#define PUBKEY_ALGO_ELGAMAL_E 16 /* encrypt only ElGamal (but not for v3)*/
-#define PUBKEY_ALGO_DSA 17
-#define PUBKEY_ALGO_ELGAMAL 20 /* sign and encrypt elgamal */
-
-#if 0
-#define PUBKEY_USAGE_SIG 1 /* key is good for signatures */
-#define PUBKEY_USAGE_ENC 2 /* key is good for encryption */
-#endif
-
-#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)
-
-int g10c_debug_mode;
-int g10_opt_verbose;
-const char *g10_opt_homedir;
-
-/*-- dynload.c --*/
-void register_cipher_extension( const char *mainpgm, const char *fname );
-
-/*-- rmd160.c --*/
-void rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length );
-
-
-/*-- smallprime.c --*/
-extern ushort small_prime_numbers[];
-
-
-#endif /*G10_CIPHER_H*/
diff --git a/include/mpi.h b/include/mpi.h
deleted file mode 100644
index dca6426da..000000000
--- a/include/mpi.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* mpi.h - Multi Precision Integers
- * Copyright (C) 1994, 1996, 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
- *
- * Note: This code is heavily based on the GNU MP Library.
- * Actually it's the same code with only minor changes in the
- * way the data is stored; this is to support the abstraction
- * of an optional secure memory allocation which may be used
- * to avoid revealing of sensitive data due to paging etc.
- * The GNU MP Library itself is published under the LGPL;
- * however I decided to publish this code under the plain GPL.
- */
-
-#ifndef G10_MPI_H
-#define G10_MPI_H
-
-#include <stdio.h>
-#include "iobuf.h"
-#include "types.h"
-#include "memory.h"
-
-
-#define DBG_MPI mpi_debug_mode
-int mpi_debug_mode;
-
-#define BITS_PER_MPI_LIMB (8*SIZEOF_UNSIGNED_LONG)
-#define BYTES_PER_MPI_LIMB SIZEOF_UNSIGNED_LONG
-typedef unsigned long int mpi_limb_t;
-typedef signed long int mpi_limb_signed_t;
-
-struct gcry_mpi {
- int alloced; /* array size (# of allocated limbs) */
- int nlimbs; /* number of valid limbs */
- int nbits; /* the real number of valid bits (info only) */
- int sign; /* indicates a negative number */
- unsigned flags; /* bit 0: array must be allocated in secure memory space */
- /* bit 1: the mpi is encrypted */
- /* bit 2: the limb is a pointer to some m_alloced data */
- mpi_limb_t *d; /* array with the limbs */
-};
-
-#ifndef DID_MPI_TYPEDEF
- typedef struct gcry_mpi *MPI;
- #define DID_MPI_TYPEDEF
-#endif
-
-#define MPI_NULL NULL
-
-#define mpi_get_nlimbs(a) ((a)->nlimbs)
-#define mpi_get_nbit_info(a) ((a)->nbits)
-#define mpi_set_nbit_info(a,b) ((a)->nbits = (b))
-#define mpi_is_neg(a) ((a)->sign)
-
-/*-- mpiutil.c --*/
-
-#ifdef M_DEBUG
- #define mpi_alloc(n) mpi_debug_alloc((n), M_DBGINFO( __LINE__ ) )
- #define mpi_alloc_secure(n) mpi_debug_alloc_secure((n), M_DBGINFO( __LINE__ ) )
- #define mpi_free(a) mpi_debug_free((a), M_DBGINFO(__LINE__) )
- #define mpi_resize(a,b) mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) )
- #define mpi_copy(a) mpi_debug_copy((a), M_DBGINFO(__LINE__) )
- MPI mpi_debug_alloc( unsigned nlimbs, const char *info );
- MPI mpi_debug_alloc_secure( unsigned nlimbs, const char *info );
- void mpi_debug_free( MPI a, const char *info );
- void mpi_debug_resize( MPI a, unsigned nlimbs, const char *info );
- MPI mpi_debug_copy( MPI a, const char *info );
-#else
- MPI mpi_alloc( unsigned nlimbs );
- MPI mpi_alloc_secure( unsigned nlimbs );
- void mpi_free( MPI a );
- void mpi_resize( MPI a, unsigned nlimbs );
- MPI mpi_copy( MPI a );
-#endif
-#define mpi_is_opaque(a) ((a) && ((a)->flags&4))
-MPI mpi_set_opaque( MPI a, void *p, int len );
-void *mpi_get_opaque( MPI a, int *len );
-#define mpi_is_protected(a) ((a) && ((a)->flags&2))
-#define mpi_set_protect_flag(a) ((a)->flags |= 2)
-#define mpi_clear_protect_flag(a) ((a)->flags &= ~2)
-#define mpi_is_secure(a) ((a) && ((a)->flags&1))
-void mpi_set_secure( MPI a );
-void mpi_clear( MPI a );
-MPI mpi_alloc_like( MPI a );
-void mpi_set( MPI w, MPI u);
-void mpi_set_ui( MPI w, ulong u);
-MPI mpi_alloc_set_ui( unsigned long u);
-void mpi_m_check( MPI a );
-void mpi_swap( MPI a, MPI b);
-
-/*-- mpicoder.c --*/
-int mpi_write( IOBUF out, MPI a );
-#ifdef M_DEBUG
- #define mpi_read(a,b,c) mpi_debug_read((a),(b),(c), M_DBGINFO( __LINE__ ) )
- MPI mpi_debug_read(IOBUF inp, unsigned *nread, int secure, const char *info);
-#else
- MPI mpi_read(IOBUF inp, unsigned *nread, int secure);
-#endif
-MPI mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure);
-int mpi_fromstr(MPI val, const char *str);
-int mpi_print( FILE *fp, MPI a, int mode );
-void g10_log_mpidump( const char *text, MPI a );
-u32 mpi_get_keyid( MPI a, u32 *keyid );
-byte *mpi_get_buffer( MPI a, unsigned *nbytes, int *sign );
-byte *mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign );
-void mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign );
-
-#define log_mpidump g10_log_mpidump
-
-/*-- mpi-add.c --*/
-void mpi_add_ui(MPI w, MPI u, ulong v );
-void mpi_add(MPI w, MPI u, MPI v);
-void mpi_addm(MPI w, MPI u, MPI v, MPI m);
-void mpi_sub_ui(MPI w, MPI u, ulong v );
-void mpi_sub( MPI w, MPI u, MPI v);
-void mpi_subm( MPI w, MPI u, MPI v, MPI m);
-
-/*-- mpi-mul.c --*/
-void mpi_mul_ui(MPI w, MPI u, ulong v );
-void mpi_mul_2exp( MPI w, MPI u, ulong cnt);
-void mpi_mul( MPI w, MPI u, MPI v);
-void mpi_mulm( MPI w, MPI u, MPI v, MPI m);
-
-/*-- mpi-div.c --*/
-ulong mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor );
-void mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor );
-void mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor );
-void mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor );
-void mpi_tdiv_r( MPI rem, MPI num, MPI den);
-void mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den);
-void mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count );
-int mpi_divisible_ui(MPI dividend, ulong divisor );
-
-/*-- mpi-gcd.c --*/
-int mpi_gcd( MPI g, MPI a, MPI b );
-
-/*-- mpi-pow.c --*/
-void mpi_pow( MPI w, MPI u, MPI v);
-void mpi_powm( MPI res, MPI base, MPI exp, MPI mod);
-
-/*-- mpi-mpow.c --*/
-void mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI mod);
-
-/*-- mpi-cmp.c --*/
-int mpi_cmp_ui( MPI u, ulong v );
-int mpi_cmp( MPI u, MPI v );
-
-/*-- mpi-scan.c --*/
-int mpi_getbyte( MPI a, unsigned idx );
-void mpi_putbyte( MPI a, unsigned idx, int value );
-unsigned mpi_trailing_zeros( MPI a );
-
-/*-- mpi-bit.c --*/
-void mpi_normalize( MPI a );
-unsigned mpi_get_nbits( MPI a );
-int mpi_test_bit( MPI a, unsigned n );
-void mpi_set_bit( MPI a, unsigned n );
-void mpi_set_highbit( MPI a, unsigned n );
-void mpi_clear_highbit( MPI a, unsigned n );
-void mpi_clear_bit( MPI a, unsigned n );
-void mpi_rshift( MPI x, MPI a, unsigned n );
-
-/*-- mpi-inv.c --*/
-void mpi_invm( MPI x, MPI u, MPI v );
-
-
-#endif /*G10_MPI_H*/
diff --git a/include/util.h b/include/util.h
index cf656f625..190bff6ff 100644
--- a/include/util.h
+++ b/include/util.h
@@ -24,42 +24,13 @@
#error This header should not be used internally by libgcrypt
#endif
+#include <stdio.h>
#include "types.h"
#include "errors.h"
-#include "types.h"
-#include "mpi.h"
-
-
-typedef struct {
- int *argc; /* pointer to argc (value subject to change) */
- char ***argv; /* pointer to argv (value subject to change) */
- unsigned flags; /* Global flags (DO NOT CHANGE) */
- int err; /* print error about last option */
- /* 1 = warning, 2 = abort */
- int r_opt; /* return option */
- int r_type; /* type of return value (0 = no argument found)*/
- union {
- int ret_int;
- long ret_long;
- ulong ret_ulong;
- char *ret_str;
- } r; /* Return values */
- struct {
- int idx;
- int inarg;
- int stopped;
- const char *last;
- void *aliases;
- const void *cur_alias;
- } internal; /* DO NOT CHANGE */
-} ARGPARSE_ARGS;
-
-typedef struct {
- int short_opt;
- const char *long_opt;
- unsigned flags;
- const char *description; /* optional option description */
-} ARGPARSE_OPTS;
+#include "../util/mischelp.h"
+#include "../util/stringhelp.h"
+#include "../util/argparse.h"
+
/*-- logger.c --*/
void log_set_logfile( const char *name, int fd );
@@ -119,14 +90,6 @@ void g10_log_hexdump( const char *text, const char *buf, size_t len );
/*-- errors.c --*/
const char * g10_errstr( int no );
-/*-- argparse.c --*/
-int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
-int optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
- ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
-void usage( int level );
-const char *strusage( int level );
-void set_strusage( const char *(*f)( int ) );
-
/*-- dotlock.c --*/
struct dotlock_handle;
@@ -168,11 +131,6 @@ STRLIST append_to_strlist( STRLIST *list, const char *string );
STRLIST append_to_strlist2( STRLIST *list, const char *string, int is_utf8 );
STRLIST strlist_prev( STRLIST head, STRLIST node );
STRLIST strlist_last( STRLIST node );
-const char *memistr( const char *buf, size_t buflen, const char *sub );
-char *mem2str( char *, const void *, size_t);
-char *trim_spaces( char *string );
-unsigned trim_trailing_chars( byte *line, unsigned len, const char *trimchars);
-unsigned trim_trailing_ws( byte *line, unsigned len );
int string_count_chr( const char *string, int c );
int set_native_charset( const char *newset );
const char* get_native_charset(void);
@@ -180,24 +138,6 @@ char *native_to_utf8( const char *string );
char *utf8_to_native( const char *string, size_t length );
int check_utf8_string( const char *string );
-#ifndef HAVE_MEMICMP
-int memicmp( const char *a, const char *b, size_t n );
-#endif
-#ifndef HAVE_STPCPY
-char *stpcpy(char *a,const char *b);
-#endif
-#ifndef HAVE_STRLWR
-char *strlwr(char *a);
-#endif
-#ifndef HAVE_STRTOUL
- #define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
-#endif
-#ifndef HAVE_MEMMOVE
- #define memmove(d, s, n) bcopy((s), (d), (n))
-#endif
-#ifndef HAVE_STRICMP
- #define stricmp(a,b) strcasecmp( (a), (b) )
-#endif
/**** other missing stuff ****/
#ifndef HAVE_ATEXIT /* For SunOS */
@@ -209,10 +149,6 @@ char *strlwr(char *a);
#endif
/******** some macros ************/
-#ifndef STR
- #define STR(v) #v
-#endif
-#define STR2(v) STR(v)
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
#define DIMof(type,member) DIM(((type *)0)->member)