]> git.codecow.com Git - Monocypher.git/commitdiff
Convert int indices to size_t
authorLoup Vaillant <loup@loup-vaillant.fr>
Thu, 29 Nov 2018 21:32:39 +0000 (22:32 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Thu, 29 Nov 2018 21:32:49 +0000 (22:32 +0100)
Fixes #111 (MSVC warnings)

All indices in Monocypher are size_t.  We might as well be consistent.

src/monocypher.c

index 6ea9832e96e4aded09b3f28a7489473a45618f95..0ccd1812214b92443b4491537f34049289ebf523 100644 (file)
@@ -1288,7 +1288,7 @@ static void trim_scalar(u8 s[32])
     s[31] |= 64;
 }
 
-static int scalar_bit(const u8 s[32], int i) { return (s[i>>3] >> (i&7)) & 1; }
+static int scalar_bit(const u8 s[32], size_t i) {return (s[i>>3] >> (i&7)) & 1;}
 
 int crypto_x25519(u8       raw_shared_secret[32],
                   const u8 your_secret_key  [32],
@@ -1600,7 +1600,7 @@ static void slide(i8 adds[258], const u8 scalar[32])
             if (adds[i] > 16) {
                 // go back to [-15, 15], propagate carry.
                 adds[i] -= 32;
-                int j = i + 5;
+                size_t j = i + 5;
                 while (adds[j] != 0) {
                     adds[j] = 0;
                     j++;