Skip to content

Commit 5998844

Browse files
committed
format source using new style specification
Just do `make format` Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
1 parent 3d30156 commit 5998844

17 files changed

+2890
-2378
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
all: dut_aes32 dut_aesbitsliced dut_donna dut_donnabad dut_simple
22

3+
SRC_DIR = src
4+
SOURCES = $(wildcard $(SRC_DIR)/*.h)
5+
EXAMPLE_DIR = examples
6+
EXAMPLE_HEADERS = $(wildcard $(EXAMPLE_DIR)/*/*.h)
7+
EXAMPLE_SOURCES = $(wildcard $(EXAMPLE_DIR)/*/*.c)
8+
39
OBJS_AES32 = examples/aes32/rijndael-alg-fst.o
410
OBJS_DONNA = examples/donna/curve25519-donna.o
511
OBJS_DONNABAD = examples/donnabad/curve25519-donnabad.o
@@ -43,5 +49,9 @@ dut_simple: examples/simple/example.c
4349
clean:
4450
rm -f $(OBJS_AES32) $(OBJS_AESBITSLICED) $(OBJS_DONNA) $(OBJS_DONNABAD) dudect_* *.exe a.out
4551

52+
format: $(SOURCES) $(EXAMPLE_HEADERS) $(EXAMPLE_SOURCES)
53+
clang-format -i $^
54+
55+
4656
test: all
4757
python test.py

examples/aes32/dut_aes32.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1-
#include <stdlib.h>
2-
#include <stdint.h>
3-
#include <string.h>
41
#include "rijndael-alg-fst.h"
2+
#include <stdint.h>
3+
#include <stdlib.h>
4+
#include <string.h>
55

66
#define DUDECT_IMPLEMENTATION
77
#include "dudect.h"
88

9-
static uint32_t rk[44] = {0};
9+
static uint32_t rk[44] = { 0 };
1010

11-
uint8_t do_one_computation(uint8_t *data) {
12-
uint8_t in[16] = {0};
13-
uint8_t out[16] = {0};
11+
uint8_t
12+
do_one_computation(uint8_t* data)
13+
{
14+
uint8_t in[16] = { 0 };
15+
uint8_t out[16] = { 0 };
1416
uint8_t ret = 0;
1517

1618
memcpy(in, data, 16);
1719

1820
rijndaelEncrypt(rk, 10, in, out);
1921

2022
ret ^= out[0];
21-
/* return some computation output to try to tame a clever optimizing compiler */
23+
/* return some computation output to try to tame a clever optimizing compiler
24+
*/
2225
return ret;
2326
}
2427

25-
void prepare_inputs(dudect_config_t *c, uint8_t *input_data, uint8_t *classes) {
28+
void
29+
prepare_inputs(dudect_config_t* c, uint8_t* input_data, uint8_t* classes)
30+
{
2631
randombytes(input_data, c->number_measurements * c->chunk_size);
2732
for (size_t i = 0; i < c->number_measurements; i++) {
2833
classes[i] = randombit();
@@ -34,18 +39,19 @@ void prepare_inputs(dudect_config_t *c, uint8_t *input_data, uint8_t *classes) {
3439
}
3540
}
3641

37-
int main(int argc, char **argv)
42+
int
43+
main(int argc, char** argv)
3844
{
3945
(void)argc;
4046
(void)argv;
4147

4248
dudect_config_t config = {
43-
.chunk_size = 16,
44-
.number_measurements = 1e6,
49+
.chunk_size = 16,
50+
.number_measurements = 1e6,
4551
};
4652
dudect_ctx_t ctx;
4753

48-
uint8_t cipherKey[16] = {0};
54+
uint8_t cipherKey[16] = { 0 };
4955
rijndaelKeySetupEnc(rk, cipherKey, 128);
5056

5157
dudect_init(&ctx, &config);
@@ -68,4 +74,3 @@ int main(int argc, char **argv)
6874
dudect_free(&ctx);
6975
return (int)state;
7076
}
71-

examples/aes32/rijndael-alg-fst.c

Lines changed: 1050 additions & 1267 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)