fix truncation of integers on 32bit AIX
[openssl.git] / crypto / ec / curve448 / curve448.c
index 7c43a758f91f02afcb055c634444efda1c752379..6236ad66383deeb619581b3ef4fa224ebf835788 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2015-2016 Cryptography Research, Inc.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -27,8 +27,8 @@
 static const curve448_scalar_t precomputed_scalarmul_adjustment = {
     {
         {
-            SC_LIMB(0xc873d6d54a7bb0cf), SC_LIMB(0xe933d8d723a70aad),
-            SC_LIMB(0xbb124b65129c96fd), SC_LIMB(0x00000008335dc163)
+            SC_LIMB(0xc873d6d54a7bb0cfULL), SC_LIMB(0xe933d8d723a70aadULL),
+            SC_LIMB(0xbb124b65129c96fdULL), SC_LIMB(0x00000008335dc163ULL)
         }
     }
 };
@@ -500,7 +500,7 @@ struct smvt_control {
     int power, addend;
 };
 
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
 # define NUMTRAILINGZEROS      __builtin_ctz
 #else
 # define NUMTRAILINGZEROS      numtrailingzeros
@@ -579,7 +579,7 @@ static int recode_wnaf(struct smvt_control *control,
             assert(position >= 0);
             if (odd & (1 << (table_bits + 1)))
                 delta -= (1 << (table_bits + 1));
-            current -= delta << pos;
+            current -= delta * (1 << pos);
             control[position].power = pos + 16 * (w - 1);
             control[position].addend = delta;
             position--;