summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_lib.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2004-06-17 20:13:50 +0000
committerGeoff Thorpe <geoff@openssl.org>2004-06-17 20:13:50 +0000
commit9088d5f24f467bb8d0c08d78be416cc8226bbcad (patch)
treea411c8a6743d1b322a3966ae9a641d3a3d6d9ed2 /crypto/bn/bn_lib.c
parentcf9056cfda3976fc53a630f9965b68569d656e27 (diff)
As Nils put it;
Yet another question: some time ago you changed BN_set_word. Why didn't you change BN_get_word as well? Quite. I'm also removing the older commented-out implementations to improve readability. This complex stuff seems to date from a time when the types didn't match up well. Submitted by: Nils Larsch, Geoff Thorpe
Diffstat (limited to 'crypto/bn/bn_lib.c')
-rw-r--r--crypto/bn/bn_lib.c52
1 files changed, 4 insertions, 48 deletions
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 0cc20d9239..8aa817dfc6 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -616,55 +616,12 @@ void BN_clear(BIGNUM *a)
BN_ULONG BN_get_word(const BIGNUM *a)
{
- int i,n;
- BN_ULONG ret=0;
-
- n=BN_num_bytes(a);
- if (n > (int)sizeof(BN_ULONG))
- return(BN_MASK2);
- for (i=a->top-1; i>=0; i--)
- {
-#ifndef SIXTY_FOUR_BIT /* the data item > unsigned long */
- ret<<=BN_BITS4; /* stops the compiler complaining */
- ret<<=BN_BITS4;
-#else
- ret=0;
-#endif
- ret|=a->d[i];
- }
- return(ret);
+ if (a->top > 1)
+ return BN_MASK2;
+ else
+ return a->d[0];
}
-#if 0 /* a->d[0] is a BN_ULONG, w is a BN_ULONG, what's the big deal? */
-int BN_set_word(BIGNUM *a, BN_ULONG w)
- {
- int i,n;
- bn_check_top(a);
- if (bn_expand(a,(int)sizeof(BN_ULONG)*8) == NULL) return(0);
-
- n=sizeof(BN_ULONG)/BN_BYTES;
- a->neg=0;
- a->top=0;
- a->d[0]=(BN_ULONG)w&BN_MASK2;
- if (a->d[0] != 0) a->top=1;
- for (i=1; i<n; i++)
- {
- /* the following is done instead of
- * w>>=BN_BITS2 so compilers don't complain
- * on builds where sizeof(long) == BN_TYPES */
-#ifndef SIXTY_FOUR_BIT /* the data item > unsigned long */
- w>>=BN_BITS4;
- w>>=BN_BITS4;
-#else
- w=0;
-#endif
- a->d[i]=(BN_ULONG)w&BN_MASK2;
- if (a->d[i] != 0) a->top=i+1;
- }
- bn_check_top(a);
- return(1);
- }
-#else
int BN_set_word(BIGNUM *a, BN_ULONG w)
{
bn_check_top(a);
@@ -675,7 +632,6 @@ int BN_set_word(BIGNUM *a, BN_ULONG w)
bn_check_top(a);
return(1);
}
-#endif
BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
{