1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

extensions are now working and fixed a lot of bugs

This commit is contained in:
Werner Koch 1998-06-15 15:41:04 +00:00
parent e662bf708b
commit 6e1ca6b80f
40 changed files with 350 additions and 454 deletions

View file

@ -1,3 +1,7 @@
Mon Jun 15 14:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* tiger.c: Removed from dis, will reappear as dynload module
Sat Jun 13 14:16:57 1998 Werner Koch (wk@isil.d.shuttle.de)
* pubkey.c: Major changes to allow extensions. Changed the inteface

View file

@ -2,6 +2,7 @@
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl -I../intl
EXTRA_DIST = tiger.c
noinst_LIBRARIES = libcipher.a
@ -15,7 +16,6 @@ libcipher_a_SOURCES = cipher.c \
blowfish.h \
cast5.c \
cast5.h \
des.h \
elgamal.c \
elgamal.h \
md5.c \
@ -29,8 +29,6 @@ libcipher_a_SOURCES = cipher.c \
rand-dummy.c \
rmd.h \
rmd160.c \
tiger.h \
tiger.c \
sha1.h \
sha1.c \
dsa.h \

View file

@ -31,7 +31,6 @@
#include "cipher.h"
#include "blowfish.h"
#include "cast5.h"
#include "des.h"
#include "dynload.h"
@ -64,7 +63,6 @@ struct cipher_handle_s {
};
static void
dummy_setkey( void *c, byte *key, unsigned keylen ) { }
static void

View file

@ -25,7 +25,13 @@
#include <assert.h>
#include "util.h"
#include "types.h"
#include "des.h"
#define DES_BLOCKSIZE 8
#define DES_ROUNDS 16
typedef struct {
int tripledes;
} DES_context;
static const int IP[64] = {

View file

@ -1,37 +0,0 @@
/* des.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_DES_H
#define G10_DES_H
#include "types.h"
#define DES_BLOCKSIZE 8
#define DES_ROUNDS 16
typedef struct {
int tripledes;
} DES_context;
void des_setkey( DES_context *c, byte *key, unsigned keylen );
void des_3des_setkey( DES_context *c, byte *key, unsigned keylen );
void des_encrypt_block( DES_context *bc, byte *outbuf, byte *inbuf );
void des_decrypt_block( DES_context *bc, byte *outbuf, byte *inbuf );
#endif /*G10_DES_H*/

View file

@ -359,7 +359,8 @@ dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey )
}
int
dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey )
dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev )
{
DSA_public_key pk;

View file

@ -23,7 +23,8 @@
int dsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors );
int dsa_check_secret_key( int algo, MPI *skey );
int dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey );
int dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey );
int dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev );
unsigned dsa_get_nbits( int algo, MPI *pkey );
const char *dsa_get_info( int algo, int *npkey, int *nskey,
int *nenc, int *nsig, int *usage );

View file

@ -221,7 +221,8 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo,
int (**encrypt)( int algo, MPI *resarr, MPI data, MPI *pkey ),
int (**decrypt)( int algo, MPI *result, MPI *data, MPI *skey ),
int (**sign)( int algo, MPI *resarr, MPI data, MPI *skey ),
int (**verify)( int algo, MPI hash, MPI *data, MPI *pkey ),
int (**verify)( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev ),
unsigned (**get_nbits)( int algo, MPI *pkey ) )
{
EXTLIST r;
@ -232,7 +233,8 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo,
int (**)( int, MPI *, MPI , MPI * ),
int (**)( int, MPI *, MPI *, MPI * ),
int (**)( int, MPI *, MPI , MPI * ),
int (**)( int, MPI , MPI *, MPI * ),
int (**)( int, MPI , MPI *, MPI *,
int (*)(void*,MPI), void *),
unsigned (**)( int , MPI * ) );
if( !*enum_context ) { /* init context */

View file

@ -36,7 +36,8 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo,
int (**encrypt)( int algo, MPI *resarr, MPI data, MPI *pkey ),
int (**decrypt)( int algo, MPI *result, MPI *data, MPI *skey ),
int (**sign)( int algo, MPI *resarr, MPI data, MPI *skey ),
int (**verify)( int algo, MPI hash, MPI *data, MPI *pkey ),
int (**verify)( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev ),
unsigned (**get_nbits)( int algo, MPI *pkey ) );
#endif /*G10_CIPHER_DYNLOAD_H*/

