mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
See ChangeLog: Tue Oct 26 14:10:21 CEST 1999 Werner Koch
This commit is contained in:
parent
df4ecbb8d9
commit
cf70ca8d68
71 changed files with 4032 additions and 2869 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Oct 26 14:10:21 CEST 1999 Werner Koch <wk@gnupg.de>
|
||||
|
||||
* g10lib.h: Moved from ../gcrypt to here.
|
||||
|
||||
Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
|
||||
|
||||
|
||||
|
|
102
include/cipher.h
102
include/cipher.h
|
@ -57,38 +57,6 @@
|
|||
|| (a)==PUBKEY_ALGO_RSA_S )
|
||||
#define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL || (a)==PUBKEY_ALGO_ELGAMAL_E)
|
||||
|
||||
typedef struct {
|
||||
int algo;
|
||||
int keylen;
|
||||
byte key[32]; /* this is the largest used keylen (256 bit) */
|
||||
} DEK;
|
||||
|
||||
struct cipher_handle_s;
|
||||
typedef struct cipher_handle_s *CIPHER_HANDLE;
|
||||
|
||||
|
||||
#define CIPHER_MODE_ECB 1
|
||||
#define CIPHER_MODE_CFB 2
|
||||
#define CIPHER_MODE_PHILS_CFB 3
|
||||
#define CIPHER_MODE_AUTO_CFB 4
|
||||
#define CIPHER_MODE_DUMMY 5 /* used with algo DUMMY for no encryption */
|
||||
#define CIPHER_MODE_CBC 6
|
||||
|
||||
struct md_digest_list_s;
|
||||
|
||||
struct gcry_md_context {
|
||||
int secure;
|
||||
FILE *debug;
|
||||
int finalized;
|
||||
struct md_digest_list_s *list;
|
||||
int bufcount;
|
||||
int bufsize;
|
||||
byte buffer[1];
|
||||
};
|
||||
|
||||
typedef struct gcry_md_context *MD_HANDLE;
|
||||
|
||||
|
||||
int g10c_debug_mode;
|
||||
int g10_opt_verbose;
|
||||
const char *g10_opt_homedir;
|
||||
|
@ -96,82 +64,12 @@ const char *g10_opt_homedir;
|
|||
/*-- dynload.c --*/
|
||||
void register_cipher_extension( const char *mainpgm, const char *fname );
|
||||
|
||||
/*-- md.c --*/
|
||||
int string_to_digest_algo( const char *string );
|
||||
const char * digest_algo_to_string( int algo );
|
||||
int check_digest_algo( int algo );
|
||||
MD_HANDLE md_open( int algo, int secure );
|
||||
void md_enable( MD_HANDLE hd, int algo );
|
||||
MD_HANDLE md_copy( MD_HANDLE a );
|
||||
void md_reset( MD_HANDLE a );
|
||||
void md_close(MD_HANDLE a);
|
||||
void md_write( MD_HANDLE a, byte *inbuf, size_t inlen);
|
||||
void md_final(MD_HANDLE a);
|
||||
byte *md_read( MD_HANDLE a, int algo );
|
||||
int md_digest( MD_HANDLE a, int algo, byte *buffer, int buflen );
|
||||
int md_get_algo( MD_HANDLE a );
|
||||
int md_digest_length( int algo );
|
||||
const byte *md_asn_oid( int algo, size_t *asnlen, size_t *mdlen );
|
||||
void md_start_debug( MD_HANDLE a, const char *suffix );
|
||||
void md_stop_debug( MD_HANDLE a );
|
||||
#define md_is_secure(a) ((a)->secure)
|
||||
#define md_putc(h,c) \
|
||||
do { \
|
||||
if( (h)->bufcount == (h)->bufsize ) \
|
||||
md_write( (h), NULL, 0 ); \
|
||||
(h)->buffer[(h)->bufcount++] = (c) & 0xff; \
|
||||
} while(0)
|
||||
/*-- rmd160.c --*/
|
||||
void rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length );
|
||||
|
||||
|
||||
/*-- cipher.c --*/
|
||||
int string_to_cipher_algo( const char *string );
|
||||
const char * cipher_algo_to_string( int algo );
|
||||
void disable_cipher_algo( int algo );
|
||||
int check_cipher_algo( int algo );
|
||||
unsigned cipher_get_keylen( int algo );
|
||||
unsigned cipher_get_blocksize( int algo );
|
||||
CIPHER_HANDLE cipher_open( int algo, int mode, int secure );
|
||||
void cipher_close( CIPHER_HANDLE c );
|
||||
int cipher_setkey( CIPHER_HANDLE c, byte *key, unsigned keylen );
|
||||
void cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen );
|
||||
void cipher_encrypt( CIPHER_HANDLE c, byte *out, byte *in, unsigned nbytes );
|
||||
void cipher_decrypt( CIPHER_HANDLE c, byte *out, byte *in, unsigned nbytes );
|
||||
void cipher_sync( CIPHER_HANDLE c );
|
||||
|
||||
/*-- pubkey.c --*/
|
||||
#define PUBKEY_MAX_NPKEY 4
|
||||
#define PUBKEY_MAX_NSKEY 6
|
||||
#define PUBKEY_MAX_NSIG 2
|
||||
#define PUBKEY_MAX_NENC 2
|
||||
|
||||
int string_to_pubkey_algo( const char *string );
|
||||
const char * pubkey_algo_to_string( int algo );
|
||||
void disable_pubkey_algo( int algo );
|
||||
int check_pubkey_algo( int algo );
|
||||
int check_pubkey_algo2( int algo, unsigned use );
|
||||
int pubkey_get_npkey( int algo );
|
||||
int pubkey_get_nskey( int algo );
|
||||
int pubkey_get_nsig( int algo );
|
||||
int pubkey_get_nenc( int algo );
|
||||
unsigned pubkey_nbits( int algo, MPI *pkey );
|
||||
int pubkey_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors );
|
||||
int pubkey_check_secret_key( int algo, MPI *skey );
|
||||
int pubkey_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey );
|
||||
int pubkey_decrypt( int algo, MPI *result, MPI *data, MPI *skey );
|
||||
int pubkey_sign( int algo, MPI *resarr, MPI hash, MPI *skey );
|
||||
int pubkey_verify( int algo, MPI hash, MPI *data, MPI *pkey,
|
||||
int (*cmp)(void *, MPI), void *opaque );
|
||||
|
||||
/*-- smallprime.c --*/
|
||||
extern ushort small_prime_numbers[];
|
||||
|
||||
/*-- primegen.c --*/
|
||||
MPI generate_secret_prime( unsigned nbits );
|
||||
MPI generate_public_prime( unsigned nbits );
|
||||
MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits,
|
||||
MPI g, MPI **factors );
|
||||
|
||||
|
||||
#endif /*G10_CIPHER_H*/
|
||||
|
|
|
@ -9,5 +9,6 @@ util.h
|
|||
i18n.h
|
||||
host2net.h
|
||||
http.h
|
||||
g10lib.h
|
||||
|
||||
ChangeLog
|
||||
|
|
212
include/g10lib.h
Normal file
212
include/g10lib.h
Normal file
|
@ -0,0 +1,212 @@
|
|||
/* g10lib.h - internal defintions for libgcrypt
|
||||
* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
*
|
||||
* This header is to be used inside of libgcrypt in place of gcrypt.h.
|
||||
* This way we can easily distinguish between internal and external
|
||||
* usage of gcrypt.h
|
||||
*
|
||||
* 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)
|
||||
|
||||
/*-- gcrypt/global.c --*/
|
||||
int set_lasterr( int ec );
|
||||
|
||||
/*-- gcrypt/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 */
|
|
@ -54,7 +54,10 @@ struct gcry_mpi {
|
|||
mpi_limb_t *d; /* array with the limbs */
|
||||
};
|
||||
|
||||
typedef struct gcry_mpi *MPI;
|
||||
#ifndef DID_MPI_TYPEDEF
|
||||
typedef struct gcry_mpi *MPI;
|
||||
#define DID_MPI_TYPEDEF
|
||||
#endif
|
||||
|
||||
#define MPI_NULL NULL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue