Merge pull request #15 from altendky/makefile_rounds_parameters
Make *c* and *d* rounds less intrusively configurablemain
commit
1512ba4576
17
README.md
17
README.md
|
@ -42,11 +42,18 @@ verifies 64 test vectors, and
|
||||||
does the same and prints intermediate values.
|
does the same and prints intermediate values.
|
||||||
|
|
||||||
The code can be adapted to implement SipHash-*c*-*d*, the version of SipHash
|
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
|
with *c* compression rounds and *d* finalization rounds, by defining `cROUNDS`
|
||||||
lines
|
or `dROUNDS` when compiling. This can be done with `-D` command line arguments
|
||||||
```C
|
to many compilers such as below.
|
||||||
#define cROUNDS 2
|
|
||||||
#define dROUNDS 4
|
```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
|
Obviously, if the number of rounds is modified then the test vectors
|
||||||
|
|
|
@ -19,8 +19,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* default: SipHash-2-4 */
|
/* default: SipHash-2-4 */
|
||||||
|
#ifndef cROUNDS
|
||||||
#define cROUNDS 2
|
#define cROUNDS 2
|
||||||
|
#endif
|
||||||
|
#ifndef dROUNDS
|
||||||
#define dROUNDS 4
|
#define dROUNDS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ROTL(x, b) (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))
|
#define ROTL(x, b) (uint32_t)(((x) << (b)) | ((x) >> (32 - (b))))
|
||||||
|
|
||||||
|
|
8
makefile
8
makefile
|
@ -3,6 +3,14 @@ CFLAGS=-Wall --std=c99
|
||||||
SRC=siphash.c halfsiphash.c test.c
|
SRC=siphash.c halfsiphash.c test.c
|
||||||
BIN=test debug vectors
|
BIN=test debug vectors
|
||||||
|
|
||||||
|
ifneq ($(cROUNDS),)
|
||||||
|
CFLAGS:=$(CFLAGS) -DcROUNDS=$(cROUNDS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(dROUNDS),)
|
||||||
|
CFLAGS:=$(CFLAGS) -DdROUNDS=$(dROUNDS)
|
||||||
|
endif
|
||||||
|
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
|
|
||||||
test: $(SRC)
|
test: $(SRC)
|
||||||
|
|
|
@ -20,8 +20,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* default: SipHash-2-4 */
|
/* default: SipHash-2-4 */
|
||||||
|
#ifndef cROUNDS
|
||||||
#define cROUNDS 2
|
#define cROUNDS 2
|
||||||
|
#endif
|
||||||
|
#ifndef dROUNDS
|
||||||
#define dROUNDS 4
|
#define dROUNDS 4
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
|
#define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue