From 421e5acbd6f375ca9f2f16d260fe9c5505fb42f4 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 15 Apr 2013 14:18:29 -0400 Subject: [PATCH] tweak, build.sh --- build.sh | 3 +++ shamirssecret.c | 5 +++++ 2 files changed, 8 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b473a52 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/sh +gcc shamirssecret.c -O2 -std=c99 -DTEST -o shamirssecret && ./shamirssecret && +gcc shamirssecret.c -O2 -std=c99 -o shamirssecret diff --git a/shamirssecret.c b/shamirssecret.c index cc3e713..be6eed3 100644 --- a/shamirssecret.c +++ b/shamirssecret.c @@ -102,6 +102,11 @@ static uint8_t field_pow_ret(uint8_t calc, uint8_t a, uint8_t e) { return ret; } static uint8_t field_pow(uint8_t a, uint8_t e) { +#ifndef TEST + // Although this function works for a==0, its not trivially obvious why, + // and since we never call with a==0, we just assert a != 0 (except when testing) + assert(a != 0); +#endif return field_pow_ret(exp[(log[a] * e) % 255], a, e); } -- 2.30.2