diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/Makefile.am | 19 | ||||
-rw-r--r-- | src/g10lib.h | 208 | ||||
-rw-r--r-- | src/gcrypt.h | 295 | ||||
-rw-r--r-- | src/global.c | 78 | ||||
-rw-r--r-- | src/mdapi.c | 31 | ||||
-rw-r--r-- | src/misc.c | 50 | ||||
-rw-r--r-- | src/mpiapi.c | 65 | ||||
-rw-r--r-- | src/pkapi.c | 31 | ||||
-rw-r--r-- | src/symapi.c | 144 |
10 files changed, 0 insertions, 926 deletions
diff --git a/src/ChangeLog b/src/ChangeLog deleted file mode 100644 index ee0f83d2..00000000 --- a/src/ChangeLog +++ /dev/null @@ -1,5 +0,0 @@ -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/Makefile.am b/src/Makefile.am deleted file mode 100644 index d8f8beca..00000000 --- a/src/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -## Process this file with automake to produce Makefile.in - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl - -lib_LTLIBRARIES = libgcrypt.la - -libgcrypt_la_LDFLAGS = -version-info 0:0:0 -libgcrypt_la_SOURCES = gcrypt.h \ - g10lib.h \ - misc.c \ - global.c \ - mpiapi.c \ - symapi.c \ - mdapi.c \ - pkapi.c - - - - diff --git a/src/g10lib.h b/src/g10lib.h deleted file mode 100644 index 031dc950..00000000 --- a/src/g10lib.h +++ /dev/null @@ -1,208 +0,0 @@ -/* g10lib.h - internal defintions for libgcrypt - * 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 G10LIB_H -#define G10LIB_H 1 - -#ifdef _GCRYPT_H - #error gcrypt.h already included -#endif - -#include "gcrypt.h" - -#ifdef G10_I18N_H - #error i18n should not be included here -#endif - -#define _(a) g10_gettext(a) -#define N_(a) (a) - -/*-- global.c --*/ -int set_lasterr( int ec ); - -/*-- misc.c --*/ -const char *g10_gettext( const char *key ); -int fatal_invalid_arg(const char *text); - -#if 0 -/* This used to be the old include/g10lib.h */ - -#include "mpi.h" - -int g10c_debug_mode; -int g10_opt_verbose; - -/******************************** - ******* math functions ******* - ********************************/ -MPI g10m_new( unsigned nbits ); -MPI g10m_new_secure( unsigned nbits ); -void g10m_release( MPI a ); -void g10m_resize( MPI a, unsigned nbits ); -MPI g10m_copy( MPI a ); -void g10m_swap( MPI a, MPI b); -void g10m_set( MPI w, MPI u); -void g10m_set_ui( MPI w, unsigned long u); -void g10m_set_bytes( MPI a, unsigned nbits, unsigned char (*fnc)(int), int opaque ); -int g10m_cmp( MPI u, MPI v ); -int g10m_cmp_ui( MPI u, unsigned long 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 ); - - -/******************************************** - ******* symmetric cipher functions ******* - ********************************************/ - - - -/********************************************* - ******* asymmetric cipher functions ******* - *********************************************/ - - - - -/********************************************* - ******* cryptograhic hash functions ******* - *********************************************/ - - -/***************************************** - ******* miscellaneous functions ******* - *****************************************/ - -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 ); - - -/*************************** - ******* constants ******* - **************************/ -#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 - - -/*********************************** - ******* some handy macros ******* - ***********************************/ - -#ifndef BUG - #define BUG() g10_log_bug0( __FILE__ , __LINE__ ) -#endif - -#ifndef STR - #define STR(v) #v - #define STR2(v) STR(v) -#endif - -#ifndef DIM - #define DIM(v) (sizeof(v)/sizeof((v)[0])) - #define DIMof(type,member) DIM(((type *)0)->member) -#endif - - -#define DBG_CIPHER g10c_debug_mode -#define OPT_VERBOSE g10_opt_verbose - -#endif /* if 0 */ - - -#endif /* G10LIB_H */ diff --git a/src/gcrypt.h b/src/gcrypt.h deleted file mode 100644 index 37947027..00000000 --- a/src/gcrypt.h +++ /dev/null @@ -1,295 +0,0 @@ -/* gcrypt.h - GNU digital encryption library 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 - - -#ifndef HAVE_BYTE_TYPEDEF - #undef byte /* maybe there is a macro with this name */ - typedef unsigned char byte; - #define HAVE_BYTE_TYPEDEF -#endif - -/******************************************* - * * - * error handling etc. * - * * - *******************************************/ - -enum { - GCRYERR_SUCCESS = 0, /* "no error" */ - GCRYERR_GENERAL = 1, /* catch all the other errors code */ - GCRYERR_INV_OP = 2, /* invalid operation code or ctl command */ - GCRYERR_NOMEM = 3, /* out of core */ - GCRYERR_INV_ALGO = 4, /* invalid algorithm */ - GCRYERR_INV_ARG = 5, /* invalid argument */ - GCRYERR_INTERNAL = 6, /* internal error */ - GCRYERR_TOO_SHORT = 7, /* provided buffer too short */ - GCRYERR_EOF = 8, /* (-1) is remapped to this value */ -}; - - -int gcry_errno(void); -const char *gcry_strerror( int ec ); - -enum gcry_ctl_cmds { - GCRYCTL_SET_KEY = 1, - GCRYCTL_SET_IV = 2, - GCRYCTL_CFB_SYNC = 3, -}; - -int gcry_control( enum gcry_ctl_cmds, ... ); - - -/******************************************* - * * - * 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) ) - -#if 0 -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 - -#endif /* GCRYPT_NO_MPI_MACROS */ - -/******************************************** - ******* symmetric cipher functions ******* - ********************************************/ - -struct gcry_cipher_context; -typedef struct gcry_cipher_context *GCRY_CIPHER_HD; - -enum gcry_cipher_algos { - GCRY_CIPHER_NONE = 0, - GCRY_CIPHER_IDEA = 1, - GCRY_CIPHER_3DES = 2, - GCRY_CIPHER_CAST5 = 3, - GCRY_CIPHER_BLOWFISH = 4, - GCRY_CIPHER_SAFER_SK128 = 5, - GCRY_CIPHER_DES_SK = 6 -}; - -enum gcry_cipher_modes { - GCRY_CIPHER_MODE_NONE = 0, - GCRY_CIPHER_MODE_ECB = 1, - GCRY_CIPHER_MODE_CFB = 2, -}; - -enum gcry_cipher_flags { - GCRY_CIPHER_SECURE = 1, /* allocate in secure memory */ - GCRY_CIPHER_ENABLE_SYNC = 2, /* enable CFB sync mode */ -}; - - -#if 0 /* not yet done */ -int gcry_string_to_cipher_algo( const char *string ); -const char * gcry_cipher_algo_to_string( int algo ); -int gcry_check_cipher_algo( int algo ); -unsigned gcry_cipher_get_keylen( int algo ); -unsigned gcry_cipher_get_blocksize( int algo ); -#endif - -GCRY_CIPHER_HD gcry_cipher_open( int algo, int mode, unsigned flags ); -void gcry_cipher_close( GCRY_CIPHER_HD h ); -int gcry_cipher_ctl( GCRY_CIPHER_HD h, int cmd, byte *buffer, size_t buflen); - -int gcry_cipher_encrypt( GCRY_CIPHER_HD h, byte *out, size_t outsize, - byte *in, size_t inlen ); -int gcry_cipher_decrypt( GCRY_CIPHER_HD h, byte *out, size_t outsize, - byte *in, size_t inlen ); - - -/* some handy macros */ -#define gcry_cipher_setkey(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_KEY, \ - (k), (l) ) -#define gcry_cipher_setiv(h,k,l) gcry_cipher_ctl( (h), GCRYCTL_SET_IV, \ - (k), (l) ) -#define gcry_cipher_sync(h) gcry_cipher_ctl( (h), GCRYCTL_CFB_SYNC, \ - NULL, 0 ) - - -/********************************************* - ******* 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/global.c b/src/global.c deleted file mode 100644 index 7c5e21b8..00000000 --- a/src/global.c +++ /dev/null @@ -1,78 +0,0 @@ -/* global.c - global control functions - * 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> - -#include "g10lib.h" - -static int last_ec; /* fixme: make thread safe */ - - -int -gcry_control( enum gcry_ctl_cmds cmd, ... ) -{ - #if 0 - switch( cmd ) { - case GCRYCTL_NO_MEM_IS_FATAL: - break; - case GCRYCTL_SET_FATAL_FNC: - break; - } - #endif - return GCRYERR_INV_OP; -} - -int -gcry_errno() -{ - return last_ec; -} - -const char* -gcry_strerror( int ec ) -{ - const char *s; - static char buf[20]; - - if( ec == -1 ) - ec = gcry_errno(); - switch( ec ) { - default: - sprintf( buf, "ec=%d", ec ); - s = buf; - } - return s; -} - - -int -set_lasterr( int ec ) -{ - if( ec ) - last_ec = ec == -1 ? GCRYERR_EOF : ec; - return ec; -} - - diff --git a/src/mdapi.c b/src/mdapi.c deleted file mode 100644 index 8c1a6342..00000000 --- a/src/mdapi.c +++ /dev/null @@ -1,31 +0,0 @@ -/* mdapi.c - message digest 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> - -#include "g10lib.h" - - - diff --git a/src/misc.c b/src/misc.c deleted file mode 100644 index e1e135cc..00000000 --- a/src/misc.c +++ /dev/null @@ -1,50 +0,0 @@ -/* misc.c - symmetric cipher 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> - -#include "g10lib.h" - - -const char * -g10_gettext( const char *key ) -{ - /* switch the domain to gnupg and restore later */ - return key; -} - - - -/**************** - * This function is here as a default fatal error - * handler. The caller might want to use his own. - */ -int -fatal_invalid_arg(const char *text) -{ - /*log_error("Fatal error: %s\n", text );*/ - return GCRYERR_INV_ARG; -} - diff --git a/src/mpiapi.c b/src/mpiapi.c deleted file mode 100644 index 041d34c8..00000000 --- a/src/mpiapi.c +++ /dev/null @@ -1,65 +0,0 @@ -/* mpiapi.a - 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> - -#define GCRYPT_NO_MPI_MACROS 1 -#include "g10lib.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; - } -} - diff --git a/src/pkapi.c b/src/pkapi.c deleted file mode 100644 index e3d900a6..00000000 --- a/src/pkapi.c +++ /dev/null @@ -1,31 +0,0 @@ -/* pkapi.c - public key 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> - -#include "g10lib.h" - - - diff --git a/src/symapi.c b/src/symapi.c deleted file mode 100644 index ffe967a5..00000000 --- a/src/symapi.c +++ /dev/null @@ -1,144 +0,0 @@ -/* symapi.c - symmetric cipher 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 - */ - -/* fixme: merge this function with ../cipher/cipher.c */ - -#include <config.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <assert.h> - -#include "g10lib.h" -#define G10_MPI_H /* fake mpi.h header */ -#include "cipher.h" - - -#define CONTEXT_MAGIC 0x12569afe - -struct gcry_cipher_context { - u32 magic; - int mode; - unsigned flags; - CIPHER_HANDLE hd; -}; - - -GCRY_CIPHER_HD -gcry_cipher_open( int algo, int mode, unsigned flags ) -{ - GCRY_CIPHER_HD h; - - /* check whether the algo is available */ - if( check_cipher_algo( algo ) ) { - set_lasterr( GCRYERR_INV_ALGO ); - return NULL; - } - /* check flags */ - if( (flags & ~(GCRY_CIPHER_SECURE|GCRY_CIPHER_ENABLE_SYNC)) ) { - set_lasterr( GCRYERR_INV_ARG ); - return NULL; - } - - /* map mode to internal mode */ - switch( mode ) { - case GCRY_CIPHER_MODE_NONE: mode = CIPHER_MODE_DUMMY; break; - case GCRY_CIPHER_MODE_ECB: mode = CIPHER_MODE_ECB; break; - case GCRY_CIPHER_MODE_CFB: - mode = (flags & GCRY_CIPHER_ENABLE_SYNC) ? CIPHER_MODE_PHILS_CFB - : CIPHER_MODE_CFB; - break; - default: - set_lasterr( GCRYERR_INV_ALGO ); - return NULL; - } - - /* allocate the handle */ - h = m_lib_alloc_clear( sizeof *h ); - if( !h ) { - set_lasterr( GCRYERR_NOMEM ); - return NULL; - } - h->magic = CONTEXT_MAGIC; - h->mode = mode; - h->hd = cipher_open( algo, mode, (flags & GCRY_CIPHER_SECURE) ); - if( !h ) { - m_lib_free( h ); - set_lasterr( GCRYERR_INTERNAL ); - return NULL; - } - - return h; -} - - -void -gcry_cipher_close( GCRY_CIPHER_HD h ) -{ - if( !h ) - return; - if( h->magic != CONTEXT_MAGIC ) { - fatal_invalid_arg("gcry_cipher_close: already closed/invalid handle"); - return; - } - cipher_close( h->hd ); - h->magic = 0; - m_lib_free(h); -} - -int gcry_cipher_ctl( GCRY_CIPHER_HD h, int cmd, byte *buffer, size_t buflen) -{ - switch( cmd ) { - case GCRYCTL_SET_KEY: - cipher_setkey( h->hd, buffer, buflen ); - break; - case GCRYCTL_SET_IV: - cipher_setiv( h->hd, buffer ); - break; - case GCRYCTL_CFB_SYNC: - cipher_sync( h->hd ); - default: - return set_lasterr( GCRYERR_INV_OP ); - } - return 0; -} - - -int -gcry_cipher_encrypt( GCRY_CIPHER_HD h, byte *out, size_t outsize, - byte *in, size_t inlen ) -{ - if( outsize < inlen ) - return set_lasterr( GCRYERR_TOO_SHORT ); - cipher_encrypt( h->hd, out, in, inlen ); - return 0; -} - -int -gcry_cipher_decrypt( GCRY_CIPHER_HD h, byte *out, size_t outsize, - byte *in, size_t inlen ) -{ - if( outsize < inlen ) - return set_lasterr( GCRYERR_TOO_SHORT ); - cipher_decrypt( h->hd, out, in, inlen ); - return 0; -} - |