Fix share id == 0 check for share at index 0
[shamirs] / main.c
diff --git a/main.c b/main.c
index 42ec45ebcc4c17392bd2fa33e233f5b338b32843..af5a7d791425ac764d77ffeb10640ad2186e4b24 100644 (file)
--- a/main.c
+++ b/main.c
@@ -3,18 +3,21 @@
  *
  * Copyright (C) 2013 Matt Corallo <git@bluematt.me>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
+ * This file is part of ASSS (Audit-friendly Shamir's Secret Sharing)
  *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
+ * ASSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
+ * ASSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with ASSS.  If not, see
+ * <http://www.gnu.org/licenses/>.
  */
 
 #define _GNU_SOURCE
@@ -198,7 +201,7 @@ int main(int argc, char* argv[]) {
 
                // TODO: The following loop may take a long time and eat lots of /dev/random if total_shares is high
                for (uint32_t i = 0; i < total_shares; i++) {
-                       int32_t j = 0;
+                       int32_t j = -1;
                        do {
                                assert(fread(&x[i], sizeof(uint8_t), 1, random) == 1);
                                if (x[i] == 0)
@@ -206,7 +209,7 @@ int main(int argc, char* argv[]) {
                                for (j = 0; j < i; j++)
                                        if (x[j] == x[i])
                                                break;
-                       } while (j < i); // Inner loop will get to j = i when x[j] != x[i] for all j
+                       } while (j < (int32_t)i); // Inner loop will get to j = i when x[j] != x[i] for all j
                        if (i % 32 == 31)
                                printf("Finished picking X coordinates for %u shares\n", i+1);
                }