Minimise the amount of code dependent on BN_DEBUG_RAND. In particular,
[openssl.git] / crypto / bn / bn_nist.c
index 6aa196f..a29503b 100644 (file)
 #define BN_NIST_521_TOP        (521+BN_BITS2-1)/BN_BITS2
 
 #if BN_BITS2 == 64
-const static BN_ULONG _nist_p_192[] = {0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFE,
-       0xFFFFFFFFFFFFFFFF};
-const static BN_ULONG _nist_p_224[] = {0x0000000000000001,0xFFFFFFFF00000000,
-       0xFFFFFFFFFFFFFFFF,0x00000000FFFFFFFF};
-const static BN_ULONG _nist_p_256[] = {0xFFFFFFFFFFFFFFFF,0x00000000FFFFFFFF,
-       0x0000000000000000,0xFFFFFFFF00000001};
-const static BN_ULONG _nist_p_384[] = {0x00000000FFFFFFFF,0xFFFFFFFF00000000,
-       0xFFFFFFFFFFFFFFFE,0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
-       0xFFFFFFFFFFFFFFFF};
-const static BN_ULONG _nist_p_521[] = {0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
-       0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
-       0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF,
-       0x00000000000001FF};
+const static BN_ULONG _nist_p_192[] =
+       {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFEULL,
+       0xFFFFFFFFFFFFFFFFULL};
+const static BN_ULONG _nist_p_224[] =
+       {0x0000000000000001ULL,0xFFFFFFFF00000000ULL,
+       0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL};
+const static BN_ULONG _nist_p_256[] =
+       {0xFFFFFFFFFFFFFFFFULL,0x00000000FFFFFFFFULL,
+       0x0000000000000000ULL,0xFFFFFFFF00000001ULL};
+const static BN_ULONG _nist_p_384[] =
+       {0x00000000FFFFFFFFULL,0xFFFFFFFF00000000ULL,
+       0xFFFFFFFFFFFFFFFEULL,0xFFFFFFFFFFFFFFFFULL,
+       0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL};
+const static BN_ULONG _nist_p_521[] =
+       {0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
+       0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
+       0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
+       0xFFFFFFFFFFFFFFFFULL,0xFFFFFFFFFFFFFFFFULL,
+       0x00000000000001FFULL};
 #elif BN_BITS2 == 32
 const static BN_ULONG _nist_p_192[] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFE,
        0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
@@ -353,12 +359,7 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
                        --carry; 
                }
        r->top = BN_NIST_192_TOP;
-
-#if 1
-       bn_clear_top2max(r);
-#endif
        bn_correct_top(r);
-
        if (BN_ucmp(r, field) >= 0)
                {
                bn_sub_words(r_d, r_d, _nist_p_192, BN_NIST_192_TOP);
@@ -447,11 +448,7 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
                        }
 
        r->top = BN_NIST_224_TOP;
-#if 1
-       bn_clear_top2max(r);
-#endif
        bn_correct_top(r);
-
        if (BN_ucmp(r, field) >= 0)
                {
                bn_sub_words(r_d, r_d, _nist_p_224, BN_NIST_224_TOP);
@@ -606,11 +603,7 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
                }
 
        r->top = BN_NIST_256_TOP;
-#if 1
-       bn_clear_top2max(r);
-#endif
        bn_correct_top(r);
-
        if (BN_ucmp(r, field) >= 0)
                {
                bn_sub_words(r_d, r_d, _nist_p_256, BN_NIST_256_TOP);
@@ -775,11 +768,7 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
                }
 
        r->top = BN_NIST_384_TOP;
-#if 1
-       bn_clear_top2max(r);
-#endif
        bn_correct_top(r);
-
        if (BN_ucmp(r, field) >= 0)
                {
                bn_sub_words(r_d, r_d, _nist_p_384, BN_NIST_384_TOP);