Even though C specification explicitly says that constant type "stretches"
authorAndy Polyakov <appro@openssl.org>
Sun, 25 Jan 2004 10:53:43 +0000 (10:53 +0000)
committerAndy Polyakov <appro@openssl.org>
Sun, 25 Jan 2004 10:53:43 +0000 (10:53 +0000)
automatically to accomodate the value, some compilers fail to do so. Most
notably 0x0123456789ABCDEF should come out as long long in 32-bit context,
but HP compiler truncates it to 32-bit value. Which in turn breaks GF(2^m)
arithmetics in hpux-parisc2-cc build. Therefore this fix...

crypto/bn/bn_gf2m.c
crypto/bn/bn_nist.c

index fb3a8a9c7752b7ff8727b1c6921cdc519af25c4f..30520eedecdca03aebaf63506a33392c61957d67 100644 (file)
@@ -228,7 +228,7 @@ static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const
        BN_ULONG tab[16], top3b = a >> 61;
        register BN_ULONG a1, a2, a4, a8;
 
-       a1 = a & (0x1FFFFFFFFFFFFFFF); a2 = a1 << 1; a4 = a2 << 1; a8 = a4 << 1;
+       a1 = a & (0x1FFFFFFFFFFFFFFFULL); a2 = a1 << 1; a4 = a2 << 1; a8 = a4 << 1;
 
        tab[ 0] = 0;     tab[ 1] = a1;       tab[ 2] = a2;       tab[ 3] = a1^a2;
        tab[ 4] = a4;    tab[ 5] = a1^a4;    tab[ 6] = a2^a4;    tab[ 7] = a1^a2^a4;
index 6aa196f6f86959ede237f1bb07be558daebfacbf..f30f6c65d1692acb9cb643652ca489544c1b7876 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};