summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-01-07 17:05:44 +0000
committerWerner Koch <wk@gnupg.org>1999-01-07 17:05:44 +0000
commit37cdf7d88bad91e9b6d66bad7dc91082142cccc2 (patch)
treea91d15d325d26afd60e6416905de0df6b1199388
parentaf1719288e56347975b751fe1ab2384982bf8b07 (diff)
downloadlibgcrypt-37cdf7d88bad91e9b6d66bad7dc91082142cccc2.tar.gz
See ChangeLog: Thu Jan 7 18:00:58 CET 1999 Werner Koch
-rw-r--r--cipher/ChangeLog5
-rw-r--r--cipher/md.c28
-rw-r--r--configure.in2
-rw-r--r--mpi/ChangeLog7
-rw-r--r--mpi/mpi-bit.c13
-rw-r--r--mpi/mpi-cmp.c23
6 files changed, 62 insertions, 16 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 328f2649..347d3469 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * md.c (md_stop_debug): Do a flush first.
+ (md_open): size of buffer now depends on the secure parameter
+
Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* rndunix.c (start_gatherer): Fixed stupid ==/= bug
diff --git a/cipher/md.c b/cipher/md.c
index b1274c63..f7be5e4c 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <assert.h>
#include "util.h"
#include "cipher.h"
#include "errors.h"
@@ -208,8 +209,18 @@ MD_HANDLE
md_open( int algo, int secure )
{
MD_HANDLE hd;
- hd = secure ? m_alloc_secure_clear( sizeof *hd )
- : m_alloc_clear( sizeof *hd );
+ int bufsize;
+
+ if( secure ) {
+ bufsize = 512 - sizeof( *hd );
+ hd = m_alloc_secure_clear( sizeof *hd + bufsize );
+ }
+ else {
+ bufsize = 1024 - sizeof( *hd );
+ hd = m_alloc_clear( sizeof *hd + bufsize );
+ }
+
+ hd->bufsize = bufsize+1; /* hd has already one byte allocated */
hd->secure = secure;
if( algo )
md_enable( hd, algo );
@@ -252,9 +263,11 @@ md_copy( MD_HANDLE a )
MD_HANDLE b;
struct md_digest_list_s *ar, *br;
- b = a->secure ? m_alloc_secure( sizeof *b )
- : m_alloc( sizeof *b );
- memcpy( b, a, sizeof *a );
+ if( a->bufcount )
+ md_write( a, NULL, 0 );
+ b = a->secure ? m_alloc_secure( sizeof *b + a->bufsize - 1 )
+ : m_alloc( sizeof *b + a->bufsize - 1 );
+ memcpy( b, a, sizeof *a + a->bufsize - 1 );
b->list = NULL;
b->debug = NULL;
/* and now copy the complete list of algorithms */
@@ -266,6 +279,9 @@ md_copy( MD_HANDLE a )
br->next = b->list;
b->list = br;
}
+
+ if( a->debug )
+ md_start_debug( b, "unknown" );
return b;
}
@@ -490,6 +506,8 @@ void
md_stop_debug( MD_HANDLE md )
{
if( md->debug ) {
+ if( md->bufcount )
+ md_write( md, NULL, 0 );
fclose(md->debug);
md->debug = NULL;
}
diff --git a/configure.in b/configure.in
index 04508171..f7104866 100644
--- a/configure.in
+++ b/configure.in
@@ -106,6 +106,8 @@ case "${target}" in
CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
fi
;;
+ m68k-atari-mint)
+ ;;
*)
;;
esac
diff --git a/mpi/ChangeLog b/mpi/ChangeLog
index 2b0d99ec..9d79660e 100644
--- a/mpi/ChangeLog
+++ b/mpi/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * mpi-bit.c (mpi_normalize): New.
+ (mpi_get_nbits): Normalize the MPI.
+ * mpi-bit.c (mpi_cmp): Normalize the MPI before the compare.
+
+
Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* config.links: Moved the case for powerpc*linux
diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c
index 8ca5c57d..227a929b 100644
--- a/mpi/mpi-bit.c
+++ b/mpi/mpi-bit.c
@@ -48,7 +48,19 @@ __clz_tab[] =
#define A_LIMB_1 ((mpi_limb_t)1)
+/****************
+ * Sometimes we have MSL (most significant limbs) which are 0;
+ * this is for some reasons not good, so this function removes them.
+ */
+void
+mpi_normalize( MPI a )
+{
+ if( mpi_is_protected(a) )
+ return;
+ for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
+ ;
+}
@@ -67,6 +79,7 @@ mpi_get_nbits( MPI a )
return n;
}
+ mpi_normalize( a );
if( a->nlimbs ) {
mpi_limb_t alimb = a->d[a->nlimbs-1];
if( alimb )
diff --git a/mpi/mpi-cmp.c b/mpi/mpi-cmp.c
index f4dd70e9..3c3c76b7 100644
--- a/mpi/mpi-cmp.c
+++ b/mpi/mpi-cmp.c
@@ -46,27 +46,28 @@ mpi_cmp_ui( MPI u, unsigned long v )
int
mpi_cmp( MPI u, MPI v )
{
- mpi_size_t usize = u->nlimbs;
- mpi_size_t vsize = v->nlimbs;
+ mpi_size_t usize, vsize;
int cmp;
- /* FIXME: are the numbers always normalized? */
+ mpi_normalize( u );
+ mpi_normalize( v );
+ usize = u->nlimbs;
+ vsize = v->nlimbs;
if( !u->sign && v->sign )
return 1;
- else if( u->sign && !v->sign )
+ if( u->sign && !v->sign )
return -1;
- else if( usize != vsize && !u->sign && !v->sign )
+ if( usize != vsize && !u->sign && !v->sign )
return usize - vsize;
- else if( usize != vsize && u->sign && v->sign )
+ if( usize != vsize && u->sign && v->sign )
return vsize + usize;
- else if( !usize )
+ if( !usize )
return 0;
- else if( !(cmp=mpihelp_cmp( u->d, v->d, usize )) )
+ if( !(cmp=mpihelp_cmp( u->d, v->d, usize )) )
return 0;
- else if( (cmp < 0?1:0) == (u->sign?1:0))
+ if( (cmp < 0?1:0) == (u->sign?1:0))
return 1;
- else
- return -1;
+ return -1;
}