summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-09-11 09:28:44 +0200
committerWerner Koch <wk@gnupg.org>2002-09-11 09:28:44 +0200
commit7a71a26d590666b8cdaa3165fb488db6b0673533 (patch)
tree3585d493dfc9db71b1f1d16c501a4b308dd52e1c
parent* g10.c, options.h: Removed option --emulate-checksum-bug. (diff)
downloadgnupg2-7a71a26d590666b8cdaa3165fb488db6b0673533.tar.xz
gnupg2-7a71a26d590666b8cdaa3165fb488db6b0673533.zip
* mpi-bit.c (mpi_normalize): Replaced the check for protected byV1-2-5V1-2-4V1-2-3RC-1-2-5rc2RC-1-2-5rc1RC-1-2-4rc1RC-1-2-3rc2RC-1-2-3rc1
is_opaque. (mpi_get_nbits): Removed the special case for protected MPIs. * mpicoder.c (do_get_buffer): Likewise. (mpi_print): Removed the nbit_info printing.
-rw-r--r--include/ChangeLog6
-rw-r--r--include/mpi.h7
-rw-r--r--mpi/ChangeLog8
-rw-r--r--mpi/mpi-bit.c9
-rw-r--r--mpi/mpicoder.c55
5 files changed, 41 insertions, 44 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index e7db18284..d486b05de 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,9 @@
+2002-09-10 Werner Koch <wk@gnupg.org>
+
+ * mpi.h (mpi_is_protected, mpi_set_protect_flag)
+ (mpi_clear_protect_flag): Removed.
+ (mpi_get_nbit_info, mpi_set_nbit_info): Removed.
+
2002-08-13 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add AES aliases for RIJNDAEL algo numbers.
diff --git a/include/mpi.h b/include/mpi.h
index 80d617b1d..7bb8271dc 100644
--- a/include/mpi.h
+++ b/include/mpi.h
@@ -71,7 +71,7 @@ struct gcry_mpi {
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 1: not used */
/* bit 2: the limb is a pointer to some m_alloced data */
mpi_limb_t *d; /* array with the limbs */
};
@@ -81,8 +81,6 @@ typedef struct gcry_mpi *MPI;
#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 --*/
@@ -111,9 +109,6 @@ typedef struct gcry_mpi *MPI;
#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 );
diff --git a/mpi/ChangeLog b/mpi/ChangeLog
index f20251ab4..238f69f31 100644
--- a/mpi/ChangeLog
+++ b/mpi/ChangeLog
@@ -1,3 +1,11 @@
+2002-09-10 Werner Koch <wk@gnupg.org>
+
+ * mpi-bit.c (mpi_normalize): Replaced the check for protected by
+ is_opaque.
+ (mpi_get_nbits): Removed the special case for protected MPIs.
+ * mpicoder.c (do_get_buffer): Likewise.
+ (mpi_print): Removed the nbit_info printing.
+
2002-09-03 Werner Koch <wk@gnupg.org>
* mpicoder.c (mpi_set_buffer): Cast all left operands of a shift
diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c
index fa6bf06e6..440e35212 100644
--- a/mpi/mpi-bit.c
+++ b/mpi/mpi-bit.c
@@ -55,7 +55,7 @@ __clz_tab[] =
void
mpi_normalize( MPI a )
{
- if( mpi_is_protected(a) )
+ if( mpi_is_opaque (a) )
return;
for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- )
@@ -72,13 +72,6 @@ mpi_get_nbits( MPI a )
{
unsigned n;
- if( mpi_is_protected(a) ) {
- n = mpi_get_nbit_info(a);
- if( !n )
- n = a->nlimbs * BITS_PER_MPI_LIMB;
- return n;
- }
-
mpi_normalize( a );
if( a->nlimbs ) {
mpi_limb_t alimb = a->d[a->nlimbs-1];
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c
index 1859b6331..f796888c8 100644
--- a/mpi/mpicoder.c
+++ b/mpi/mpicoder.c
@@ -255,29 +255,26 @@ mpi_print( FILE *fp, MPI a, int mode )
if( a == MPI_NULL )
return fprintf(fp, "[MPI_NULL]");
if( !mode ) {
- unsigned n1, n2;
+ unsigned int n1;
+
n1 = mpi_get_nbits(a);
- n2 = mpi_get_nbit_info(a);
- if( n2 && n2 != n1 )
- n += fprintf(fp, "[%u bits (%u)]", n1, n2 );
- else
- n += fprintf(fp, "[%u bits]", n1);
+ n += fprintf(fp, "[%u bits]", n1);
}
else {
if( a->sign )
putc('-', fp);
- #if BYTES_PER_MPI_LIMB == 2
- #define X "4"
- #elif BYTES_PER_MPI_LIMB == 4
- #define X "8"
- #elif BYTES_PER_MPI_LIMB == 8
- #define X "16"
- #else
- #error please define the format here
- #endif
+#if BYTES_PER_MPI_LIMB == 2
+#define X "4"
+#elif BYTES_PER_MPI_LIMB == 4
+#define X "8"
+#elif BYTES_PER_MPI_LIMB == 8
+#define X "16"
+#else
+#error please define the format here
+#endif
for(i=a->nlimbs; i > 0 ; i-- ) {
n += fprintf(fp, i!=a->nlimbs? "%0" X "lX":"%lX", (ulong)a->d[i-1]);
- #undef X
+#undef X
}
if( !a->nlimbs )
putc('0', fp );
@@ -344,12 +341,12 @@ do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure )
for(i=a->nlimbs-1; i >= 0; i-- ) {
alimb = a->d[i];
- #if BYTES_PER_MPI_LIMB == 4
+#if BYTES_PER_MPI_LIMB == 4
*p++ = alimb >> 24;
*p++ = alimb >> 16;
*p++ = alimb >> 8;
*p++ = alimb ;
- #elif BYTES_PER_MPI_LIMB == 8
+#elif BYTES_PER_MPI_LIMB == 8
*p++ = alimb >> 56;
*p++ = alimb >> 48;
*p++ = alimb >> 40;
@@ -358,20 +355,18 @@ do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure )
*p++ = alimb >> 16;
*p++ = alimb >> 8;
*p++ = alimb ;
- #else
- #error please implement for this limb size.
- #endif
+#else
+#error please implement for this limb size.
+#endif
}
- if (!mpi_is_protected (a))
- {
- /* this is sub-optimal but we need to do the shift operation
- * because the caller has to free the returned buffer */
- for(p=buffer; !*p && *nbytes; p++, --*nbytes )
- ;
- if( p != buffer )
- memmove(buffer,p, *nbytes);
- }
+ /* this is sub-optimal but we need to do the shift operation
+ * because the caller has to free the returned buffer */
+ for(p=buffer; !*p && *nbytes; p++, --*nbytes )
+ ;
+ if( p != buffer )
+ memmove(buffer,p, *nbytes);
+
return buffer;
}