Merge pull request #15 from altendky/makefile_rounds_parameters

Make *c* and *d* rounds less intrusively configurable
main
Jean-Philippe Aumasson 2019-09-13 20:40:30 +02:00 committed by GitHub
commit 1512ba4576
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 9 deletions

View File

@ -42,13 +42,20 @@ verifies 64 test vectors, and
does the same and prints intermediate values.
The code can be adapted to implement SipHash-*c*-*d*, the version of SipHash
with *c* compression rounds and *d* finalization rounds, by tweaking the
lines
```C
#define cROUNDS 2
#define dROUNDS 4
with *c* compression rounds and *d* finalization rounds, by defining `cROUNDS`
or `dROUNDS` when compiling. This can be done with `-D` command line arguments
to many compilers such as below.
```sh
gcc -Wall --std=c99 -DcROUNDS=2 -DdROUNDS=4 siphash.c halfsiphash.c test.c -o test
```
The `makefile` also takes *c* and *d* rounds values as parameters.
```sh
make cROUNDS=2 dROUNDS=4
```
Obviously, if the number of rounds is modified then the test vectors
won't verify.

View File

@ -19,8 +19,12 @@
#include <string.h>
/* default: SipHash-2-4 */
#define cROUNDS 2
#define dROUNDS 4
#ifndef cROUNDS
#define cROUNDS 2
#endif
#ifndef dROUNDS
#define dROUNDS 4
#endif
#define ROTL(x, b) (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))

View File

@ -3,6 +3,14 @@ CFLAGS=-Wall --std=c99
SRC=siphash.c halfsiphash.c test.c
BIN=test debug vectors
ifneq ($(cROUNDS),)
CFLAGS:=$(CFLAGS) -DcROUNDS=$(cROUNDS)
endif
ifneq ($(dROUNDS),)
CFLAGS:=$(CFLAGS) -DdROUNDS=$(dROUNDS)
endif
all: $(BIN)
test: $(SRC)

View File

@ -20,8 +20,12 @@
#include <string.h>
/* default: SipHash-2-4 */
#define cROUNDS 2
#define dROUNDS 4
#ifndef cROUNDS
#define cROUNDS 2
#endif
#ifndef dROUNDS
#define dROUNDS 4
#endif
#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))