View file

@ -476,7 +476,8 @@ elg_sign( int algo, MPI *resarr, MPI data, MPI *skey )
}
int
elg_verify( int algo, MPI hash, MPI *data, MPI *pkey )
elg_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev )
{
ELG_public_key pk;

View file

@ -25,7 +25,8 @@ int elg_check_secret_key( int algo, MPI *skey );
int elg_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey );
int elg_decrypt( int algo, MPI *result, MPI *data, MPI *skey );
int elg_sign( int algo, MPI *resarr, MPI data, MPI *skey );
int elg_verify( int algo, MPI hash, MPI *data, MPI *pkey );
int elg_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev );
unsigned elg_get_nbits( int algo, MPI *pkey );
const char *elg_get_info( int algo, int *npkey, int *nskey,
int *nenc, int *nsig, int *usage );

View file

@ -27,6 +27,7 @@
#define _g10lib_INTERNAL 1
#include "g10lib.h"
const char *g10c_revision_string(int dummy) { return "$Revision$"; }
MPI
g10c_generate_secret_prime( unsigned nbits )

View file

@ -38,7 +38,6 @@ static struct { const char *name; int algo;} digest_names[] = {
{ "RMD160", DIGEST_ALGO_RMD160 },
{ "RMD-160", DIGEST_ALGO_RMD160 },
{ "RIPE-MD-160", DIGEST_ALGO_RMD160 },
{ "TIGER", DIGEST_ALGO_TIGER },
{NULL} };
@ -79,9 +78,6 @@ int
check_digest_algo( int algo )
{
switch( algo ) {
#ifdef WITH_TIGER_HASH
case DIGEST_ALGO_TIGER:
#endif
case DIGEST_ALGO_MD5:
case DIGEST_ALGO_RMD160:
case DIGEST_ALGO_SHA1:
@ -134,13 +130,6 @@ md_enable( MD_HANDLE h, int algo )
sha1_init( &h->sha1 );
h->use_sha1 = 1;
}
#ifdef WITH_TIGER_HASH
else if( algo == DIGEST_ALGO_TIGER ) {
if( !h->use_tiger )
tiger_init( &h->tiger );
h->use_tiger = 1;
}
#endif
else
log_bug("md_enable(%d)", algo );
}
@ -186,12 +175,6 @@ md_write( MD_HANDLE a, byte *inbuf, size_t inlen)
sha1_write( &a->sha1, a->buffer, a->bufcount );
sha1_write( &a->sha1, inbuf, inlen );
}
#ifdef WITH_TIGER_HASH
if( a->use_tiger ) {
tiger_write( &a->tiger, a->buffer, a->bufcount );
tiger_write( &a->tiger, inbuf, inlen );
}
#endif
if( a->use_md5 ) {
md5_write( &a->md5, a->buffer, a->bufcount );
md5_write( &a->md5, inbuf, inlen );
@ -210,10 +193,6 @@ md_final(MD_HANDLE a)
rmd160_final( &a->rmd160 );
if( a->use_sha1 )
sha1_final( &a->sha1 );
#ifdef WITH_TIGER_HASH
if( a->use_tiger )
tiger_final( &a->tiger );
#endif
if( a->use_md5 )
md5_final( &a->md5 );
}
@ -230,10 +209,6 @@ md_read( MD_HANDLE a, int algo )
return rmd160_read( &a->rmd160 );
if( a->use_sha1 )
return sha1_read( &a->sha1 );
#ifdef WITH_TIGER_HASH
if( a->use_tiger )
return tiger_read( &a->tiger );
#endif
if( a->use_md5 )
return md5_read( &a->md5 );
}
@ -242,10 +217,6 @@ md_read( MD_HANDLE a, int algo )
return rmd160_read( &a->rmd160 );
if( algo == DIGEST_ALGO_SHA1 )
return sha1_read( &a->sha1 );
#ifdef WITH_TIGER_HASH
if( algo == DIGEST_ALGO_TIGER )
return tiger_read( &a->tiger );
#endif
if( algo == DIGEST_ALGO_MD5 )
return md5_read( &a->md5 );
}
@ -259,10 +230,6 @@ md_get_algo( MD_HANDLE a )
return DIGEST_ALGO_RMD160;
if( a->use_sha1 )
return DIGEST_ALGO_SHA1;
#ifdef WITH_TIGER_HASH
if( a->use_tiger )
return DIGEST_ALGO_TIGER;
#endif
if( a->use_md5 )
return DIGEST_ALGO_MD5;
return 0;
@ -275,8 +242,6 @@ int
md_digest_length( int algo )
{
switch( algo ) {
case DIGEST_ALGO_TIGER:
return 24;
case DIGEST_ALGO_RMD160:
case DIGEST_ALGO_SHA1:
return 20;

View file

@ -25,7 +25,6 @@
#include "rmd.h"
#include "sha1.h"
#include "md5.h"
#include "tiger.h"
#define MD_BUFFER_SIZE 512

View file

@ -28,6 +28,8 @@
#include "errors.h"
#include "mpi.h"
#include "cipher.h"
#include "elgamal.h"
#include "dsa.h"
#include "dynload.h"
@ -46,7 +48,8 @@ struct pubkey_table_s {
int (*encrypt)( int algo, MPI *resarr, MPI data, MPI *pkey );
int (*decrypt)( int algo, MPI *result, MPI *data, MPI *skey );
int (*sign)( int algo, MPI *resarr, MPI data, MPI *skey );
int (*verify)( int algo, MPI hash, MPI *data, MPI *pkey );
int (*verify)( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev );
unsigned (*get_nbits)( int algo, MPI *pkey );
};
@ -75,7 +78,8 @@ dummy_sign( int algo, MPI *resarr, MPI data, MPI *skey )
{ log_bug("no sign() for %d\n", algo ); return G10ERR_PUBKEY_ALGO; }
static int
dummy_verify( int algo, MPI hash, MPI *data, MPI *pkey )
dummy_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev )
{ log_bug("no verify() for %d\n", algo ); return G10ERR_PUBKEY_ALGO; }
static unsigned
@ -523,7 +527,8 @@ pubkey_sign( int algo, MPI *resarr, MPI data, MPI *skey )
* Return 0 if the signature is good
*/
int
pubkey_verify( int algo, MPI hash, MPI *data, MPI *pkey )
pubkey_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev )
{
int i, rc;
@ -531,7 +536,8 @@ pubkey_verify( int algo, MPI hash, MPI *data, MPI *pkey )
do {
for(i=0; pubkey_table[i].name; i++ )
if( pubkey_table[i].algo == algo ) {
rc = (*pubkey_table[i].verify)( algo, hash, data, pkey );
rc = (*pubkey_table[i].verify)( algo, hash, data, pkey,
cmp, opaquev );
goto ready;
}
} while( load_pubkey_modules() );

View file

@ -25,9 +25,15 @@
#include <assert.h>
#include "util.h"
#include "memory.h"
#include "tiger.h"
#ifdef WITH_TIGER_HASH
typedef struct {
u64 a, b, c;
u32 nblocks;
byte buf[64];
int count;
} TIGER_CONTEXT;
/*********************************
* Okay, okay, this is not the fastest code - improvements are welcome.
@ -845,5 +851,3 @@ tiger_final( TIGER_CONTEXT *hd )
#undef X
}
#endif /* WITH_TIGER_HASH */

View file

@ -1,44 +0,0 @@
/* tiger.h - TIGER hash function
* 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_TIGER_H
#define G10_TIGER_H
#include "types.h"
#ifdef HAVE_U64_TYPEDEF
#define WITH_TIGER_HASH 1
typedef struct {
u64 a, b, c;
u32 nblocks;
byte buf[64];
int count;
} TIGER_CONTEXT;
void tiger_init( TIGER_CONTEXT *c );
void tiger_write( TIGER_CONTEXT *hd, byte *inbuf, size_t inlen);
void tiger_final(TIGER_CONTEXT *hd);
#define tiger_read(h) ( (h)->buf )
#endif /* HAVE_TIGER_HASH */
#endif /*G10_TIGER_H*/